Skip to content

Commit

Permalink
cppcheck: added "--enable=warning"
Browse files Browse the repository at this point in the history
  • Loading branch information
danielinux committed Oct 13, 2023
1 parent 5f5b4a5 commit dcb82b6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ line-count-x86:
cloc --force-lang-def cloc_lang_def.txt src/boot_x86_fsp.c src/boot_x86_fsp_payload.c src/boot_x86_fsp_start.S src/image.c src/keystore.c src/libwolfboot.c src/loader.c src/string.c src/update_disk.c src/x86/ahci.c src/x86/ata.c src/x86/common.c src/x86/gpt.c src/x86/hob.c src/pci.c src/x86/tgl_fsp.c hal/x86_fsp_tgl.c hal/x86_uart.c

cppcheck:
cppcheck -f --suppress="ctunullpointer" --suppress="nullPointer" --suppress="objectIndex" --suppress="comparePointers" --error-exitcode=89 --std=c89 src/*.c hal/*.c hal/spi/*.c hal/uart/*.c
cppcheck -f --enable=warning --suppress="ctunullpointer" --suppress="nullPointer" --suppress="objectIndex" --suppress="comparePointers" --error-exitcode=89 --std=c89 src/*.c hal/*.c hal/spi/*.c hal/uart/*.c

%.o:%.c
@echo "\t[CC-$(ARCH)] $@"
Expand Down
14 changes: 7 additions & 7 deletions hal/spi/spi_drv_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,32 +84,32 @@ void RAMFUNCTION stm_gpio_config(uint32_t base, uint32_t pin, uint32_t mode,
RCC_GPIO_CLOCK_ER |= (1 << base_num);

/* Set Mode and Alternate Function */
reg = GPIO_MODE(base) & ~(0x03 << (pin * 2));
reg = GPIO_MODE(base) & ~(0x03UL << (pin * 2));
GPIO_MODE(base) = reg | (mode << (pin * 2));
if (mode < 2) {
if (pin < 8)
GPIO_AFL(base) &= ~(0xf << (pin * 4));
GPIO_AFL(base) &= ~(0xfUL << (pin * 4));
else
GPIO_AFH(base) &= ~(0xf << ((pin - 8) * 4));
GPIO_AFH(base) &= ~(0xfUL << ((pin - 8) * 4));
}
else if (mode == 2) {
/* alternate mode */
if (pin < 8) {
reg = GPIO_AFL(base) & ~(0xf << (pin * 4));
reg = GPIO_AFL(base) & ~(0xfUL << (pin * 4));
GPIO_AFL(base) = reg | (af << (pin * 4));
}
else {
reg = GPIO_AFH(base) & ~(0xf << ((pin - 8) * 4));
reg = GPIO_AFH(base) & ~(0xfUL << ((pin - 8) * 4));
GPIO_AFH(base) = reg | (af << ((pin - 8) * 4));
}
}

/* configure for pull 0=float, 1=pull up, 2=pull down */
reg = GPIO_PUPD(base) & ~(0x03 << (pin * 2));
reg = GPIO_PUPD(base) & ~(0x03UL << (pin * 2));
GPIO_PUPD(base) = reg | (pull << (pin * 2));

/* configure output speed 0=low, 1=med, 2=high, 3=very high */
reg = GPIO_OSPD(base) & ~(0x03 << (pin * 2));
reg = GPIO_OSPD(base) & ~(0x03UL << (pin * 2));
GPIO_OSPD(base) |= (speed << (pin * 2));
}

Expand Down
4 changes: 3 additions & 1 deletion hal/x86_64_efi.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ static UINT64 FileSize(EFI_FILE_HANDLE FileHandle)
UINT64 ret;

FileInfo = LibFileInfo(FileHandle);
if (FileInfo == NULL)
if (FileInfo == NULL) {
panic();
return 0; /* Never reached, for static analyzer */
}

ret = FileInfo->FileSize;
FreePool(FileInfo);
Expand Down
2 changes: 1 addition & 1 deletion src/update_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static int RAMFUNCTION wolfBoot_copy_sector(struct wolfBoot_image *src,
{
uint32_t pos = 0;
uint32_t src_sector_offset = (sector * WOLFBOOT_SECTOR_SIZE);
uint32_t dst_sector_offset = (sector * WOLFBOOT_SECTOR_SIZE);
uint32_t dst_sector_offset = src_sector_offset;
#ifdef EXT_ENCRYPTED
uint8_t key[ENCRYPT_KEY_SIZE];
uint8_t nonce[ENCRYPT_NONCE_SIZE];
Expand Down

0 comments on commit dcb82b6

Please sign in to comment.