Skip to content

Commit 2ad8e9d

Browse files
committed
net: config: init: Suppress array bounds check warning temporarily
If ipv4_multicast_address[] is not set in the yaml config file, then compiler may emit this warning which looks like false positive: net/lib/config/init.c: In function 'ipv4_setup.constprop': net/lib/config/init.c:599:67: warning: offset '4294967279' outside bounds of constant string [-Warray-bounds] 599 | ret = parse_mask(ipv4->ipv4_multicast_addresses[j].value, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ In file included from zephyr/subsys/net/lib/config/init.c:2028: build/test/zephyr/include/generated/net_init_config.inc:137:37: note: 'net_init_config_data' declared here 137 | static const struct net_init_config net_init_config_data = { | ^~~~~~~~~~~~~~~~~~~~ If user has specified ipv4_multicast_addresses in the yaml file, there is no warning printed. Suppress this warning here temporarily before we find out why this happens. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 7baae30 commit 2ad8e9d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

subsys/net/lib/config/init.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,9 +580,30 @@ static void ipv4_setup(struct net_if *iface,
580580
continue;
581581
}
582582

583+
/* If ipv4_multicast_address[] is not set in the config file,
584+
* then compiler may emit this warning which looks like false positive:
585+
*
586+
* zephyr/subsys/net/lib/config/init.c: In function 'ipv4_setup.constprop':
587+
* zephyr/subsys/net/lib/config/init.c:599:67: warning: offset '4294967279' outside
588+
* bounds of constant string [-Warray-bounds]
589+
* 599 | ret = parse_mask(ipv4->ipv4_multicast_addresses[j].value,
590+
* | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
591+
* In file included from zephyr/subsys/net/lib/config/init.c:2028:
592+
* build/test/zephyr/include/generated/net_init_config.inc:137:37:
593+
* note: 'net_init_config_data' declared here
594+
* 137 | static const struct net_init_config net_init_config_data = {
595+
* | ^~~~~~~~~~~~~~~~~~~~
596+
*
597+
* If user has specified ipv4_multicast_addresses in the yaml file, there is no
598+
* warning printed.
599+
*
600+
* Suppress this warning here temporarily before we find out why this happens.
601+
*/
602+
TOOLCHAIN_DISABLE_WARNING(TOOLCHAIN_WARNING_ARRAY_BOUNDS);
583603
ret = parse_mask(ipv4->ipv4_multicast_addresses[j].value,
584604
strlen(ipv4->ipv4_multicast_addresses[j].value),
585605
(struct sockaddr *)&addr, NULL);
606+
TOOLCHAIN_ENABLE_WARNING(TOOLCHAIN_WARNING_ARRAY_BOUNDS);
586607
if (!ret) {
587608
NET_DBG("Invalid IPv%c %s address \"%s\"", '4', "multicast",
588609
ipv4->ipv4_addresses[j].value);

0 commit comments

Comments
 (0)