diff options
author | Thomas Haller <thaller@redhat.com> | 2021-08-05 13:18:24 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-08-05 14:59:01 +0200 |
commit | 7459a8c67a6107fca24d1ce3159e7e1929181fa1 (patch) | |
tree | 6dd239dce2f721e0c14ddc051e88110221f02dda | |
parent | 4513d4db630377d7c11ea8a0eed3c99c081186e4 (diff) | |
download | NetworkManager-7459a8c67a6107fca24d1ce3159e7e1929181fa1.tar.gz |
std-aux: use unique temporary variable in NM_IS_IPv4()
NM_IS_IPv4() should work well, also inside other macros and not
be concerned about shadowing another variable.
-rw-r--r-- | src/libnm-std-aux/nm-std-aux.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/libnm-std-aux/nm-std-aux.h b/src/libnm-std-aux/nm-std-aux.h index 4f18081cd8..62400ad86b 100644 --- a/src/libnm-std-aux/nm-std-aux.h +++ b/src/libnm-std-aux/nm-std-aux.h @@ -1152,15 +1152,17 @@ nm_utils_addr_family_to_char(int addr_family) #define nm_assert_addr_family(addr_family) \ nm_assert(NM_IN_SET((addr_family), NM_AF_INET, NM_AF_INET6)) -#define NM_IS_IPv4(addr_family) \ - ({ \ - const int _addr_family = (addr_family); \ - \ - nm_assert_addr_family(_addr_family); \ - \ - (_addr_family == NM_AF_INET); \ +#define _NM_IS_IPv4(uniq, addr_family) \ + ({ \ + const int NM_UNIQ_T(_addr_family, uniq) = (addr_family); \ + \ + nm_assert_addr_family(NM_UNIQ_T(_addr_family, uniq)); \ + \ + (NM_UNIQ_T(_addr_family, uniq) == NM_AF_INET); \ }) +#define NM_IS_IPv4(addr_family) _NM_IS_IPv4(NM_UNIQ, addr_family) + static inline size_t nm_utils_addr_family_to_size(int addr_family) { |