mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-15 04:24:32 +00:00
shared: add NM_AUTO_PROTECT_ERRNO
Similar to systemd's PROTECT_ERRNO. The difference it, that it doesn't treat the auto-variable as internal, so it is allowed to use it. E.g. if (!(fd = open (...)) { NM_AUTO_PROTECT_ERRNO (errno_saved); printf ("error: %s", g_strerror (errno_saved)); return FALSE; }
This commit is contained in:
parent
215c50922d
commit
99e1e4d6a1
|
@ -85,6 +85,13 @@ _nm_auto_fclose_impl (FILE **pfd)
|
|||
}
|
||||
#define nm_auto_fclose nm_auto(_nm_auto_fclose_impl)
|
||||
|
||||
static inline void
|
||||
_nm_auto_protect_errno (int *p_saved_errno)
|
||||
{
|
||||
errno = *p_saved_errno;
|
||||
}
|
||||
#define NM_AUTO_PROTECT_ERRNO(errsv_saved) nm_auto(_nm_auto_protect_errno) _nm_unused const int errsv_saved = (errno)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* http://stackoverflow.com/a/11172679 */
|
||||
|
|
Loading…
Reference in a new issue