unit: pragma test_address to fix GCC warning on musl-libc
PATCH 1/1 unit: pragma test_address to fix GCC warning on musl-libc
This appears to be a compiler bug causing an array-bounds warning:
unit/test-rtnl.c: In function 'test_address':unit/test-rtnl.c:285:13: error: offset '2305843009213693948' outside bounds of constant string [-Werror=array-bounds]
285 | static void test_address(const void *data)
| ^~~~~~~~~~~~
unit/test-rtnl.c:215:36: note: 'address' declared here
215 | static const struct l_rtnl_address address = {
| ^~~~~~~
There is nothing visually wrong with the code, and it appears to be having an issue with the "label" member, which is a simple constant string. Doing things like adding a member before "label" or making "address" not const seems to make it go away, making it really appear as if the compiler is confused.
Fix this by adding a pragma for that test function.
--- unit/test-rtnl.c | 3 +++ 1 file changed, 3 insertions(+)
unit/test-rtnl.c +3 -0
@@ -279,6 +279,8 @@ static struct ifaddrmsg *build_ifaddrmsg(const struct l_rtnl_address *addr,return ifamsg; } +_Pragma("GCC diagnostic push") +_Pragma("GCC diagnostic ignored \"-Warray-bounds\"")static void test_address (const void *data) {static const int ifindex =3 ;
@@ -293,6 +295,7 @@ static void test_address(const void *data)assert (messages_equal (nlm, ifamsg, ifamsg_len));l_netlink_message_unref (nlm); } +_Pragma("GCC diagnostic pop")static void signal_handler (uint32_t signo,void *user_data) {
Signature · 1 line
2.34.1
Denis Kenzior
AppliedHi James,
Quoted 16 lines · James Prestwood
This appears to be a compiler bug causing an array-bounds warning:
unit/test-rtnl.c: In function 'test_address':unit/test-rtnl.c:285:13: error: offset '2305843009213693948' outside bounds of constant string [-Werror=array-bounds]
285 | static voidtest_address(const void *data)| ^~~~~~~~~~~~
unit/test-rtnl.c:215:36: note: 'address' declared here
215 | static const structl_rtnl_addressaddress = {
| ^~~~~~~There is nothing visually wrong with the code, and it appears to be having an issue with the "label" member, which is a simple constant string. Doing things like adding a member before "label" or making "address" not const seems to make it go away, making it really appear as if the compiler is confused.
Quoted 5 lines
Fix this by adding a pragma for that test function.
--- unit/test-rtnl.c | 3 +++ 1 file changed, 3 insertions(+)
Applied, thanks.
Regards,
-Denis