Skip to content
Permalink
Browse files

subsys/settings: Add const modifier to the value pointer

This commit adds const modifier for value pointer in
settings_save_one function.

Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
  • Loading branch information...
rakons authored and nashif committed May 29, 2019
1 parent f8f6e7e commit 974231ee6e29223c5498f1281523aabf8fb62a33
@@ -74,7 +74,7 @@ struct settings_handler {
* User might use it to apply setting to the application.
*/

int (*h_export)(int (*export_func)(const char *name, void *val,
int (*h_export)(int (*export_func)(const char *name, const void *val,
size_t val_len));
/**< This gets called to dump all current settings items.
*
@@ -139,7 +139,7 @@ int settings_save(void);
*
* @return 0 on success, non-zero on failure.
*/
int settings_save_one(const char *name, void *value, size_t val_len);
int settings_save_one(const char *name, const void *value, size_t val_len);

/**
* Delete a single serialized in persisted storage.
@@ -240,7 +240,7 @@ static int commit(void)
return 0;
}

static int export(int (*export_func)(const char *name, void *val,
static int export(int (*export_func)(const char *name, const void *val,
size_t val_len))

{
@@ -9,8 +9,8 @@ struct bt_settings_handler {
int (*set)(int argc, char **argv, size_t len, settings_read_cb read_cb,
void *cb_arg);
int (*commit)(void);
int (*export)(int (*func)(const char *name, void *val,
size_t val_len));
int (*export)(int (*func)(const char *name,
const void *val, size_t val_len));
};

#define BT_SETTINGS_DEFINE(_name, _set, _commit, _export) \
@@ -60,7 +60,7 @@ int settings_load(void)
/*
* Append a single value to persisted config. Don't store duplicate value.
*/
int settings_save_one(const char *name, void *value, size_t val_len)
int settings_save_one(const char *name, const void *value, size_t val_len)
{
struct settings_store *cs;

@@ -28,7 +28,7 @@ struct deletable_s {

u32_t val4v2;

int c4_handle_export(int (*cb)(const char *name, void *value, size_t val_len));
int c4_handle_export(int (*cb)(const char *name, const void *value, size_t val_len));

struct settings_handler c4_test_handler = {
.name = "4",
@@ -38,7 +38,7 @@ struct settings_handler c4_test_handler = {
.h_export = c4_handle_export
};

int c4_handle_export(int (*cb)(const char *name, void *value, size_t val_len))
int c4_handle_export(int (*cb)(const char *name, const void *value, size_t val_len))
{
if (deletable_val.valid) {
(void)cb(NAME_DELETABLE, &deletable_val.val32,
@@ -27,17 +27,20 @@ int c1_handle_get(int argc, char **argv, char *val, int val_len_max);
int c1_handle_set(int argc, char **argv, size_t len, settings_read_cb read_cb,
void *cb_arg);
int c1_handle_commit(void);
int c1_handle_export(int (*cb)(const char *name, void *value, size_t val_len));
int c1_handle_export(int (*cb)(const char *name,
const void *value, size_t val_len));

int c2_handle_get(int argc, char **argv, char *val, int val_len_max);
int c2_handle_set(int argc, char **argv, size_t len, settings_read_cb read_cb,
void *cb_arg);
int c2_handle_export(int (*cb)(const char *name, void *value, size_t val_len));
int c2_handle_export(int (*cb)(const char *name,
const void *value, size_t val_len));

int c3_handle_get(int argc, char **argv, char *val, int val_len_max);
int c3_handle_set(int argc, char **argv, size_t len, settings_read_cb read_cb,
void *cb_arg);
int c3_handle_export(int (*cb)(const char *name, void *value, size_t val_len));
int c3_handle_export(int (*cb)(const char *name,
const void *value, size_t val_len));

struct settings_handler c_test_handlers[] = {
{
@@ -122,7 +125,8 @@ int c1_handle_commit(void)
return 0;
}

int c1_handle_export(int (*cb)(const char *name, void *value, size_t val_len))
int c1_handle_export(int (*cb)(const char *name,
const void *value, size_t val_len))
{
if (test_export_block) {
return 0;
@@ -269,7 +273,8 @@ int c2_handle_set(int argc, char **argv, size_t len, settings_read_cb read_cb,
return -ENOENT;
}

int c2_handle_export(int (*cb)(const char *name, void *value, size_t val_len))
int c2_handle_export(int (*cb)(const char *name,
const void *value, size_t val_len))
{
int i;
char name[32];
@@ -310,7 +315,8 @@ int c3_handle_set(int argc, char **argv, size_t len, settings_read_cb read_cb,
return -ENOENT;
}

int c3_handle_export(int (*cb)(const char *name, void *value, size_t val_len))
int c3_handle_export(int (*cb)(const char *name,
const void *value, size_t val_len))
{
(void)cb("3/v", &val32, sizeof(val32));

@@ -29,8 +29,8 @@ static int c1_set(int argc, char **argv, size_t len, settings_read_cb read_cb,
return -ENOENT;
}

static int c1_export(int (*export_func)(const char *name, void *value,
size_t val_len))
static int c1_export(int (*export_func)(const char *name,
const void *value, size_t val_len))
{
(void)export_func("hello/val32", &val32, sizeof(val32));

@@ -26,7 +26,8 @@ int c1_handle_get(int argc, char **argv, char *val, int val_len_max);
int c1_handle_set(int argc, char **argv, size_t len, settings_read_cb read_cb,
void *cb_arg);
int c1_handle_commit(void);
int c1_handle_export(int (*cb)(const char *name, void *value, size_t val_len));
int c1_handle_export(int (*cb)(const char *name,
const void *value, size_t val_len));

struct settings_handler c_test_handlers[] = {
{
@@ -108,7 +109,8 @@ int c1_handle_commit(void)
return 0;
}

int c1_handle_export(int (*cb)(const char *name, void *value, size_t val_len))
int c1_handle_export(int (*cb)(const char *name,
const void *value, size_t val_len))
{
if (test_export_block) {
return 0;

0 comments on commit 974231e

Please sign in to comment.
You can’t perform that action at this time.