mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 03:40:07 +01:00
core: replace g_return_if_fail() with nm_assert() in nm_ip_config_iter_ip[46]_(address,route)_init()
With LTO, the compiler can see that some code paths return without
initializing the variable. But it fails to see that those are code
paths after an assertion fail. Still that can lead to
"-Wmaybe-uninitialized" warnings in the caller.
Avoid that by not using g_return_if_fail() but nm_assert().
src/nm-ip6-config.c: In function '_nmtst_ip6_config_get_address':
./shared/nm-glib-aux/nm-dedup-multi.h:337:8: error: 'iter._next' may be used uninitialized in this function [-Werror=maybe-uninitialized]
337 | if (!iter->_next)
| ^
src/nm-ip6-config.c:1622:33: note: 'iter._next' was declared here
1622 | NMDedupMultiIter iter;
| ^
./shared/nm-glib-aux/nm-dedup-multi.h:343:8: error: 'iter._head' may be used uninitialized in this function [-Werror=maybe-uninitialized]
343 | if (iter->_next->next == iter->_head)
| ^
src/nm-ip6-config.c:1622:33: note: 'iter._head' was declared here
1622 | NMDedupMultiIter iter;
| ^
and more.
This commit is contained in:
parent
828e47f632
commit
46da6eae6e
2 changed files with 7 additions and 3 deletions
|
|
@ -365,7 +365,8 @@ nm_ip4_config_lookup_addresses(const NMIP4Config *self)
|
|||
void
|
||||
nm_ip_config_iter_ip4_address_init(NMDedupMultiIter *ipconf_iter, const NMIP4Config *self)
|
||||
{
|
||||
g_return_if_fail(NM_IS_IP4_CONFIG(self));
|
||||
nm_assert(NM_IS_IP4_CONFIG(self));
|
||||
|
||||
nm_dedup_multi_iter_init(ipconf_iter, nm_ip4_config_lookup_addresses(self));
|
||||
}
|
||||
|
||||
|
|
@ -383,6 +384,7 @@ void
|
|||
nm_ip_config_iter_ip4_route_init(NMDedupMultiIter *ipconf_iter, const NMIP4Config *self)
|
||||
{
|
||||
nm_assert(NM_IS_IP4_CONFIG(self));
|
||||
|
||||
nm_dedup_multi_iter_init(ipconf_iter, nm_ip4_config_lookup_routes(self));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -158,7 +158,8 @@ nm_ip6_config_lookup_addresses(const NMIP6Config *self)
|
|||
void
|
||||
nm_ip_config_iter_ip6_address_init(NMDedupMultiIter *ipconf_iter, const NMIP6Config *self)
|
||||
{
|
||||
g_return_if_fail(NM_IS_IP6_CONFIG(self));
|
||||
nm_assert(NM_IS_IP6_CONFIG(self));
|
||||
|
||||
nm_dedup_multi_iter_init(ipconf_iter, nm_ip6_config_lookup_addresses(self));
|
||||
}
|
||||
|
||||
|
|
@ -175,7 +176,8 @@ nm_ip6_config_lookup_routes(const NMIP6Config *self)
|
|||
void
|
||||
nm_ip_config_iter_ip6_route_init(NMDedupMultiIter *ipconf_iter, const NMIP6Config *self)
|
||||
{
|
||||
g_return_if_fail(NM_IS_IP6_CONFIG(self));
|
||||
nm_assert(NM_IS_IP6_CONFIG(self));
|
||||
|
||||
nm_dedup_multi_iter_init(ipconf_iter, nm_ip6_config_lookup_routes(self));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue