mynewt-core icon indicating copy to clipboard operation
mynewt-core copied to clipboard

config functions don't work when the string is a constant

Open amrbekhit opened this issue 7 years ago • 0 comments

Some of the config module functions (e.g. conf_get_value) don't work when the string is a const. Because these functions internally use strtok_r, which modifies the original string, if the string passed into the function is a const (such as a char * string literal), the function will fail to tokenize the string properly. The workaround in the user code is to copy the config name to a temporary variable and pass that into the function.

Perhaps it might a good idea to have the config functions do this themselves internally, as it's not obvious in the documentation that this is the behaviour and it's a difficult bug to diagnose.

amrbekhit avatar Feb 20 '19 08:02 amrbekhit