Skip to content

Commit d09112a

Browse files
de-nordicnvlsianpu
authored andcommitted
boot: Reduce repeating code in boot_decrypt_and_copy_image_to_sram
There was not really needed repetition of code in if-else block; common code has been moved out and the block has been reduced. Signed-off-by: Dominik Ermel <[email protected]>
1 parent 7f9ac97 commit d09112a

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

boot/bootutil/src/loader.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2769,21 +2769,15 @@ boot_decrypt_and_copy_image_to_sram(struct boot_loader_state *state,
27692769
cur_dst = ram_dst + bytes_copied;
27702770
blk_sz = chunk_sz;
27712771
idx = 0;
2772+
blk_off = ((bytes_copied) - hdr->ih_hdr_size) & 0xf;
27722773
if (bytes_copied + chunk_sz > tlv_off) {
27732774
/* Going over TLV section
27742775
* Part of the chunk is encrypted payload */
2775-
blk_off = ((bytes_copied) - hdr->ih_hdr_size) & 0xf;
27762776
blk_sz = tlv_off - (bytes_copied);
2777-
boot_encrypt(BOOT_CURR_ENC(state), image_index, area_id,
2778-
(bytes_copied + idx) - hdr->ih_hdr_size, blk_sz,
2779-
blk_off, cur_dst);
2780-
} else {
2781-
/* Image encrypted payload section */
2782-
blk_off = ((bytes_copied) - hdr->ih_hdr_size) & 0xf;
2783-
boot_encrypt(BOOT_CURR_ENC(state), image_index, area_id,
2784-
(bytes_copied + idx) - hdr->ih_hdr_size, blk_sz,
2785-
blk_off, cur_dst);
27862777
}
2778+
boot_encrypt(BOOT_CURR_ENC(state), image_index, area_id,
2779+
(bytes_copied + idx) - hdr->ih_hdr_size, blk_sz,
2780+
blk_off, cur_dst);
27872781

27882782
bytes_copied += chunk_sz;
27892783
}

0 commit comments

Comments
 (0)