Skip to content

Commit dcc66e5

Browse files
tomchyde-nordic
authored andcommitted
loader: Unify header_valid(..) API
Rename boot_is_header_valid(..) to boot_check_header_valid(..). The fap and hdr arguments are misleading - they should always point to the same slot. Change the function signature to use slot number instead. Signed-off-by: Tomasz Chyrowicz <tomasz.chyrowicz@nordicsemi.no>
1 parent 257265c commit dcc66e5

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

boot/bootutil/src/loader.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -698,13 +698,16 @@ split_image_check(struct image_header *app_hdr,
698698
* are present but these features are not enabled.
699699
*/
700700
static bool
701-
boot_is_header_valid(const struct image_header *hdr, const struct flash_area *fap,
702-
struct boot_loader_state *state)
701+
boot_check_header_valid(struct boot_loader_state *state, int slot)
703702
{
703+
const struct flash_area *fap = NULL;
704+
struct image_header *hdr;
704705
uint32_t size;
705706

706-
(void)state;
707+
fap = BOOT_IMG_AREA(state, slot);
708+
assert(fap != NULL);
707709

710+
hdr = boot_img_hdr(state, slot);
708711
if (hdr->ih_magic != IMAGE_MAGIC) {
709712
return false;
710713
}
@@ -910,7 +913,7 @@ boot_validate_slot(struct boot_loader_state *state, int slot,
910913
}
911914
}
912915
#endif
913-
if (!boot_is_header_valid(hdr, fap, state)) {
916+
if (!boot_check_header_valid(state, slot)) {
914917
fih_rc = FIH_FAILURE;
915918
} else {
916919
BOOT_HOOK_CALL_FIH(boot_image_check_hook, FIH_BOOT_HOOK_REGULAR,
@@ -2525,7 +2528,7 @@ boot_get_slot_usage(struct boot_loader_state *state)
25252528
for (slot = 0; slot < BOOT_NUM_SLOTS; slot++) {
25262529
hdr = boot_img_hdr(state, slot);
25272530

2528-
if (boot_is_header_valid(hdr, BOOT_IMG_AREA(state, slot), state)) {
2531+
if (boot_check_header_valid(state, slot)) {
25292532
state->slot_usage[BOOT_CURR_IMG(state)].slot_available[slot] = true;
25302533
BOOT_LOG_IMAGE_INFO(slot, hdr);
25312534
} else {

0 commit comments

Comments
 (0)