mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 14:48:10 +02:00
core: workaround compiler waring in for-each macros for NMIP4Config/NMIP6Config (again)
Compiler wouldn't recognize that the @route/@address argument is always initialized. The right workaround seems to let the next() functions always set the value.
This commit is contained in:
parent
167118a2cf
commit
d36f847e51
3 changed files with 12 additions and 27 deletions
|
|
@ -687,21 +687,6 @@ nm_clear_g_cancellable (GCancellable **cancellable)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/* Only useful inside a macro to avoid compiler warning.
|
|
||||||
*
|
|
||||||
* Otherwise compiler might warn for "if (ptr)"
|
|
||||||
* the address of ‘a’ will always evaluate as ‘true’ [-Werror=address]
|
|
||||||
*
|
|
||||||
* The trivial function avoids the compiler warning.
|
|
||||||
*/
|
|
||||||
static inline int
|
|
||||||
_nm_is_null (const void *ptr)
|
|
||||||
{
|
|
||||||
return !!ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
/* Determine whether @x is a power of two (@x being an integer type).
|
/* Determine whether @x is a power of two (@x being an integer type).
|
||||||
* Basically, this returns TRUE, if @x has exactly one bit set.
|
* Basically, this returns TRUE, if @x has exactly one bit set.
|
||||||
* For negative values and zero, this always returns FALSE. */
|
* For negative values and zero, this always returns FALSE. */
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,8 @@ nm_ip_config_iter_ip4_address_next (NMDedupMultiIter *ipconf_iter, const NMPlatf
|
||||||
gboolean has_next;
|
gboolean has_next;
|
||||||
|
|
||||||
has_next = nm_dedup_multi_iter_next (ipconf_iter);
|
has_next = nm_dedup_multi_iter_next (ipconf_iter);
|
||||||
if (has_next && out_address)
|
if (out_address)
|
||||||
*out_address = NMP_OBJECT_CAST_IP4_ADDRESS (ipconf_iter->current->obj);
|
*out_address = has_next ? NMP_OBJECT_CAST_IP4_ADDRESS (ipconf_iter->current->obj) : NULL;
|
||||||
return has_next;
|
return has_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,18 +58,18 @@ nm_ip_config_iter_ip4_route_next (NMDedupMultiIter *ipconf_iter, const NMPlatfor
|
||||||
gboolean has_next;
|
gboolean has_next;
|
||||||
|
|
||||||
has_next = nm_dedup_multi_iter_next (ipconf_iter);
|
has_next = nm_dedup_multi_iter_next (ipconf_iter);
|
||||||
if (has_next && out_route)
|
if (out_route)
|
||||||
*out_route = NMP_OBJECT_CAST_IP4_ROUTE (ipconf_iter->current->obj);
|
*out_route = has_next ? NMP_OBJECT_CAST_IP4_ROUTE (ipconf_iter->current->obj) : NULL;
|
||||||
return has_next;
|
return has_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define nm_ip_config_iter_ip4_address_for_each(iter, self, address) \
|
#define nm_ip_config_iter_ip4_address_for_each(iter, self, address) \
|
||||||
for (({ if (!_nm_is_null (address)) { *((const NMPlatformIP4Address **) (address)) = NULL; } }), nm_ip_config_iter_ip4_address_init ((iter), (self)); \
|
for (nm_ip_config_iter_ip4_address_init ((iter), (self)); \
|
||||||
nm_ip_config_iter_ip4_address_next ((iter), (address)); \
|
nm_ip_config_iter_ip4_address_next ((iter), (address)); \
|
||||||
)
|
)
|
||||||
|
|
||||||
#define nm_ip_config_iter_ip4_route_for_each(iter, self, route) \
|
#define nm_ip_config_iter_ip4_route_for_each(iter, self, route) \
|
||||||
for (({ if (!_nm_is_null (route)) { *((const NMPlatformIP4Route **) (route)) = NULL; } }), nm_ip_config_iter_ip4_route_init ((iter), (self)); \
|
for (nm_ip_config_iter_ip4_route_init ((iter), (self)); \
|
||||||
nm_ip_config_iter_ip4_route_next ((iter), (route)); \
|
nm_ip_config_iter_ip4_route_next ((iter), (route)); \
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,8 @@ nm_ip_config_iter_ip6_address_next (NMDedupMultiIter *ipconf_iter, const NMPlatf
|
||||||
gboolean has_next;
|
gboolean has_next;
|
||||||
|
|
||||||
has_next = nm_dedup_multi_iter_next (ipconf_iter);
|
has_next = nm_dedup_multi_iter_next (ipconf_iter);
|
||||||
if (has_next && out_address)
|
if (out_address)
|
||||||
*out_address = NMP_OBJECT_CAST_IP6_ADDRESS (ipconf_iter->current->obj);
|
*out_address = has_next ? NMP_OBJECT_CAST_IP6_ADDRESS (ipconf_iter->current->obj) : NULL;
|
||||||
return has_next;
|
return has_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,18 +51,18 @@ nm_ip_config_iter_ip6_route_next (NMDedupMultiIter *ipconf_iter, const NMPlatfor
|
||||||
gboolean has_next;
|
gboolean has_next;
|
||||||
|
|
||||||
has_next = nm_dedup_multi_iter_next (ipconf_iter);
|
has_next = nm_dedup_multi_iter_next (ipconf_iter);
|
||||||
if (has_next && out_route)
|
if (out_route)
|
||||||
*out_route = NMP_OBJECT_CAST_IP6_ROUTE (ipconf_iter->current->obj);
|
*out_route = has_next ? NMP_OBJECT_CAST_IP6_ROUTE (ipconf_iter->current->obj) : NULL;
|
||||||
return has_next;
|
return has_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define nm_ip_config_iter_ip6_address_for_each(iter, self, address) \
|
#define nm_ip_config_iter_ip6_address_for_each(iter, self, address) \
|
||||||
for (({ if (!_nm_is_null (address)) { *(((const NMPlatformIP6Address **) address)) = NULL; } }), nm_ip_config_iter_ip6_address_init ((iter), (self)); \
|
for (nm_ip_config_iter_ip6_address_init ((iter), (self)); \
|
||||||
nm_ip_config_iter_ip6_address_next ((iter), (address)); \
|
nm_ip_config_iter_ip6_address_next ((iter), (address)); \
|
||||||
)
|
)
|
||||||
|
|
||||||
#define nm_ip_config_iter_ip6_route_for_each(iter, self, route) \
|
#define nm_ip_config_iter_ip6_route_for_each(iter, self, route) \
|
||||||
for (({ if (!_nm_is_null (route)) { *((const NMPlatformIP6Route **) (route)) = NULL; } }), nm_ip_config_iter_ip6_route_init ((iter), (self)); \
|
for (nm_ip_config_iter_ip6_route_init ((iter), (self)); \
|
||||||
nm_ip_config_iter_ip6_route_next ((iter), (route)); \
|
nm_ip_config_iter_ip6_route_next ((iter), (route)); \
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue