summaryrefslogtreecommitdiff
path: root/src/nm-logging.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-12-11 22:33:19 +0100
committerThomas Haller <thaller@redhat.com>2016-12-13 11:26:58 +0100
commit215c50922d75ecf75eebc9c871adcdc0fabe3f2d (patch)
treeaf63f35ba17b73104bdeebcf918001a8c02f85a4 /src/nm-logging.c
parentccf766f6596d47b6491553d607ffbd3d9295e0fb (diff)
downloadNetworkManager-215c50922d75ecf75eebc9c871adcdc0fabe3f2d.tar.gz
logging: preserve errno in logging functions
It would be nice that our logging functions are guaranteed to preserve errno. We are currently not very consistent about handling errno, let's improve on that.
Diffstat (limited to 'src/nm-logging.c')
-rw-r--r--src/nm-logging.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/nm-logging.c b/src/nm-logging.c
index 50927f8caf..c242d90319 100644
--- a/src/nm-logging.c
+++ b/src/nm-logging.c
@@ -599,6 +599,7 @@ _nm_log_impl (const char *file,
va_list args;
char *msg;
GTimeVal tv;
+ int errno_saved;
if ((guint) level >= G_N_ELEMENTS (_nm_logging_enabled_state))
g_return_if_reached ();
@@ -606,6 +607,8 @@ _nm_log_impl (const char *file,
if (!(_nm_logging_enabled_state[level] & domain))
return;
+ errno_saved = errno;
+
/* Make sure that %m maps to the specified error */
if (error != 0) {
if (error < 0)
@@ -719,6 +722,8 @@ _nm_log_impl (const char *file,
}
g_free (msg);
+
+ errno = errno_saved;
}
/*****************************************************************************/