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:
Lennart Poettering
2014-11-28 03:16:56 +01:00
parent 387eba0084
commit 6357ac664c
+6
View File
@@ -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);