diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-01-11 13:13:02 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-01-11 14:44:31 +0100 |
commit | d04ce5a9c4a91a86786eedd947822b23b689dd67 (patch) | |
tree | 4952e61deca64ef1d000291f04e9c20dd6ef4466 /src/basic/log.c | |
parent | log: minor modernizations to log_received_signal() (diff) | |
download | systemd-d04ce5a9c4a91a86786eedd947822b23b689dd67.tar.xz systemd-d04ce5a9c4a91a86786eedd947822b23b689dd67.zip |
log: rework log_syntax_invalid_utf8() a bit
The macro used utf8.h functions without including that. Let's clean this
up, by moving that code inside of log.c.
Let's also make the call return -EINVAL in all cases. This is in line
with log_oom() which also returns a well-defined error code even though
it doesn#t take one.
Diffstat (limited to 'src/basic/log.c')
-rw-r--r-- | src/basic/log.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/basic/log.c b/src/basic/log.c index 318c55e901..9169474289 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -54,6 +54,7 @@ #include "syslog-util.h" #include "terminal-util.h" #include "time-util.h" +#include "utf8.h" #include "util.h" #define SNDBUF_SIZE (8*1024*1024) @@ -1290,6 +1291,27 @@ int log_syntax_internal( NULL); } +int log_syntax_invalid_utf8_internal( + const char *unit, + int level, + const char *config_file, + unsigned config_line, + const char *file, + int line, + const char *func, + const char *rvalue) { + + _cleanup_free_ char *p = NULL; + + if (rvalue) + p = utf8_escape_invalid(rvalue); + + log_syntax_internal(unit, level, config_file, config_line, 0, file, line, func, + "String is not UTF-8 clean, ignoring assignment: %s", strna(p)); + + return -EINVAL; +} + void log_set_upgrade_syslog_to_journal(bool b) { upgrade_syslog_to_journal = b; } |