Skip to content

Commit 1edc8cc

Browse files
nordicjmnashif
authored andcommitted
mgmt: mcumgr: grp: img_mgmt: Fix using signed values
Fixes wrongly using signed values for slot and image number when listing images. Signed-off-by: Jamie McCrae <[email protected]>
1 parent 0773cc8 commit 1edc8cc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ img_mgmt_state_read(struct smp_streamer *ctxt)
237237
struct image_version ver;
238238
uint32_t flags;
239239
uint8_t state_flags;
240-
int i;
240+
uint32_t i;
241241
zcbor_state_t *zse = ctxt->writer->zs;
242242
bool ok;
243243
struct zcbor_string zhash = { .value = hash, .len = IMAGE_HASH_LEN };
@@ -256,9 +256,9 @@ img_mgmt_state_read(struct smp_streamer *ctxt)
256256
ok = zcbor_map_start_encode(zse, MAX_IMG_CHARACTERISTICS) &&
257257
(CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER == 1 ||
258258
(zcbor_tstr_put_lit(zse, "image") &&
259-
zcbor_int32_put(zse, i >> 1))) &&
259+
zcbor_uint32_put(zse, i >> 1))) &&
260260
zcbor_tstr_put_lit(zse, "slot") &&
261-
zcbor_int32_put(zse, i % 2) &&
261+
zcbor_uint32_put(zse, i % 2) &&
262262
zcbor_tstr_put_lit(zse, "version");
263263

264264
if (ok) {

0 commit comments

Comments
 (0)