Skip to content

Commit 39ab9e4

Browse files
committed
mgmt: mcumgr: grp: settings_mgmt: Part revert settings save change
Partially reverts commit 7d2fb6c, it was originally thought that this commit added a method of saving one specific key using the value that the device already has set, but has been found to actually save the value that the user has provided, bypassing the current value that the device has, which is not compliant with the settings mgmt protocol, therefore remove this change and it will need to be reworked in future to function properly by saving one specific value from the device's current configuration, not a user-specified value Signed-off-by: Jamie McCrae <[email protected]>
1 parent ec3bcd3 commit 39ab9e4

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

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

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -437,13 +437,11 @@ static int settings_mgmt_save(struct smp_streamer *ctxt)
437437
zcbor_state_t *zse = ctxt->writer->zs;
438438
zcbor_state_t *zsd = ctxt->reader->zs;
439439
bool ok = true;
440-
struct zcbor_string data = {0};
441440
size_t decoded;
442441
struct zcbor_string key = {0};
443442
bool name_found = false;
444443
bool val_found = false;
445444
bool save_subtree = false;
446-
bool save_one = false;
447445

448446
#ifdef CONFIG_MCUMGR_GRP_SETTINGS_BUFFER_TYPE_HEAP
449447
char *key_name = NULL;
@@ -453,7 +451,6 @@ static int settings_mgmt_save(struct smp_streamer *ctxt)
453451

454452
struct zcbor_map_decode_key_val settings_save_decode[] = {
455453
ZCBOR_MAP_DECODE_KEY_DECODER("name", zcbor_tstr_decode, &key),
456-
ZCBOR_MAP_DECODE_KEY_DECODER("val", zcbor_bstr_decode, &data),
457454
};
458455

459456
ok = zcbor_map_decode_bulk(zsd, settings_save_decode, ARRAY_SIZE(settings_save_decode),
@@ -465,18 +462,14 @@ static int settings_mgmt_save(struct smp_streamer *ctxt)
465462

466463
name_found = zcbor_map_decode_bulk_key_found(settings_save_decode,
467464
ARRAY_SIZE(settings_save_decode), "name");
468-
val_found = zcbor_map_decode_bulk_key_found(settings_save_decode,
469-
ARRAY_SIZE(settings_save_decode), "val");
470465

471-
if ((name_found && key.len == 0) || (val_found && data.len == 0)) {
466+
if (name_found && key.len == 0) {
472467
return MGMT_ERR_EINVAL;
473-
} else if (name_found && val_found) {
474-
save_one = true;
475468
} else if (name_found) {
476469
save_subtree = true;
477470
}
478471

479-
if (save_one || save_subtree) {
472+
if (save_subtree) {
480473
if (key.len >= CONFIG_MCUMGR_GRP_SETTINGS_NAME_LEN) {
481474
ok = smp_add_cmd_err(zse, MGMT_GROUP_ID_SETTINGS,
482475
SETTINGS_MGMT_ERR_KEY_TOO_LONG);
@@ -524,9 +517,7 @@ static int settings_mgmt_save(struct smp_streamer *ctxt)
524517
}
525518
}
526519

527-
if (save_one) {
528-
rc = settings_save_one(key_name, data.value, data.len);
529-
} else if (save_subtree) {
520+
if (save_subtree) {
530521
rc = settings_save_subtree(key_name);
531522
} else {
532523
rc = settings_save();

0 commit comments

Comments
 (0)