mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 15:28:03 +02:00
std-aux: add nm_clear_fd() helper
This commit is contained in:
parent
81ed762d46
commit
f3def63fed
1 changed files with 13 additions and 0 deletions
|
|
@ -845,6 +845,19 @@ nm_close(int fd)
|
|||
return r;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
nm_clear_fd(int *p_fd)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if (!p_fd || (fd = *p_fd) < 0)
|
||||
return false;
|
||||
|
||||
*p_fd = -1;
|
||||
nm_close(fd);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* Note: @value is only evaluated when *out_val is present.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue