mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-11 15:40:17 +01:00
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:
parent
ccf766f659
commit
215c50922d
1 changed files with 5 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue