summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-01-03 17:53:29 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-01-13 11:12:12 +0100
commit08fed2cf4f8a5d8cd34b77b6bd8e45732d9cbb5e (patch)
tree9f8128c927328f0fd4dd5b3034f3dc0e254e5760
parent9fb5b0d9b5ca8bdf816e3bdc95e73d98b8bc53a0 (diff)
downloadsystemd-08fed2cf4f8a5d8cd34b77b6bd8e45732d9cbb5e.tar.gz
basic/log: allow errno values higher than 255
When the support for "synthetic errno" was added, we started truncating the errno value to just the least significant byte. This is generally OK, because errno values are defined up to ~130. The docs don't really say what the maximum value is. But at least in principle higher values could be added in the future. So let's stop truncating the values needlessly. The kernel (or libbpf?) have an error where they return 524 as an errno value (https://bugzilla.redhat.com/show_bug.cgi?id=2036145). We would confusingly truncate this to 12 (ENOMEM). It seems much nicer to let strerror() give us "Unknown error 524" rather than to print the bogus message about ENOMEM. (cherry picked from commit 5f74fcd41cb1a1b26c23e0f2ab405ae9cf6bcc93) (cherry picked from commit cd686fe4c719bfb894bd24d673c51f19cea64643) (cherry picked from commit fb824c90e5a83218e4252a2c21c7f365d0167458)
-rw-r--r--src/basic/log.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/basic/log.h b/src/basic/log.h
index b3d32abfc8..18b1bc496d 100644
--- a/src/basic/log.h
+++ b/src/basic/log.h
@@ -26,10 +26,10 @@ typedef enum LogTarget{
_LOG_TARGET_INVALID = -EINVAL,
} LogTarget;
-/* Note to readers: << and >> have lower precedence than & and | */
+/* Note to readers: << and >> have lower precedence (are evaluated earlier) than & and | */
#define SYNTHETIC_ERRNO(num) (1 << 30 | (num))
#define IS_SYNTHETIC_ERRNO(val) ((val) >> 30 & 1)
-#define ERRNO_VALUE(val) (abs(val) & 255)
+#define ERRNO_VALUE(val) (abs(val) & ~(1 << 30))
const char *log_target_to_string(LogTarget target) _const_;
LogTarget log_target_from_string(const char *s) _pure_;