diff options
author | Thomas Haller <thaller@redhat.com> | 2021-01-13 09:41:56 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-01-13 09:46:59 +0100 |
commit | 46da6eae6e937e7aa91acd40c8e3e05fc8b93091 (patch) | |
tree | b3640470cc86c8bb2420df0201088b66b19294d9 | |
parent | 828e47f63275fce8ea0fd9b8510519fd3e3144a5 (diff) | |
download | NetworkManager-46da6eae6e937e7aa91acd40c8e3e05fc8b93091.tar.gz |
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.
-rw-r--r-- | src/nm-ip4-config.c | 4 | ||||
-rw-r--r-- | src/nm-ip6-config.c | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index 0cb4cb2e93..b881871c5a 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -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)); } diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c index fbc9fe246f..0be98e5fe6 100644 --- a/src/nm-ip6-config.c +++ b/src/nm-ip6-config.c @@ -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)); } |