mgmt/mcumgr: Fix image erase returning MGMT_ERR_EMSGSIZE

In case when CONFIG_MCUMGR_SMP_LEGACY_RC_BEHAVIOUR=n then
the image erase command would incorrectly return MGMT_ERR_EMSGSIZE,
even though no such error occurred.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
Dominik Ermel 2023-04-25 16:34:48 +00:00 committed by Carles Cufí
parent af2576a127
commit 00f1639e38

View file

@ -243,7 +243,6 @@ img_mgmt_erase(struct smp_streamer *ctxt)
struct image_version ver;
int rc;
zcbor_state_t *zsd = ctxt->reader->zs;
zcbor_state_t *zse = ctxt->writer->zs;
bool ok;
uint32_t slot = 1;
size_t decoded = 0;
@ -283,12 +282,15 @@ img_mgmt_erase(struct smp_streamer *ctxt)
return rc;
}
if (IS_ENABLED(CONFIG_MCUMGR_SMP_LEGACY_RC_BEHAVIOUR) && zcbor_tstr_put_lit(zse, "rc") &&
zcbor_int32_put(zse, 0)) {
return MGMT_ERR_EOK;
if (IS_ENABLED(CONFIG_MCUMGR_SMP_LEGACY_RC_BEHAVIOUR)) {
zcbor_state_t *zse = ctxt->writer->zs;
if (!zcbor_tstr_put_lit(zse, "rc") || !zcbor_int32_put(zse, 0)) {
return MGMT_ERR_EMSGSIZE;
}
}
return MGMT_ERR_EMSGSIZE;
return MGMT_ERR_EOK;
}
static int