From d6370d09e6aa158d4fc7fe1e2ce4c335eed1e017 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 23 Sep 2015 16:03:41 +0200 Subject: logging: coerce negative error values to positive errno Especially systemd, which makes use of the error argument for logging, likes to represent errors as negative numbers. We hence must invert a negative error code to get the real errno. --- src/nm-logging.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/nm-logging.c') diff --git a/src/nm-logging.c b/src/nm-logging.c index f79ba3c2e4..30c754d163 100644 --- a/src/nm-logging.c +++ b/src/nm-logging.c @@ -431,8 +431,11 @@ _nm_log_impl (const char *file, return; /* Make sure that %m maps to the specified error */ - if (error != 0) + if (error != 0) { + if (error < 0) + error = -error; errno = error; + } va_start (args, fmt); msg = g_strdup_vprintf (fmt, args); -- cgit v1.2.1