andrzej-kaczmarek commented on a change in pull request #1339: sys/config: Add
API to use FCB as generic key-value storage
URL: https://github.com/apache/mynewt-core/pull/1339#discussion_r211529043
##########
File path: sys/config/src/config_fcb.c
##########
@@ -255,14 +262,84 @@ conf_fcb_append(struct conf_fcb *cf, char *buf, int len)
if (rc) {
return OS_EINVAL;
}
- fcb_append_finish(&cf->cf_fcb, &loc);
+ fcb_append_finish(fcb, &loc);
return OS_OK;
}
static int
conf_fcb_save(struct conf_store *cs, const char *name, const char *value)
{
struct conf_fcb *cf = (struct conf_fcb *)cs;
+
+ return conf_fcb_kv_save(&cf->cf_fcb, name, value);
+}
+
+void
+conf_fcb_compress(struct conf_fcb *cf,
+ int (*copy_or_not)(const char *name, const char *val,
+ void *cn_arg),
+ void *cn_arg)
+{
+ return conf_fcb_compress_internal(&cf->cf_fcb, copy_or_not, cn_arg);
+}
+
+static int
+conf_kv_load_cb(struct fcb_entry *loc, void *arg)
+{
+ struct conf_kv_load_cb_arg *cb_arg = arg;
+ char buf[CONF_MAX_NAME_LEN + CONF_MAX_VAL_LEN + 32];
Review comment:
Yep, seems like `2` is length of element data written to FCB here:
https://github.com/apache/mynewt-core/blob/master/fs/fcb/src/fcb_append.c#L106
However, since we read data by `data_off` and `data_len` I think there's no
need to add any magic value here and just keep buffer large enough for element
data only. I dug in code a bit and it seems this will work, but would prefer
that someone more familiar with FCB confirm...
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services