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.
This commit is contained in:
Thomas Haller 2016-12-11 22:33:19 +01:00
parent ccf766f659
commit 215c50922d

View file

@ -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;
}
/*****************************************************************************/