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>
This commit is contained in:
parent
f8f6e7e117
commit
974231ee6e
8 changed files with 26 additions and 18 deletions
|
@ -74,7 +74,7 @@ struct settings_handler {
|
||||||
* User might use it to apply setting to the application.
|
* 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));
|
size_t val_len));
|
||||||
/**< This gets called to dump all current settings items.
|
/**< 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.
|
* @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.
|
* Delete a single serialized in persisted storage.
|
||||||
|
|
|
@ -240,7 +240,7 @@ static int commit(void)
|
||||||
return 0;
|
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))
|
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,
|
int (*set)(int argc, char **argv, size_t len, settings_read_cb read_cb,
|
||||||
void *cb_arg);
|
void *cb_arg);
|
||||||
int (*commit)(void);
|
int (*commit)(void);
|
||||||
int (*export)(int (*func)(const char *name, void *val,
|
int (*export)(int (*func)(const char *name,
|
||||||
size_t val_len));
|
const void *val, size_t val_len));
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BT_SETTINGS_DEFINE(_name, _set, _commit, _export) \
|
#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.
|
* 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;
|
struct settings_store *cs;
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ struct deletable_s {
|
||||||
|
|
||||||
u32_t val4v2;
|
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 = {
|
struct settings_handler c4_test_handler = {
|
||||||
.name = "4",
|
.name = "4",
|
||||||
|
@ -38,7 +38,7 @@ struct settings_handler c4_test_handler = {
|
||||||
.h_export = c4_handle_export
|
.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) {
|
if (deletable_val.valid) {
|
||||||
(void)cb(NAME_DELETABLE, &deletable_val.val32,
|
(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,
|
int c1_handle_set(int argc, char **argv, size_t len, settings_read_cb read_cb,
|
||||||
void *cb_arg);
|
void *cb_arg);
|
||||||
int c1_handle_commit(void);
|
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_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,
|
int c2_handle_set(int argc, char **argv, size_t len, settings_read_cb read_cb,
|
||||||
void *cb_arg);
|
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_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,
|
int c3_handle_set(int argc, char **argv, size_t len, settings_read_cb read_cb,
|
||||||
void *cb_arg);
|
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[] = {
|
struct settings_handler c_test_handlers[] = {
|
||||||
{
|
{
|
||||||
|
@ -122,7 +125,8 @@ int c1_handle_commit(void)
|
||||||
return 0;
|
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) {
|
if (test_export_block) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -269,7 +273,8 @@ int c2_handle_set(int argc, char **argv, size_t len, settings_read_cb read_cb,
|
||||||
return -ENOENT;
|
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;
|
int i;
|
||||||
char name[32];
|
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;
|
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));
|
(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;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int c1_export(int (*export_func)(const char *name, void *value,
|
static int c1_export(int (*export_func)(const char *name,
|
||||||
size_t val_len))
|
const void *value, size_t val_len))
|
||||||
{
|
{
|
||||||
(void)export_func("hello/val32", &val32, sizeof(val32));
|
(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,
|
int c1_handle_set(int argc, char **argv, size_t len, settings_read_cb read_cb,
|
||||||
void *cb_arg);
|
void *cb_arg);
|
||||||
int c1_handle_commit(void);
|
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[] = {
|
struct settings_handler c_test_handlers[] = {
|
||||||
{
|
{
|
||||||
|
@ -108,7 +109,8 @@ int c1_handle_commit(void)
|
||||||
return 0;
|
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) {
|
if (test_export_block) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue