settings: add const qualifier for unmodified data source
Code using this API to set a key to a value that is a string literal produces errors in C++ because the passed pointer is not const qualified, allowing the possibility that the callee modifies the referenced string literal memory. Add the required const qualifiers since the set function does not change the passed to it. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
parent
94b744cc0a
commit
e052c7991c
2 changed files with 3 additions and 3 deletions
|
@ -567,7 +567,7 @@ int settings_name_next(const char *name, const char **next);
|
|||
*
|
||||
* @return 0 on success, non-zero on failure.
|
||||
*/
|
||||
int settings_runtime_set(const char *name, void *data, size_t len);
|
||||
int settings_runtime_set(const char *name, const void *data, size_t len);
|
||||
|
||||
/**
|
||||
* Get a value corresponding to a key from a module handler.
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "settings_priv.h"
|
||||
|
||||
struct read_cb_arg {
|
||||
void *data;
|
||||
const void *data;
|
||||
size_t len;
|
||||
};
|
||||
|
||||
|
@ -23,7 +23,7 @@ static ssize_t settings_runtime_read_cb(void *cb_arg, void *data, size_t len)
|
|||
return MIN(arg->len, len);
|
||||
}
|
||||
|
||||
int settings_runtime_set(const char *name, void *data, size_t len)
|
||||
int settings_runtime_set(const char *name, const void *data, size_t len)
|
||||
{
|
||||
struct settings_handler_static *ch;
|
||||
const char *name_key;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue