diff mbox series

[ovs-dev,4/6] test-netlink-policy: Fix missing field initializer warnings on older GCC.

Message ID 20251009092228.382349-5-i.maximets@ovn.org
State Accepted
Commit 67e5e1998b3fb597c12f877dde1c5b538daea895
Headers show
Series Build fixes for OVS on old distributions. | expand

Checks

Context Check Description
ovsrobot/apply-robot warning apply and check: warning
ovsrobot/github-robot-_Build_and_Test success github build: passed

Commit Message

Ilya Maximets Oct. 9, 2025, 9:21 a.m. UTC
For some reason GCC 4.8 doesn't like this style of initialization,
complaining that nla_type is missing in the initializer:

  tests/test-netlink-policy.c: In function 'test_nl_policy_parse_ll_addr':
  tests/test-netlink-policy.c:60:9:
    error: missing initializer for field 'nla_type' of 'struct nlattr'
    [-Werror=missing-field-initializers]
         .nlattr.nla_type = TEST_POLICY_ATTR,
         ^
Let's use a normal designated initializer for the nested structure
to avoid this issue.

Fixes: 2f2ae5b6bdef ("tests: Fix endianness in netlink policy test fixtures.")
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
---
 tests/test-netlink-policy.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

Comments

Kevin Traynor Oct. 10, 2025, 11:23 a.m. UTC | #1
On 09/10/2025 10:21, Ilya Maximets wrote:
> For some reason GCC 4.8 doesn't like this style of initialization,
> complaining that nla_type is missing in the initializer:
> 
>   tests/test-netlink-policy.c: In function 'test_nl_policy_parse_ll_addr':
>   tests/test-netlink-policy.c:60:9:
>     error: missing initializer for field 'nla_type' of 'struct nlattr'
>     [-Werror=missing-field-initializers]
>          .nlattr.nla_type = TEST_POLICY_ATTR,
>          ^

that is surprising

> Let's use a normal designated initializer for the nested structure
> to avoid this issue.
> 
> Fixes: 2f2ae5b6bdef ("tests: Fix endianness in netlink policy test fixtures.")
> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
> ---
>  tests/test-netlink-policy.c | 15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)

Acked-by: Kevin Traynor <ktraynor@redhat.com>
Eelco Chaudron Oct. 10, 2025, 11:48 a.m. UTC | #2
On 9 Oct 2025, at 11:21, Ilya Maximets wrote:

> For some reason GCC 4.8 doesn't like this style of initialization,
> complaining that nla_type is missing in the initializer:
>
>   tests/test-netlink-policy.c: In function 'test_nl_policy_parse_ll_addr':
>   tests/test-netlink-policy.c:60:9:
>     error: missing initializer for field 'nla_type' of 'struct nlattr'
>     [-Werror=missing-field-initializers]
>          .nlattr.nla_type = TEST_POLICY_ATTR,
>          ^
> Let's use a normal designated initializer for the nested structure
> to avoid this issue.
>
> Fixes: 2f2ae5b6bdef ("tests: Fix endianness in netlink policy test fixtures.")
> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>

Acked-by: Eelco Chaudron <echaudro@redhat.com>
Ilya Maximets Oct. 10, 2025, 8:07 p.m. UTC | #3
On 10/10/25 1:23 PM, Kevin Traynor wrote:
> On 09/10/2025 10:21, Ilya Maximets wrote:
>> For some reason GCC 4.8 doesn't like this style of initialization,
>> complaining that nla_type is missing in the initializer:
>>
>>   tests/test-netlink-policy.c: In function 'test_nl_policy_parse_ll_addr':
>>   tests/test-netlink-policy.c:60:9:
>>     error: missing initializer for field 'nla_type' of 'struct nlattr'
>>     [-Werror=missing-field-initializers]
>>          .nlattr.nla_type = TEST_POLICY_ATTR,
>>          ^
> 
> that is surprising

It is.  Might be a bug or just some weird behavior in that old GCC.

> 
>> Let's use a normal designated initializer for the nested structure
>> to avoid this issue.
>>
>> Fixes: 2f2ae5b6bdef ("tests: Fix endianness in netlink policy test fixtures.")
>> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
>> ---
>>  tests/test-netlink-policy.c | 15 +++++----------
>>  1 file changed, 5 insertions(+), 10 deletions(-)
> 
> Acked-by: Kevin Traynor <ktraynor@redhat.com>
>
diff mbox series

Patch

diff --git a/tests/test-netlink-policy.c b/tests/test-netlink-policy.c
index 55083935a..fee65fc30 100644
--- a/tests/test-netlink-policy.c
+++ b/tests/test-netlink-policy.c
@@ -48,35 +48,30 @@  test_nl_policy_parse_ll_addr(struct ovs_cmdl_context *ctx OVS_UNUSED) {
     struct nlattr *attrs[ARRAY_SIZE(policy)];
     struct nlattr_fixture fixture_nl_data_policy_short = {
         /* too short according to policy */
-        .nlattr.nla_len = 5,
-        .nlattr.nla_type = TEST_POLICY_ATTR,
+        .nlattr = { .nla_len = 5, .nla_type = TEST_POLICY_ATTR },
         .data = { 0x00 },
     };
     struct nlattr_fixture fixture_nl_data_policy_long = {
         /* too long according to policy */
-        .nlattr.nla_len = 25,
-        .nlattr.nla_type = TEST_POLICY_ATTR,
+        .nlattr = { .nla_len = 25, .nla_type = TEST_POLICY_ATTR },
         .data = { 0x00, 0x00, 0x67, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
                   0x00, 0xe4, 0x1d, 0x2d, 0x03, 0x00, 0xa5, 0xf0, 0x2f, 0x00,
                   0x00 },
     };
     struct nlattr_fixture fixture_nl_data_eth = {
         /* valid policy and eth_addr length */
-        .nlattr.nla_len = 10,
-        .nlattr.nla_type = TEST_POLICY_ATTR,
+        .nlattr = { .nla_len = 10, .nla_type = TEST_POLICY_ATTR },
         .data = { 0x00, 0x53, 0x00, 0x00, 0x00, 0x2a },
     };
     struct nlattr_fixture fixture_nl_data_ib = {
         /* valid policy and ib_addr length */
-        .nlattr.nla_len = 24,
-        .nlattr.nla_type = TEST_POLICY_ATTR,
+        .nlattr = { .nla_len = 24, .nla_type = TEST_POLICY_ATTR },
         .data = { 0x00, 0x00, 0x00, 0x67, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00,
                   0x00, 0x00, 0xe4, 0x1d, 0x2d, 0x03, 0x00, 0xa5, 0xf0, 0x2f },
     };
     struct nlattr_fixture fixture_nl_data_invalid = {
         /* valid policy but data neither eth_addr nor ib_addr */
-        .nlattr.nla_len = 11,
-        .nlattr.nla_type = TEST_POLICY_ATTR,
+        .nlattr = { .nla_len = 11, .nla_type = TEST_POLICY_ATTR },
         .data = { 0x00, 0x53, 0x00, 0x00, 0x00, 0x2a, 0x00 },
     };
     struct ofpbuf *buf;