mirror of
https://github.com/systemd/systemd.git
synced 2024-11-02 10:51:20 +03:00
log: also set errno to the passed error code before processing format string in log_struct()
That way the caller may use %m to print the specified error.
This commit is contained in:
parent
387eba0084
commit
6357ac664c
@ -813,6 +813,9 @@ int log_struct_internal(
|
||||
* since vasprintf() leaves it afterwards at
|
||||
* an undefined location */
|
||||
|
||||
if (error != 0)
|
||||
errno = error;
|
||||
|
||||
va_copy(aq, ap);
|
||||
if (vasprintf(&buf, format, aq) < 0) {
|
||||
va_end(aq);
|
||||
@ -856,6 +859,9 @@ int log_struct_internal(
|
||||
while (format) {
|
||||
va_list aq;
|
||||
|
||||
if (error != 0)
|
||||
errno = error;
|
||||
|
||||
va_copy(aq, ap);
|
||||
vsnprintf(buf, sizeof(buf), format, aq);
|
||||
va_end(aq);
|
||||
|
Loading…
Reference in New Issue
Block a user