summaryrefslogtreecommitdiff
path: root/src/basic/log.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-04-27 18:00:58 +0200
committerSven Eden <yamakuzure@gmx.net>2018-08-24 16:47:08 +0200
commitcbb9e59083da8cedd08a059008f8ef2b1bac25a2 (patch)
tree0246f6f369a23e39d90ac048281ae279d9d23c71 /src/basic/log.c
parent4d4159f9c39d318d86e630b8c5cb93e73543da82 (diff)
basic/log: always ignore errno from the enviornment (#8841)
This extends the change done in b29f6480ec to other logging functions. This actually fixes some bugs in callers of log_struct(), for example config_parse_alias() called 'return log_syntax(..., 0, ...)' which could result in a bogus non-zero return value. Calls to log_object() and log_format_iovec() — which is only used by server_driver_message() — appear correct.
Diffstat (limited to 'src/basic/log.c')
-rw-r--r--src/basic/log.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/basic/log.c b/src/basic/log.c
index 6d5616730..ed02a4b90 100644
--- a/src/basic/log.c
+++ b/src/basic/log.c
@@ -751,9 +751,8 @@ static int log_object_internalv(
if (_likely_(LOG_PRI(level) > log_max_level[LOG_REALM_SYSTEMD]))
return -error;
- /* Make sure that %m maps to the specified error */
- if (error != 0)
- errno = error;
+ /* Make sure that %m maps to the specified error (or "Success"). */
+ errno = error;
/* Prepend the object name before the message */
if (object) {
@@ -876,8 +875,7 @@ int log_format_iovec(
* since vasprintf() leaves it afterwards at
* an undefined location */
- if (error != 0)
- errno = error;
+ errno = error;
va_copy(aq, ap);
r = vasprintf(&m, format, aq);
@@ -980,8 +978,7 @@ int log_struct_internal(
while (format) {
va_list aq;
- if (error != 0)
- errno = error;
+ errno = error;
va_copy(aq, ap);
(void) vsnprintf(buf, sizeof buf, format, aq);
@@ -1283,8 +1280,7 @@ int log_syntax_internal(
if (log_target == LOG_TARGET_NULL)
return -error;
- if (error != 0)
- errno = error;
+ errno = error;
va_start(ap, format);
(void) vsnprintf(buffer, sizeof buffer, format, ap);