summaryrefslogtreecommitdiff
path: root/src
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
parente2cc6eca73cd1df8be552d7c23f9ff3d69c06f1e (diff)
log: allow negative errno values
sd_bus_error_set_errno() allows negative errors too, hence, be equally nice.
Diffstat (limited to 'src')
-rw-r--r--src/shared/log.c10
-rw-r--r--src/shared/log.h2
2 files changed, 9 insertions, 3 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) &&
diff --git a/src/shared/log.h b/src/shared/log.h
index 3a4d1134a1..3180dfd638 100644
--- a/src/shared/log.h
+++ b/src/shared/log.h
@@ -202,7 +202,7 @@ LogTarget log_target_from_string(const char *s) _pure_;
/* Helpers to prepare various fields for structured logging */
#define LOG_MESSAGE(fmt, ...) "MESSAGE=" fmt, ##__VA_ARGS__
#define LOG_MESSAGE_ID(x) "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(x)
-#define LOG_ERRNO(error) "ERRNO=%i", error
+#define LOG_ERRNO(error) "ERRNO=%i", abs(error)
void log_received_signal(int level, const struct signalfd_siginfo *si);