Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

settings: gracefully handle the case with empty settings #415

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions net/golioth/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ static int settings_decode(zcbor_state_t *zsd, void *value)
struct zcbor_string label;
bool ok;

if (zcbor_nil_expect(zsd, NULL)) {
/* No settings are set */
return -ENOENT;
}

ok = zcbor_map_start_decode(zsd);
if (!ok) {
LOG_WRN("Did not start CBOR list correctly");
Expand Down Expand Up @@ -273,6 +278,10 @@ static int on_setting(struct golioth_req_rsp *rsp)

err = zcbor_map_decode(zsd, map_entries, ARRAY_SIZE(map_entries));
if (err) {
if (err == -ENOENT) {
return 0;
}

LOG_ERR("Failed to parse tstr map");
return err;
}
Expand Down
Loading