summaryrefslogtreecommitdiff
path: root/src/shared/log.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-28 02:12:30 +0100
committerLennart Poettering <lennart@poettering.net>2014-11-28 02:18:46 +0100
commit8f16f51d9323e87cc78d28e9656984c028071f94 (patch)
tree0354a56d378fc37f7dd5c0b17d3d138bbb3e99c5 /src/shared/log.c
parente2cc6eca73cd1df8be552d7c23f9ff3d69c06f1e (diff)
log: allow negative errno values
sd_bus_error_set_errno() allows negative errors too, hence, be equally nice.
Diffstat (limited to 'src/shared/log.c')
-rw-r--r--src/shared/log.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/shared/log.c b/src/shared/log.c
index dcbcd9d9c9..56469b32b5 100644
--- a/src/shared/log.c
+++ b/src/shared/log.c
@@ -545,6 +545,9 @@ static int log_dispatch(
if ((level & LOG_FACMASK) == 0)
level = log_facility | LOG_PRI(level);
+ if (error < 0)
+ error = -error;
+
do {
char *e;
int k = 0;
@@ -644,7 +647,7 @@ int log_internalv(
/* Make sure that %m maps to the specified error */
if (error != 0)
- errno = error;
+ errno = abs(error);
vsnprintf(buffer, sizeof(buffer), format, ap);
char_array_0(buffer);
@@ -689,7 +692,7 @@ int log_object_internalv(
/* Make sure that %m maps to the specified error */
if (error != 0)
- errno = error;
+ errno = abs(error);
vsnprintf(buffer, sizeof(buffer), format, ap);
char_array_0(buffer);
@@ -781,6 +784,9 @@ int log_struct_internal(
if ((level & LOG_FACMASK) == 0)
level = log_facility | LOG_PRI(level);
+ if (error < 0)
+ error = -error;
+
if ((log_target == LOG_TARGET_AUTO ||
log_target == LOG_TARGET_JOURNAL_OR_KMSG ||
log_target == LOG_TARGET_JOURNAL) &&