mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-24 13:40:10 +01: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
1 changed files with 7 additions and 0 deletions
|
|
@ -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…
Add table
Reference in a new issue