Skip to content

Commit 99187c8

Browse files
de-nordicgmarull
authored andcommitted
[nrf fromtree] mcumgr/img_mgmt: Fix zcbor logic in os_mgmt_bootloader_info
There have been to problems with the code where zcbor_bool_encode has been fed value instead of expected pointer and the result of previous zcbor_encode operations has not been taken to evaluate value of ok status. The change also replaces usage of #if IS_ENABLED with #ifdef, as IS_ENABLED should not be used outside if(). (cherry picked from commit c007e71) Signed-off-by: Dominik Ermel <[email protected]>
1 parent 8b560b3 commit 99187c8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,9 @@ os_mgmt_bootloader_info(struct smp_streamer *ctxt)
469469

470470
ok = zcbor_tstr_put_lit(zse, "mode") &&
471471
zcbor_int32_put(zse, BOOTLOADER_MODE);
472-
#if IS_ENABLED(CONFIG_MCUBOOT_BOOTLOADER_NO_DOWNGRADE)
473-
ok = zcbor_tstr_put_lit(zse, "no-downgrade") &&
474-
zcbor_bool_encode(zse, true);
472+
#ifdef CONFIG_MCUBOOT_BOOTLOADER_NO_DOWNGRADE
473+
ok = ok && zcbor_tstr_put_lit(zse, "no-downgrade") &&
474+
zcbor_bool_encode(zse, &(bool){true});
475475
#endif
476476
} else {
477477
return OS_MGMT_ERR_QUERY_YIELDS_NO_ANSWER;

0 commit comments

Comments
 (0)