chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
387eba0
)
log: also set errno to the passed error code before processing format string in log_s...
author
Lennart Poettering
<lennart@poettering.net>
Fri, 28 Nov 2014 01:30:49 +0000
(
02:30
+0100)
committer
Lennart Poettering
<lennart@poettering.net>
Fri, 28 Nov 2014 02:16:56 +0000
(
03:16
+0100)
That way the caller may use %m to print the specified error.
src/shared/log.c
patch
|
blob
|
history
diff --git
a/src/shared/log.c
b/src/shared/log.c
index 56469b32b5d44dfe69e822921130cbe2c8c7163b..eba5853ab0a53ed9ad587b2a5f7c2339472b8eb1 100644
(file)
--- 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);