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.
This commit is contained in:
parent
b0a0eba9f1
commit
d1a1f0aaf0
|
@ -735,9 +735,8 @@ static int log_object_internalv(
|
||||||
if (_likely_(LOG_PRI(level) > log_max_level[LOG_REALM_SYSTEMD]))
|
if (_likely_(LOG_PRI(level) > log_max_level[LOG_REALM_SYSTEMD]))
|
||||||
return -error;
|
return -error;
|
||||||
|
|
||||||
/* Make sure that %m maps to the specified error */
|
/* Make sure that %m maps to the specified error (or "Success"). */
|
||||||
if (error != 0)
|
errno = error;
|
||||||
errno = error;
|
|
||||||
|
|
||||||
/* Prepend the object name before the message */
|
/* Prepend the object name before the message */
|
||||||
if (object) {
|
if (object) {
|
||||||
|
@ -860,8 +859,7 @@ int log_format_iovec(
|
||||||
* since vasprintf() leaves it afterwards at
|
* since vasprintf() leaves it afterwards at
|
||||||
* an undefined location */
|
* an undefined location */
|
||||||
|
|
||||||
if (error != 0)
|
errno = error;
|
||||||
errno = error;
|
|
||||||
|
|
||||||
va_copy(aq, ap);
|
va_copy(aq, ap);
|
||||||
r = vasprintf(&m, format, aq);
|
r = vasprintf(&m, format, aq);
|
||||||
|
@ -962,8 +960,7 @@ int log_struct_internal(
|
||||||
while (format) {
|
while (format) {
|
||||||
va_list aq;
|
va_list aq;
|
||||||
|
|
||||||
if (error != 0)
|
errno = error;
|
||||||
errno = error;
|
|
||||||
|
|
||||||
va_copy(aq, ap);
|
va_copy(aq, ap);
|
||||||
(void) vsnprintf(buf, sizeof buf, format, aq);
|
(void) vsnprintf(buf, sizeof buf, format, aq);
|
||||||
|
@ -1261,8 +1258,7 @@ int log_syntax_internal(
|
||||||
if (log_target == LOG_TARGET_NULL)
|
if (log_target == LOG_TARGET_NULL)
|
||||||
return -error;
|
return -error;
|
||||||
|
|
||||||
if (error != 0)
|
errno = error;
|
||||||
errno = error;
|
|
||||||
|
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
(void) vsnprintf(buffer, sizeof buffer, format, ap);
|
(void) vsnprintf(buffer, sizeof buffer, format, ap);
|
||||||
|
|
Loading…
Reference in a new issue