Use local var instead of repeated macro call
Store TLV offset in a variable to avoid repeating many calls to the
calculation macro.
Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/boot/bootutil/src/loader.c b/boot/bootutil/src/loader.c
index 43a6955..99cf186 100644
--- a/boot/bootutil/src/loader.c
+++ b/boot/bootutil/src/loader.c
@@ -1033,6 +1033,7 @@
int rc;
#ifdef MCUBOOT_ENC_IMAGES
uint32_t off;
+ uint32_t tlv_off;
size_t blk_off;
struct image_header *hdr;
uint16_t idx;
@@ -1082,12 +1083,13 @@
} else {
blk_off = ((off + bytes_copied) - hdr->ih_hdr_size) & 0xf;
}
- if (off + bytes_copied + chunk_sz > BOOT_TLV_OFF(hdr)) {
+ tlv_off = BOOT_TLV_OFF(hdr);
+ if (off + bytes_copied + chunk_sz > tlv_off) {
/* do not decrypt TLVs */
- if (off + bytes_copied >= BOOT_TLV_OFF(hdr)) {
+ if (off + bytes_copied >= tlv_off) {
blk_sz = 0;
} else {
- blk_sz = BOOT_TLV_OFF(hdr) - (off + bytes_copied);
+ blk_sz = tlv_off - (off + bytes_copied);
}
}
boot_encrypt(BOOT_CURR_ENC(state), image_index, fap_src,