Skip to content

Commit dcb82b6

Browse files
committed
cppcheck: added "--enable=warning"
1 parent 5f5b4a5 commit dcb82b6

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ line-count-x86:
329329
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
330330

331331
cppcheck:
332-
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
332+
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
333333

334334
%.o:%.c
335335
@echo "\t[CC-$(ARCH)] $@"

hal/spi/spi_drv_stm32.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,32 +84,32 @@ void RAMFUNCTION stm_gpio_config(uint32_t base, uint32_t pin, uint32_t mode,
8484
RCC_GPIO_CLOCK_ER |= (1 << base_num);
8585

8686
/* Set Mode and Alternate Function */
87-
reg = GPIO_MODE(base) & ~(0x03 << (pin * 2));
87+
reg = GPIO_MODE(base) & ~(0x03UL << (pin * 2));
8888
GPIO_MODE(base) = reg | (mode << (pin * 2));
8989
if (mode < 2) {
9090
if (pin < 8)
91-
GPIO_AFL(base) &= ~(0xf << (pin * 4));
91+
GPIO_AFL(base) &= ~(0xfUL << (pin * 4));
9292
else
93-
GPIO_AFH(base) &= ~(0xf << ((pin - 8) * 4));
93+
GPIO_AFH(base) &= ~(0xfUL << ((pin - 8) * 4));
9494
}
9595
else if (mode == 2) {
9696
/* alternate mode */
9797
if (pin < 8) {
98-
reg = GPIO_AFL(base) & ~(0xf << (pin * 4));
98+
reg = GPIO_AFL(base) & ~(0xfUL << (pin * 4));
9999
GPIO_AFL(base) = reg | (af << (pin * 4));
100100
}
101101
else {
102-
reg = GPIO_AFH(base) & ~(0xf << ((pin - 8) * 4));
102+
reg = GPIO_AFH(base) & ~(0xfUL << ((pin - 8) * 4));
103103
GPIO_AFH(base) = reg | (af << ((pin - 8) * 4));
104104
}
105105
}
106106

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

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

hal/x86_64_efi.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,10 @@ static UINT64 FileSize(EFI_FILE_HANDLE FileHandle)
147147
UINT64 ret;
148148

149149
FileInfo = LibFileInfo(FileHandle);
150-
if (FileInfo == NULL)
150+
if (FileInfo == NULL) {
151151
panic();
152+
return 0; /* Never reached, for static analyzer */
153+
}
152154

153155
ret = FileInfo->FileSize;
154156
FreePool(FileInfo);

src/update_flash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static int RAMFUNCTION wolfBoot_copy_sector(struct wolfBoot_image *src,
128128
{
129129
uint32_t pos = 0;
130130
uint32_t src_sector_offset = (sector * WOLFBOOT_SECTOR_SIZE);
131-
uint32_t dst_sector_offset = (sector * WOLFBOOT_SECTOR_SIZE);
131+
uint32_t dst_sector_offset = src_sector_offset;
132132
#ifdef EXT_ENCRYPTED
133133
uint8_t key[ENCRYPT_KEY_SIZE];
134134
uint8_t nonce[ENCRYPT_NONCE_SIZE];

0 commit comments

Comments
 (0)