Skip to content
Permalink
Browse files

logging: Duplicate only strings from rw memory

If argument for log_strdup is from ro memory then there is
no point to duplicate it. This may happen if function logs
variables coming from outside, e.g. function argument.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
  • Loading branch information...
nordic-krch authored and nashif committed Jun 7, 2019
1 parent 9f7c2b6 commit 960041bfa5bc42147309af0745097fdd4af11e54
Showing with 1 addition and 1 deletion.
  1. +1 −1 subsys/logging/log_core.c
@@ -753,7 +753,7 @@ char *log_strdup(const char *str)
struct log_strdup_buf *dup;
int err;

if (IS_ENABLED(CONFIG_LOG_IMMEDIATE)) {
if (IS_ENABLED(CONFIG_LOG_IMMEDIATE) || is_rodata(str)) {
return (char *)str;
}

0 comments on commit 960041b

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