Skip to content

Commit 65df8f4

Browse files
committed
net: config: init: Disable optimization to avoid bounds check warnings
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. Disable optimization to avoid these warnings. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 54628dd commit 65df8f4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

subsys/net/lib/config/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ zephyr_library_compile_definitions_ifdef(
66
)
77

88
zephyr_library_sources_ifdef(CONFIG_NET_CONFIG_SETTINGS init.c)
9+
10+
# Disable optimization for only init.c in order to avoid false
11+
# positives from bounds checking in optimized builds.
12+
set_source_files_properties(
13+
${CMAKE_CURRENT_SOURCE_DIR}/init.c
14+
PROPERTIES COMPILE_OPTIONS "-O0"
15+
)
16+
917
zephyr_library_include_directories(${ZEPHYR_BASE}/subsys/net/ip)
1018

1119
if(CONFIG_NET_CONFIG_SETTINGS)

0 commit comments

Comments
 (0)