Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys/config: Add option to skip dup check when saving values #3324

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions sys/config/src/config_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ conf_get_stored_value(char *name, char *buf, int buf_len)
return 0;
}

#if !MYNEWT_VAL(CONFIG_NO_DUP_CHECK)
static void
conf_dup_check_cb(char *name, char *val, void *cb_arg)
{
Expand All @@ -208,6 +209,7 @@ conf_dup_check_cb(char *name, char *val, void *cb_arg)
}
}
}
#endif

/*
* Append a single value to persisted config. Don't store duplicate value.
Expand All @@ -216,7 +218,9 @@ int
conf_save_one(const char *name, char *value)
{
struct conf_store *cs;
#if !MYNEWT_VAL(CONFIG_NO_DUP_CHECK)
struct conf_dup_check_arg cdca;
#endif
int rc;

conf_lock();
Expand All @@ -225,6 +229,7 @@ conf_save_one(const char *name, char *value)
goto out;
}

#if !MYNEWT_VAL(CONFIG_NO_DUP_CHECK)
/*
* Check if we're writing the same value again.
*/
Expand All @@ -238,6 +243,7 @@ conf_save_one(const char *name, char *value)
rc = 0;
goto out;
}
#endif
cs = conf_save_dst;
rc = cs->cs_itf->csi_save(cs, name, value);
out:
Expand Down Expand Up @@ -309,6 +315,7 @@ conf_save(void)
}
out:
conf_unlock();

return rc;
}

Expand Down
7 changes: 7 additions & 0 deletions sys/config/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ syscfg.defs:
For MCU without hardware support for enabling this if no other
function use floating point may increase image size 20kB or more.
value: 0
CONFIG_NO_DUP_CHECK:
description: >
This disables check for duplicate values when saving new value.
Depending on number of values stored in config this may speed up
the config save process considerably at the expense of more writes
to config storage.
value: 0

syscfg.vals.HARDFLOAT:
value: 1
Expand Down
Loading