Skip to content

Commit cc7b97b

Browse files
committed
boot: boot_serial: Fix wrong usage of slot numbers
Fixes an issue with 2 uses of slot numbers wrongly using the number of updateable images, for listing and slot info commands Signed-off-by: Jamie McCrae <[email protected]>
1 parent 30109df commit cc7b97b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

boot/boot_serial/src/boot_serial.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ bs_list(char *buf, int len)
275275
int swap_status = boot_swap_type_multi(image_index);
276276
#endif
277277

278-
for (slot = 0; slot < MCUBOOT_IMAGE_NUMBER; slot++) {
278+
for (slot = 0; slot < BOOT_NUM_SLOTS; slot++) {
279279
FIH_DECLARE(fih_rc, FIH_FAILURE);
280280
uint8_t tmpbuf[64];
281281

@@ -610,13 +610,13 @@ bs_slot_info(uint8_t op, char *buf, int len)
610610
zcbor_list_start_encode(cbor_state, MCUBOOT_IMAGE_NUMBER);
611611

612612
IMAGES_ITER(image_index) {
613-
for (slot = 0; slot < MCUBOOT_IMAGE_NUMBER; slot++) {
613+
for (slot = 0; slot < BOOT_NUM_SLOTS; slot++) {
614614
if (slot == 0) {
615615
ok = zcbor_map_start_encode(cbor_state, CBOR_ENTRIES_SLOT_INFO_IMAGE_MAP) &&
616616
zcbor_tstr_put_lit(cbor_state, "image") &&
617617
zcbor_uint32_put(cbor_state, (uint32_t)image_index) &&
618618
zcbor_tstr_put_lit(cbor_state, "slots") &&
619-
zcbor_list_start_encode(cbor_state, MCUBOOT_IMAGE_NUMBER);
619+
zcbor_list_start_encode(cbor_state, BOOT_NUM_SLOTS);
620620

621621
if (!ok) {
622622
goto finish;
@@ -680,8 +680,8 @@ bs_slot_info(uint8_t op, char *buf, int len)
680680
goto finish;
681681
}
682682

683-
if (slot == (MCUBOOT_IMAGE_NUMBER - 1)) {
684-
ok = zcbor_list_end_encode(cbor_state, MCUBOOT_IMAGE_NUMBER);
683+
if (slot == (BOOT_NUM_SLOTS - 1)) {
684+
ok = zcbor_list_end_encode(cbor_state, BOOT_NUM_SLOTS);
685685

686686
if (!ok) {
687687
goto finish;

0 commit comments

Comments
 (0)