Skip to content

Commit 4ffa24c

Browse files
committed
Update CI + fix new findings with cppcheck 2.20
1 parent 977ba18 commit 4ffa24c

7 files changed

Lines changed: 34 additions & 13 deletions

File tree

.github/workflows/test-configs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,19 +194,19 @@ jobs:
194194
config-file: ./config/examples/nrf54l15-wolfcrypt-tz.config
195195

196196
nxp_p1021_test:
197-
uses: ./.github/workflows/test-build.yml
197+
uses: ./.github/workflows/test-build-powerpc.yml
198198
with:
199199
arch: ppc
200200
config-file: ./config/examples/nxp-p1021.config
201201

202202
nxp_t1024_test:
203-
uses: ./.github/workflows/test-build.yml
203+
uses: ./.github/workflows/test-build-powerpc.yml
204204
with:
205205
arch: ppc
206206
config-file: ./config/examples/nxp-t1024.config
207207

208208
nxp_t2080_test:
209-
uses: ./.github/workflows/test-build.yml
209+
uses: ./.github/workflows/test-build-powerpc.yml
210210
with:
211211
arch: ppc
212212
config-file: ./config/examples/nxp-t2080.config

.github/workflows/test-parse-tools.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
build:
1212
runs-on: ubuntu-latest
1313
container:
14-
image: ghcr.io/wolfssl/wolfboot-ci-arm:v0.9.1
14+
image: ghcr.io/wolfssl/wolfboot-ci-powerpc:v0.9.2
1515
timeout-minutes: 15
1616

1717
steps:

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,21 @@ image-header-size: wolfboot.bin
661661

662662
cppcheck:
663663
cppcheck -f --enable=warning --enable=portability \
664+
-Iinclude -I. \
665+
-D'XALIGNED(x)=' -D'TZ_SECURE()=0' -D'__has_attribute(x)=0' \
664666
--suppress="ctunullpointer" --suppress="nullPointer" \
665667
--suppress="objectIndex" --suppress="comparePointers" \
668+
--suppress="bufferAccessOutOfBounds" \
669+
--suppress="internalAstError" \
670+
--suppress="invalidPrintfArgType_s" \
671+
--suppress="invalidPrintfArgType_sint" \
672+
--suppress="invalidPrintfArgType_uint" \
673+
--suppress="invalidTestForOverflow" \
674+
--suppress="preprocessorErrorDirective" \
675+
--suppress="shiftTooManyBitsSigned" \
676+
--suppress="syntaxError" \
677+
--suppress="uninitvar" \
678+
--suppress="zerodiv" \
666679
--check-level=exhaustive \
667680
--error-exitcode=89 --std=c89 src/*.c hal/*.c hal/spi/*.c hal/uart/*.c
668681

hal/stm32h5.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,14 @@ int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
129129
#endif
130130
while (i < len) {
131131
uint32_t cur_addr = (uint32_t)dst + i;
132-
uint32_t *dst_aligned = (uint32_t *)(cur_addr & ~0xf);
132+
uint32_t *dst_aligned = (uint32_t *)(cur_addr & 0xFFFFFFF0U);
133133
int byte_offset = cur_addr - (uint32_t)dst_aligned;
134134
int i_aligned = i - byte_offset;
135135
int j;
136136
if (byte_offset == 0 && i + 16 <= len) {
137137
/* Full aligned 128 bits */
138138
for (j = 0; j < 4; j++) {
139-
qword[j] = src[(i >> 2) + j];
139+
qword[j] = src[((unsigned int)i >> 2) + j];
140140
}
141141
} else {
142142
/* Non-aligned / non-full 128 bits */

hal/va416x0.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ static int test_ext_flash(void)
425425
{
426426
int ret;
427427
uint32_t i;
428-
uint8_t pageData[WOLFBOOT_SECTOR_SIZE];
428+
uint8_t pageData[WOLFBOOT_SECTOR_SIZE] = { 0 };
429429

430430
#ifndef READONLY
431431
/* Erase sector */

src/boot_x86_fsp.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,18 @@ static int range_overlaps(uint32_t start1, uint32_t end1, uint32_t start2,
169169
return !(end1 <= start2 || end2 <= start1);
170170
}
171171

172+
static size_t linker_range_size(const void *start, const void *end)
173+
{
174+
return (size_t)((uintptr_t)end - (uintptr_t)start);
175+
}
176+
172177
static int check_memory_ranges()
173178
{
174179
uint32_t wb_start, wb_end;
175180

176181
wb_start = (uint32_t)WOLFBOOT_LOAD_BASE - IMAGE_HEADER_SIZE;
177-
wb_end = wb_start + (_wolfboot_flash_end - _wolfboot_flash_start);
182+
wb_end = wb_start + (uint32_t)linker_range_size(_wolfboot_flash_start,
183+
_wolfboot_flash_end);
178184
if (range_overlaps(wb_start, wb_end, (uint32_t)_start_data,
179185
(uint32_t)_end_data))
180186
return -1;
@@ -210,11 +216,12 @@ static void load_wolfboot(void)
210216
}
211217

212218
wolfboot_start = (uint32_t)WOLFBOOT_LOAD_BASE - IMAGE_HEADER_SIZE;
213-
wolfboot_size = _wolfboot_flash_end - _wolfboot_flash_start;
219+
wolfboot_size = linker_range_size(_wolfboot_flash_start,
220+
_wolfboot_flash_end);
214221
x86_log_memory_load(wolfboot_start, wolfboot_start + wolfboot_size,
215222
"wolfboot");
216223
memcpy((uint8_t*)wolfboot_start,_wolfboot_flash_start, wolfboot_size);
217-
bss_size = wb_end_bss - wb_start_bss;
224+
bss_size = linker_range_size(wb_start_bss, wb_end_bss);
218225
x86_log_memory_load((uint32_t)(uintptr_t)wb_start_bss,
219226
(uint32_t)(uintptr_t)(wb_start_bss + bss_size),
220227
"wolfboot .bss");
@@ -338,7 +345,7 @@ static inline void memory_init_data_bss(void)
338345
}
339346
x86_log_memory_load((uint32_t)(uintptr_t)_start_bss,
340347
(uint32_t)(uintptr_t)_end_bss, "stage1 .bss");
341-
memset(_start_bss, 0, (_end_bss - _start_bss));
348+
memset(_start_bss, 0, linker_range_size(_start_bss, _end_bss));
342349
}
343350

344351
static int pci_get_capability(uint8_t bus, uint8_t dev, uint8_t fun,
@@ -656,7 +663,8 @@ void start(uint32_t stack_base, uint32_t stack_top, uint64_t timestamp,
656663
stage2_params->tpm_policy = (uint32_t)_start_policy;
657664

658665
stage2_params->tpm_policy_size = *_policy_size_u32;
659-
if (stage2_params->tpm_policy_size > _end_policy - _start_policy)
666+
if (stage2_params->tpm_policy_size >
667+
linker_range_size(_start_policy, _end_policy))
660668
stage2_params->tpm_policy_size = 0;
661669
wolfBoot_printf("setting policy @%x (%d bytes)\r\n",
662670
(uint32_t)(uintptr_t)stage2_params->tpm_policy,

src/update_ram.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void RAMFUNCTION wolfBoot_start(void)
167167
#endif
168168

169169
#ifdef WOLFBOOT_USE_RAMBOOT
170-
load_address = (uint32_t*)(WOLFBOOT_LOAD_ADDRESS -
170+
load_address = (uint32_t *)(uintptr_t)(WOLFBOOT_LOAD_ADDRESS -
171171
IMAGE_HEADER_SIZE);
172172
#if defined(EXT_ENCRYPTED) && defined(MMU)
173173
ret = wolfBoot_ram_decrypt((uint8_t*)source_address,

0 commit comments

Comments
 (0)