You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/06/18 21:27:44 UTC
[GitHub] mkiiskila closed pull request #1203: sys/config fixes when using
multiple sources for data
mkiiskila closed pull request #1203: sys/config fixes when using multiple sources for data
URL: https://github.com/apache/mynewt-core/pull/1203
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/sys/config/src/config_cli.c b/sys/config/src/config_cli.c
index f14221866f..d24dd021a0 100644
--- a/sys/config/src/config_cli.c
+++ b/sys/config/src/config_cli.c
@@ -60,17 +60,21 @@ conf_dump_running(void)
static void
conf_saved_one(char *name, char *val, void *cb_arg)
{
- console_printf("%s = %s\n", name, val ? val : "<del>");
+ int *ip = cb_arg;
+
+ console_printf("%d - %s = %s\n", *ip, name, val ? val : "<del>");
}
static void
conf_dump_saved(void)
{
struct conf_store *cs;
+ int i = 0;
conf_lock();
SLIST_FOREACH(cs, &conf_load_srcs, cs_next) {
- cs->cs_itf->csi_load(cs, conf_saved_one, NULL);
+ cs->cs_itf->csi_load(cs, conf_saved_one, &i);
+ i++;
}
conf_unlock();
}
diff --git a/sys/config/src/config_fcb.c b/sys/config/src/config_fcb.c
index 5d8024d824..abd878c140 100644
--- a/sys/config/src/config_fcb.c
+++ b/sys/config/src/config_fcb.c
@@ -50,8 +50,11 @@ conf_fcb_src(struct conf_fcb *cf)
int rc;
cf->cf_fcb.f_version = CONF_FCB_VERS;
- cf->cf_fcb.f_scratch_cnt = 1;
-
+ if (cf->cf_fcb.f_sector_cnt > 1) {
+ cf->cf_fcb.f_scratch_cnt = 1;
+ } else {
+ cf->cf_fcb.f_scratch_cnt = 0;
+ }
while (1) {
rc = fcb_init(&cf->cf_fcb);
if (rc) {
@@ -62,7 +65,8 @@ conf_fcb_src(struct conf_fcb *cf)
* Check if system was reset in middle of emptying a sector. This
* situation is recognized by checking if the scratch block is missing.
*/
- if (fcb_free_sector_cnt(&cf->cf_fcb) < 1) {
+ if (cf->cf_fcb.f_scratch_cnt &&
+ fcb_free_sector_cnt(&cf->cf_fcb) < 1) {
flash_area_erase(cf->cf_fcb.f_active.fe_area, 0,
cf->cf_fcb.f_active.fe_area->fa_size);
} else {
@@ -230,6 +234,9 @@ conf_fcb_append(struct conf_fcb *cf, char *buf, int len)
if (rc != FCB_ERR_NOSPACE) {
break;
}
+ if (cf->cf_fcb.f_scratch_cnt == 0) {
+ return OS_ENOMEM;
+ }
conf_fcb_compress(cf);
}
if (rc) {
diff --git a/sys/config/src/config_store.c b/sys/config/src/config_store.c
index 4dfb13eae8..8372cf0fbe 100644
--- a/sys/config/src/config_store.c
+++ b/sys/config/src/config_store.c
@@ -117,8 +117,7 @@ conf_save_one(const char *name, char *value)
int rc;
conf_lock();
- cs = conf_save_dst;
- if (!cs) {
+ if (!conf_save_dst) {
rc = OS_ENOENT;
goto out;
}
@@ -129,11 +128,14 @@ conf_save_one(const char *name, char *value)
cdca.name = name;
cdca.val = value;
cdca.is_dup = 0;
- cs->cs_itf->csi_load(cs, conf_dup_check_cb, &cdca);
+ SLIST_FOREACH(cs, &conf_load_srcs, cs_next) {
+ cs->cs_itf->csi_load(cs, conf_dup_check_cb, &cdca);
+ }
if (cdca.is_dup == 1) {
rc = 0;
goto out;
}
+ cs = conf_save_dst;
rc = cs->cs_itf->csi_save(cs, name, value);
out:
conf_unlock();
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services