summaryrefslogtreecommitdiff
path: root/src/shared/log.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-28 02:30:49 +0100
committerLennart Poettering <lennart@poettering.net>2014-11-28 03:16:56 +0100
commit6357ac664c9ce8ae5b83bdb98011da24185e4efa (patch)
tree1776ff41de7e8a6e09425946e0198b5fe39ec191 /src/shared/log.c
parent387eba008426fbd8d7400eef8e41fda09f7f3cb3 (diff)
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.
Diffstat (limited to 'src/shared/log.c')
-rw-r--r--src/shared/log.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/shared/log.c b/src/shared/log.c
index 56469b32b5..eba5853ab0 100644
--- a/src/shared/log.c
+++ b/src/shared/log.c
@@ -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);