summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);