Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions boot/bootutil/src/bootutil_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ boot_check_header_erased(struct boot_loader_state *state, int slot)
struct image_header *hdr;

fap = BOOT_IMG_AREA(state, slot);
assert(fap != NULL);
ASSERT(fap != NULL);

hdr = boot_img_hdr(state, slot);
if (bootutil_buffer_is_erased(fap, &hdr->ih_magic, sizeof(hdr->ih_magic))) {
Expand All @@ -74,7 +74,7 @@ boot_check_header_valid(struct boot_loader_state *state, int slot)
uint32_t size;

fap = BOOT_IMG_AREA(state, slot);
assert(fap != NULL);
ASSERT(fap != NULL);

hdr = boot_img_hdr(state, slot);
if (hdr->ih_magic != IMAGE_MAGIC) {
Expand Down Expand Up @@ -167,7 +167,7 @@ boot_check_image(struct boot_loader_state *state, struct boot_status *bs, int sl
struct image_header *hdr;

fap = BOOT_IMG_AREA(state, slot);
assert(fap != NULL);
ASSERT(fap != NULL);

hdr = boot_img_hdr(state, slot);

Expand Down Expand Up @@ -255,7 +255,7 @@ boot_update_security_counter(struct boot_loader_state *state, int slot, int hdr_
int rc;

fap = BOOT_IMG_AREA(state, slot);
assert(fap != NULL);
ASSERT(fap != NULL);

rc = bootutil_get_img_security_cnt(state, hdr_slot_idx, fap, &img_security_cnt);
if (rc != 0) {
Expand Down Expand Up @@ -328,7 +328,7 @@ boot_open_all_flash_areas(struct boot_loader_state *state)
for (slot = 0; slot < BOOT_NUM_SLOTS; slot++) {
fa_id = flash_area_id_from_multi_image_slot(image_index, slot);
rc = flash_area_open(fa_id, &BOOT_IMG_AREA(state, slot));
assert(rc == 0);
ASSERT(rc == 0);

if (rc != 0) {
BOOT_LOG_ERR("Failed to open flash area ID %d (image %d slot %zu): %d",
Expand All @@ -340,7 +340,7 @@ boot_open_all_flash_areas(struct boot_loader_state *state)

#if MCUBOOT_SWAP_USING_SCRATCH
rc = flash_area_open(FLASH_AREA_IMAGE_SCRATCH, &BOOT_SCRATCH_AREA(state));
assert(rc == 0);
ASSERT(rc == 0);

if (rc != 0) {
BOOT_LOG_ERR("Failed to open scratch flash area: %d", rc);
Expand Down
6 changes: 3 additions & 3 deletions boot/bootutil/src/bootutil_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ boot_status_off(const struct flash_area *fap)
}
#endif

assert(off_from_end <= flash_area_get_size(fap));
ASSERT(off_from_end <= flash_area_get_size(fap));
return flash_area_get_size(fap) - off_from_end;
}

Expand Down Expand Up @@ -389,10 +389,10 @@ boot_read_image_size(struct boot_loader_state *state, int slot, uint32_t *size)
uint32_t protect_tlv_size;
int rc;

assert(slot == BOOT_SLOT_PRIMARY || slot == BOOT_SLOT_SECONDARY);
ASSERT(slot == BOOT_SLOT_PRIMARY || slot == BOOT_SLOT_SECONDARY);

fap = BOOT_IMG_AREA(state, slot);
assert(fap != NULL);
ASSERT(fap != NULL);

off = BOOT_TLV_OFF(boot_img_hdr(state, slot));

Expand Down
6 changes: 3 additions & 3 deletions boot/bootutil/src/bootutil_public.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ boot_write_trailer(const struct flash_area *fap, uint32_t off,
align = ALIGN_UP(inlen, align);
if (align > BOOT_MAX_ALIGN) {
/* This should never happen */
assert(0);
ASSERT(0);
return -1;
}
erased_val = flash_area_erased_val(fap);
Expand Down Expand Up @@ -585,7 +585,7 @@ boot_set_next(const struct flash_area *fa, bool active, bool confirm)

default:
/* Something is not OK, this should never happen */
assert(0);
ASSERT(0);
rc = BOOT_EBADIMAGE;
}

Expand Down Expand Up @@ -654,7 +654,7 @@ boot_set_next(const struct flash_area *fa, bool active, bool confirm)

default:
/* Something is not OK, this should never happen */
assert(0);
ASSERT(0);
rc = BOOT_EBADSTATUS;
}

Expand Down
6 changes: 3 additions & 3 deletions boot/bootutil/src/encrypted.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ boot_decrypt_key(const uint8_t *buf, uint8_t *enckey)

#if defined(MCUBOOT_ENCRYPT_KW)

assert(*bootutil_enc_key->len == BOOT_ENC_KEY_SIZE);
ASSERT(*bootutil_enc_key->len == BOOT_ENC_KEY_SIZE);
rc = key_unwrap(buf, enckey, bootutil_enc_key);

#endif /* defined(MCUBOOT_ENCRYPT_KW) */
Expand Down Expand Up @@ -688,7 +688,7 @@ boot_enc_encrypt(struct enc_key_data *enc, uint32_t off,
nonce[14] = (uint8_t)(off >> 8);
nonce[15] = (uint8_t)off;

assert(enc->valid == 1);
ASSERT(enc->valid == 1);
bootutil_aes_ctr_encrypt(&enc->aes_ctr, nonce, buf, sz, blk_off, buf);
}

Expand All @@ -710,7 +710,7 @@ boot_enc_decrypt(struct enc_key_data *enc, uint32_t off,
nonce[14] = (uint8_t)(off >> 8);
nonce[15] = (uint8_t)off;

assert(enc->valid == 1);
ASSERT(enc->valid == 1);
bootutil_aes_ctr_decrypt(&enc->aes_ctr, nonce, buf, sz, blk_off, buf);
}

Expand Down
4 changes: 2 additions & 2 deletions boot/bootutil/src/encrypted_psa.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void bootutil_aes_ctr_init(bootutil_aes_ctr_context *ctx)

if (psa_ret != PSA_SUCCESS) {
BOOT_LOG_ERR("AES init PSA crypto init failed %d", psa_ret);
assert(0);
ASSERT(0);
}

ctx->key = PSA_KEY_ID_NULL;
Expand All @@ -228,7 +228,7 @@ void bootutil_aes_ctr_drop(bootutil_aes_ctr_context *ctx)
* either because it is invalid key number or something is really
* wrong; either way we have no way to recover.
*/
assert(0);
ASSERT(0);
}

ctx->key = PSA_KEY_ID_NULL;
Expand Down
62 changes: 31 additions & 31 deletions boot/bootutil/src/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ boot_verify_slot_dependencies(struct boot_loader_state *state, uint32_t slot)
int rc;

fap = BOOT_IMG_AREA(state, slot);
assert(fap != NULL);
ASSERT(fap != NULL);

BOOT_LOG_DBG("boot_verify_slot_dependencies");
#if defined(MCUBOOT_SWAP_USING_OFFSET)
Expand Down Expand Up @@ -553,7 +553,7 @@ boot_validate_slot(struct boot_loader_state *state, int slot,
#endif

fap = BOOT_IMG_AREA(state, slot);
assert(fap != NULL);
ASSERT(fap != NULL);

hdr = boot_img_hdr(state, slot);
if (boot_check_header_erased(state, slot) || (hdr->ih_flags & IMAGE_F_NON_BOOTABLE)) {
Expand All @@ -576,7 +576,7 @@ boot_validate_slot(struct boot_loader_state *state, int slot,
boot_swap_type_multi(BOOT_CURR_IMG(state)) == BOOT_SWAP_TYPE_REVERT) {
const struct flash_area *fap_pri = BOOT_IMG_AREA(state, BOOT_SLOT_PRIMARY);

assert(fap_pri != NULL);
ASSERT(fap_pri != NULL);

if (swap_scramble_trailer_sectors(state, fap_pri) == 0) {
BOOT_LOG_INF("Cleared image %d primary slot trailer due to stuck revert",
Expand Down Expand Up @@ -946,7 +946,7 @@ boot_copy_image(struct boot_loader_state *state, struct boot_status *bs)
#if defined(MCUBOOT_OVERWRITE_ONLY_FAST)
uint32_t src_size = 0;
rc = boot_read_image_size(state, BOOT_SLOT_SECONDARY, &src_size);
assert(rc == 0);
ASSERT(rc == 0);
#endif

image_index = BOOT_CURR_IMG(state);
Expand All @@ -955,16 +955,16 @@ boot_copy_image(struct boot_loader_state *state, struct boot_status *bs)
BOOT_LOG_INF("Erasing the primary slot");

fap_primary_slot = BOOT_IMG_AREA(state, BOOT_SLOT_PRIMARY);
assert(fap_primary_slot != NULL);
ASSERT(fap_primary_slot != NULL);

fap_secondary_slot = BOOT_IMG_AREA(state, BOOT_SLOT_SECONDARY);
assert(fap_secondary_slot != NULL);
ASSERT(fap_secondary_slot != NULL);

sect_count = boot_img_num_sectors(state, BOOT_SLOT_PRIMARY);
for (sect = 0, size = 0; sect < sect_count; sect++) {
this_size = boot_img_sector_size(state, BOOT_SLOT_PRIMARY, sect);
rc = boot_erase_region(fap_primary_slot, size, this_size, false);
assert(rc == 0);
ASSERT(rc == 0);

#if defined(MCUBOOT_OVERWRITE_ONLY_FAST)
if ((size + this_size) >= src_size) {
Expand Down Expand Up @@ -1009,7 +1009,7 @@ boot_copy_image(struct boot_loader_state *state, struct boot_status *bs)
} while (sz < trailer_sz);

rc = boot_erase_region(fap_primary_slot, off, sz, false);
assert(rc == 0);
ASSERT(rc == 0);
#endif

#ifdef MCUBOOT_ENC_IMAGES
Expand Down Expand Up @@ -1075,7 +1075,7 @@ boot_copy_image(struct boot_loader_state *state, struct boot_status *bs)
rc = boot_scramble_region(fap_secondary_slot,
boot_img_sector_off(state, BOOT_SLOT_SECONDARY, 0),
boot_img_sector_size(state, BOOT_SLOT_SECONDARY, 0), false);
assert(rc == 0);
ASSERT(rc == 0);
#endif

last_sector = boot_img_num_sectors(state, BOOT_SLOT_SECONDARY) - 1;
Expand All @@ -1085,7 +1085,7 @@ boot_copy_image(struct boot_loader_state *state, struct boot_status *bs)
last_sector),
boot_img_sector_size(state, BOOT_SLOT_SECONDARY,
last_sector), false);
assert(rc == 0);
ASSERT(rc == 0);

/* TODO: Perhaps verify the primary slot's signature again? */

Expand Down Expand Up @@ -1132,18 +1132,18 @@ boot_swap_image(struct boot_loader_state *state, struct boot_status *bs)
hdr = boot_img_hdr(state, BOOT_SLOT_PRIMARY);
if (hdr->ih_magic == IMAGE_MAGIC) {
rc = boot_read_image_size(state, BOOT_SLOT_PRIMARY, &copy_size);
assert(rc == 0);
ASSERT(rc == 0);
}

#ifdef MCUBOOT_ENC_IMAGES
if (IS_ENCRYPTED(hdr)) {
fap = BOOT_IMG_AREA(state, BOOT_SLOT_PRIMARY);
rc = boot_enc_load(state, BOOT_SLOT_PRIMARY, hdr, fap, bs);
assert(rc >= 0);
ASSERT(rc >= 0);

if (rc == 0) {
rc = boot_enc_set_key(BOOT_CURR_ENC_SLOT(state, BOOT_SLOT_PRIMARY), bs->enckey[BOOT_SLOT_PRIMARY]);
assert(rc == 0);
ASSERT(rc == 0);
} else {
rc = 0;
}
Expand All @@ -1155,19 +1155,19 @@ boot_swap_image(struct boot_loader_state *state, struct boot_status *bs)
hdr = boot_img_hdr(state, BOOT_SLOT_SECONDARY);
if (hdr->ih_magic == IMAGE_MAGIC) {
rc = boot_read_image_size(state, BOOT_SLOT_SECONDARY, &size);
assert(rc == 0);
ASSERT(rc == 0);
}

#ifdef MCUBOOT_ENC_IMAGES
hdr = boot_img_hdr(state, BOOT_SLOT_SECONDARY);
if (IS_ENCRYPTED(hdr)) {
fap = BOOT_IMG_AREA(state, BOOT_SLOT_SECONDARY);
rc = boot_enc_load(state, BOOT_SLOT_SECONDARY, hdr, fap, bs);
assert(rc >= 0);
ASSERT(rc >= 0);

if (rc == 0) {
rc = boot_enc_set_key(BOOT_CURR_ENC_SLOT(state, BOOT_SLOT_SECONDARY), bs->enckey[BOOT_SLOT_SECONDARY]);
assert(rc == 0);
ASSERT(rc == 0);
} else {
rc = 0;
}
Expand All @@ -1188,9 +1188,9 @@ boot_swap_image(struct boot_loader_state *state, struct boot_status *bs)
*/

fap = boot_find_status(state, image_index);
assert(fap != NULL);
ASSERT(fap != NULL);
rc = boot_read_swap_size(fap, &bs->swap_size);
assert(rc == 0);
ASSERT(rc == 0);

copy_size = bs->swap_size;

Expand Down Expand Up @@ -1259,7 +1259,7 @@ boot_perform_update(struct boot_loader_state *state, struct boot_status *bs)
#else
rc = boot_swap_image(state, bs);
#endif
assert(rc == 0);
ASSERT(rc == 0);

#ifndef MCUBOOT_OVERWRITE_ONLY
/* The following state needs image_ok be explicitly set after the
Expand Down Expand Up @@ -1322,7 +1322,7 @@ boot_complete_partial_swap(struct boot_loader_state *state,
* `swap-type` trailer field.
*/
rc = boot_swap_image(state, bs);
assert(rc == 0);
ASSERT(rc == 0);

BOOT_SWAP_TYPE(state) = bs->swap_type;

Expand All @@ -1346,7 +1346,7 @@ boot_complete_partial_swap(struct boot_loader_state *state,

if (BOOT_SWAP_TYPE(state) == BOOT_SWAP_TYPE_PANIC) {
BOOT_LOG_ERR("panic!");
assert(0);
ASSERT(0);

/* Loop forever... */
while (1) {}
Expand Down Expand Up @@ -1506,13 +1506,13 @@ boot_prepare_image_for_update(struct boot_loader_state *state,
/* Should never arrive here, overwrite-only mode has
* no swap state.
*/
assert(0);
ASSERT(0);
#else
/* Determine the type of swap operation being resumed from the
* `swap-type` trailer field.
*/
rc = boot_complete_partial_swap(state, bs);
assert(rc == 0);
ASSERT(rc == 0);
#endif
/* Attempt to read an image header from each slot. Ensure that image headers in slots
* are aligned with headers in boot_data.
Expand All @@ -1529,7 +1529,7 @@ boot_prepare_image_for_update(struct boot_loader_state *state,
* as boot status.
*/
rc = boot_read_image_headers(state, false, NULL);
assert(rc == 0);
ASSERT(rc == 0);

/* Swap has finished set to NONE */
BOOT_SWAP_TYPE(state) = BOOT_SWAP_TYPE_NONE;
Expand Down Expand Up @@ -1838,7 +1838,7 @@ context_boot_go(struct boot_loader_state *state, struct boot_rsp *rsp)
{
rc = boot_perform_update(state, &bs);
}
assert(rc == 0);
ASSERT(rc == 0);
break;

case BOOT_SWAP_TYPE_FAIL:
Expand All @@ -1861,7 +1861,7 @@ context_boot_go(struct boot_loader_state *state, struct boot_rsp *rsp)

if (BOOT_SWAP_TYPE(state) == BOOT_SWAP_TYPE_PANIC) {
BOOT_LOG_ERR("panic!");
assert(0);
ASSERT(0);

/* Loop forever... */
FIH_PANIC;
Expand Down Expand Up @@ -1991,11 +1991,11 @@ split_go(int loader_slot, int split_slot, void **entry)
loader_flash_id = flash_area_id_from_image_slot(loader_slot);
rc = flash_area_open(loader_flash_id,
&BOOT_IMG_AREA(&boot_data, loader_slot));
assert(rc == 0);
ASSERT(rc == 0);
split_flash_id = flash_area_id_from_image_slot(split_slot);
rc = flash_area_open(split_flash_id,
&BOOT_IMG_AREA(&boot_data, split_slot));
assert(rc == 0);
ASSERT(rc == 0);

/* Determine the sector layout of the image slots and scratch area. */
rc = boot_read_sectors(&boot_data, sectors);
Expand Down Expand Up @@ -2174,13 +2174,13 @@ boot_select_or_erase(struct boot_loader_state *state)
active_slot = state->slot_usage[BOOT_CURR_IMG(state)].active_slot;

fap = BOOT_IMG_AREA(state, active_slot);
assert(fap != NULL);
ASSERT(fap != NULL);

active_swap_state = &(state->slot_usage[BOOT_CURR_IMG(state)].swap_state);

memset(active_swap_state, 0, sizeof(struct boot_swap_state));
rc = boot_read_swap_state(fap, active_swap_state);
assert(rc == 0);
ASSERT(rc == 0);

if (active_swap_state->magic != BOOT_MAGIC_GOOD ||
(active_swap_state->copy_done == BOOT_FLAG_SET &&
Expand All @@ -2193,7 +2193,7 @@ boot_select_or_erase(struct boot_loader_state *state)
BOOT_LOG_DBG("Erasing faulty image in the %s slot.",
(active_slot == BOOT_SLOT_PRIMARY) ? "primary" : "secondary");
rc = boot_scramble_region(fap, 0, flash_area_get_size(fap), false);
assert(rc == 0);
ASSERT(rc == 0);
rc = -1;
} else {
if (active_swap_state->copy_done != BOOT_FLAG_SET) {
Expand Down
Loading
Loading