From c007e717d4bda353a8147c90fbe21456aa44b4c8 Mon Sep 17 00:00:00 2001 From: Dominik Ermel Date: Tue, 23 Apr 2024 16:21:08 +0000 Subject: [PATCH] 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(). Signed-off-by: Dominik Ermel --- subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c b/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c index 29e222d1de..9fc02f8166 100644 --- a/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c +++ b/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c @@ -469,9 +469,9 @@ os_mgmt_bootloader_info(struct smp_streamer *ctxt) ok = zcbor_tstr_put_lit(zse, "mode") && zcbor_int32_put(zse, BOOTLOADER_MODE); -#if IS_ENABLED(CONFIG_MCUBOOT_BOOTLOADER_NO_DOWNGRADE) - ok = zcbor_tstr_put_lit(zse, "no-downgrade") && - zcbor_bool_encode(zse, true); +#ifdef CONFIG_MCUBOOT_BOOTLOADER_NO_DOWNGRADE + ok = ok && zcbor_tstr_put_lit(zse, "no-downgrade") && + zcbor_bool_encode(zse, &(bool){true}); #endif } else { return OS_MGMT_ERR_QUERY_YIELDS_NO_ANSWER;