diff options
author | Thomas Haller <thaller@redhat.com> | 2018-02-07 17:38:57 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-02-12 13:29:03 +0100 |
commit | d46de19a9ab6763461fe55b41956837e3b021f13 (patch) | |
tree | ce9163941c69b34a4c04484790502f1cc983bbca | |
parent | 4e5bef395129ff5e8d416dacf25a0270d41f18fa (diff) | |
download | NetworkManager-d46de19a9ab6763461fe55b41956837e3b021f13.tar.gz |
shared: add nm_steal_int() helper
-rw-r--r-- | shared/nm-utils/nm-macros-internal.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/shared/nm-utils/nm-macros-internal.h b/shared/nm-utils/nm-macros-internal.h index f4b25b34e8..d3cbe2f050 100644 --- a/shared/nm-utils/nm-macros-internal.h +++ b/shared/nm-utils/nm-macros-internal.h @@ -1318,6 +1318,25 @@ nm_decode_version (guint version, guint *major, guint *minor, guint *micro) /*****************************************************************************/ +/** + * nm_steal_int: + * @p_val: pointer to an int type. + * + * Returns: *p_val and sets *p_val to zero the same time. + * Accepts %NULL, in which case also numeric 0 will be returned. + */ +#define nm_steal_int(p_val) \ + ({ \ + typeof (p_val) const _p_val = (p_val); \ + typeof (*_p_val) _val = 0; \ + \ + if ( _p_val \ + && (_val = *_p_val)) { \ + *_p_val = 0; \ + } \ + _val; \ + }) + static inline int nm_steal_fd (int *p_fd) { |