diff --git a/src/dhcp-manager/systemd-dhcp/nm-sd-adapt.h b/src/dhcp-manager/systemd-dhcp/nm-sd-adapt.h index ce1716b175..a95f5bfb42 100644 --- a/src/dhcp-manager/systemd-dhcp/nm-sd-adapt.h +++ b/src/dhcp-manager/systemd-dhcp/nm-sd-adapt.h @@ -57,7 +57,7 @@ G_STMT_START { \ if (nm_logging_enabled (_l, LOGD_DHCP)) { \ const char *_location = strrchr (file "", '/'); \ \ - _nm_log (_location ? _location + 1 : file, line, func, _l, LOGD_DHCP, format, ## __VA_ARGS__); \ + _nm_log (_location ? _location + 1 : file, line, func, _l, LOGD_DHCP, 0, format, ## __VA_ARGS__); \ } \ } G_STMT_END diff --git a/src/nm-logging.c b/src/nm-logging.c index f1291fa73b..2778e84b89 100644 --- a/src/nm-logging.c +++ b/src/nm-logging.c @@ -362,6 +362,7 @@ _nm_log (const char *file, const char *func, NMLogLevel level, NMLogDomain domain, + int error, const char *fmt, ...) { @@ -379,6 +380,10 @@ _nm_log (const char *file, if (!(logging[level] & domain)) return; + /* Make sure that %m maps to the specified error */ + if (error != 0) + errno = error; + va_start (args, fmt); msg = g_strdup_vprintf (fmt, args); va_end (args); diff --git a/src/nm-logging.h b/src/nm-logging.h index e0aa71690a..4ae9c02687 100644 --- a/src/nm-logging.h +++ b/src/nm-logging.h @@ -105,7 +105,7 @@ typedef enum { /*< skip >*/ #define nm_log(level, domain, ...) \ G_STMT_START { \ if (nm_logging_enabled ((level), (domain))) { \ - _nm_log (__FILE__, __LINE__, G_STRFUNC, (level), (domain), __VA_ARGS__); \ + _nm_log (__FILE__, __LINE__, G_STRFUNC, (level), (domain), 0, __VA_ARGS__); \ } \ } G_STMT_END @@ -141,8 +141,9 @@ void _nm_log (const char *file, const char *func, NMLogLevel level, NMLogDomain domain, + int error, const char *fmt, - ...) __attribute__((__format__ (__printf__, 6, 7))); + ...) __attribute__((__format__ (__printf__, 7, 8))); const char *nm_logging_level_to_string (void); const char *nm_logging_domains_to_string (void);