apache / apache/mynewt-core

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

Open
#1,653 0 comments 0 reactions 1 assignee Claimed by @mkiiskila View on GitHub
Dominant language
C
Stars
891
Forks
381
Avg merge
2d 7h
Merged PRs (30d)
14

Description

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.