diff --git a/Makefile b/Makefile index c64baf924..be76916ea 100644 --- a/Makefile +++ b/Makefile @@ -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)] $@" diff --git a/hal/spi/spi_drv_stm32.c b/hal/spi/spi_drv_stm32.c index 8e12b3101..b6d0c209b 100644 --- a/hal/spi/spi_drv_stm32.c +++ b/hal/spi/spi_drv_stm32.c @@ -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)); } diff --git a/hal/x86_64_efi.c b/hal/x86_64_efi.c index c94065aa3..48835d7f2 100644 --- a/hal/x86_64_efi.c +++ b/hal/x86_64_efi.c @@ -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); diff --git a/src/update_flash.c b/src/update_flash.c index 917ddc132..5d045ad2a 100644 --- a/src/update_flash.c +++ b/src/update_flash.c @@ -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];