From d8c651c0911edb7bbbe602251338dc3d5b6c5747 Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Tue, 16 Apr 2024 18:50:14 +0200 Subject: [PATCH 1/2] Added explicit cast to silence warning Explicit cast to silence warning about negative array index --- src/libwolfboot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libwolfboot.c b/src/libwolfboot.c index 3dc961bfc..aebf193c5 100644 --- a/src/libwolfboot.c +++ b/src/libwolfboot.c @@ -240,8 +240,8 @@ static int RAMFUNCTION nvm_select_fresh_sector(int part) #endif /* check magic in case the sector is corrupt */ - word_0 = *((uint32_t*)(base - sizeof(uint32_t))); - word_1 = *((uint32_t*)(base - WOLFBOOT_SECTOR_SIZE - sizeof(uint32_t))); + word_0 = *((uint32_t*)((uint32_t)base - sizeof(uint32_t))); + word_1 = *((uint32_t*)((uint32_t)base - WOLFBOOT_SECTOR_SIZE - sizeof(uint32_t))); if (word_0 == WOLFBOOT_MAGIC_TRAIL && word_1 != WOLFBOOT_MAGIC_TRAIL) { sel = 0; From 32b5b9e4ec4815a4532a88e78cbc7541097219ee Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Tue, 16 Apr 2024 19:10:26 +0200 Subject: [PATCH 2/2] Replaced uint32_t with uintptr_t --- src/libwolfboot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libwolfboot.c b/src/libwolfboot.c index aebf193c5..4ec32efa2 100644 --- a/src/libwolfboot.c +++ b/src/libwolfboot.c @@ -240,8 +240,8 @@ static int RAMFUNCTION nvm_select_fresh_sector(int part) #endif /* check magic in case the sector is corrupt */ - word_0 = *((uint32_t*)((uint32_t)base - sizeof(uint32_t))); - word_1 = *((uint32_t*)((uint32_t)base - WOLFBOOT_SECTOR_SIZE - sizeof(uint32_t))); + word_0 = *((uint32_t*)((uintptr_t)base - sizeof(uint32_t))); + word_1 = *((uint32_t*)((uintptr_t)base - WOLFBOOT_SECTOR_SIZE - sizeof(uint32_t))); if (word_0 == WOLFBOOT_MAGIC_TRAIL && word_1 != WOLFBOOT_MAGIC_TRAIL) { sel = 0;