Skip to content

Commit 2f0968a

Browse files
Florian WestphalPaolo Abeni
authored andcommitted
net: gso_test: fix build with gcc-12 and earlier
gcc 12 errors out with: net/core/gso_test.c:58:48: error: initializer element is not constant 58 | .segs = (const unsigned int[]) { gso_size }, This version isn't old (2022), so switch to preprocessor-bsaed constant instead of 'static const int'. Cc: Willem de Bruijn <[email protected]> Reported-by: Tasmiya Nalatwad <[email protected]> Closes: https://lore.kernel.org/netdev/[email protected]/ Fixes: 1b4fa28 ("net: parametrize skb_segment unit test to expand coverage") Signed-off-by: Florian Westphal <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 04317b1 commit 2f0968a

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

net/core/gso_test.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <linux/skbuff.h>
55

66
static const char hdr[] = "abcdefgh";
7-
static const int gso_size = 1000;
7+
#define GSO_TEST_SIZE 1000
88

99
static void __init_skb(struct sk_buff *skb)
1010
{
@@ -18,7 +18,7 @@ static void __init_skb(struct sk_buff *skb)
1818

1919
/* proto is arbitrary, as long as not ETH_P_TEB or vlan */
2020
skb->protocol = htons(ETH_P_ATALK);
21-
skb_shinfo(skb)->gso_size = gso_size;
21+
skb_shinfo(skb)->gso_size = GSO_TEST_SIZE;
2222
}
2323

2424
enum gso_test_nr {
@@ -53,70 +53,70 @@ static struct gso_test_case cases[] = {
5353
{
5454
.id = GSO_TEST_NO_GSO,
5555
.name = "no_gso",
56-
.linear_len = gso_size,
56+
.linear_len = GSO_TEST_SIZE,
5757
.nr_segs = 1,
58-
.segs = (const unsigned int[]) { gso_size },
58+
.segs = (const unsigned int[]) { GSO_TEST_SIZE },
5959
},
6060
{
6161
.id = GSO_TEST_LINEAR,
6262
.name = "linear",
63-
.linear_len = gso_size + gso_size + 1,
63+
.linear_len = GSO_TEST_SIZE + GSO_TEST_SIZE + 1,
6464
.nr_segs = 3,
65-
.segs = (const unsigned int[]) { gso_size, gso_size, 1 },
65+
.segs = (const unsigned int[]) { GSO_TEST_SIZE, GSO_TEST_SIZE, 1 },
6666
},
6767
{
6868
.id = GSO_TEST_FRAGS,
6969
.name = "frags",
70-
.linear_len = gso_size,
70+
.linear_len = GSO_TEST_SIZE,
7171
.nr_frags = 2,
72-
.frags = (const unsigned int[]) { gso_size, 1 },
72+
.frags = (const unsigned int[]) { GSO_TEST_SIZE, 1 },
7373
.nr_segs = 3,
74-
.segs = (const unsigned int[]) { gso_size, gso_size, 1 },
74+
.segs = (const unsigned int[]) { GSO_TEST_SIZE, GSO_TEST_SIZE, 1 },
7575
},
7676
{
7777
.id = GSO_TEST_FRAGS_PURE,
7878
.name = "frags_pure",
7979
.nr_frags = 3,
80-
.frags = (const unsigned int[]) { gso_size, gso_size, 2 },
80+
.frags = (const unsigned int[]) { GSO_TEST_SIZE, GSO_TEST_SIZE, 2 },
8181
.nr_segs = 3,
82-
.segs = (const unsigned int[]) { gso_size, gso_size, 2 },
82+
.segs = (const unsigned int[]) { GSO_TEST_SIZE, GSO_TEST_SIZE, 2 },
8383
},
8484
{
8585
.id = GSO_TEST_GSO_PARTIAL,
8686
.name = "gso_partial",
87-
.linear_len = gso_size,
87+
.linear_len = GSO_TEST_SIZE,
8888
.nr_frags = 2,
89-
.frags = (const unsigned int[]) { gso_size, 3 },
89+
.frags = (const unsigned int[]) { GSO_TEST_SIZE, 3 },
9090
.nr_segs = 2,
91-
.segs = (const unsigned int[]) { 2 * gso_size, 3 },
91+
.segs = (const unsigned int[]) { 2 * GSO_TEST_SIZE, 3 },
9292
},
9393
{
9494
/* commit 89319d3801d1: frag_list on mss boundaries */
9595
.id = GSO_TEST_FRAG_LIST,
9696
.name = "frag_list",
97-
.linear_len = gso_size,
97+
.linear_len = GSO_TEST_SIZE,
9898
.nr_frag_skbs = 2,
99-
.frag_skbs = (const unsigned int[]) { gso_size, gso_size },
99+
.frag_skbs = (const unsigned int[]) { GSO_TEST_SIZE, GSO_TEST_SIZE },
100100
.nr_segs = 3,
101-
.segs = (const unsigned int[]) { gso_size, gso_size, gso_size },
101+
.segs = (const unsigned int[]) { GSO_TEST_SIZE, GSO_TEST_SIZE, GSO_TEST_SIZE },
102102
},
103103
{
104104
.id = GSO_TEST_FRAG_LIST_PURE,
105105
.name = "frag_list_pure",
106106
.nr_frag_skbs = 2,
107-
.frag_skbs = (const unsigned int[]) { gso_size, gso_size },
107+
.frag_skbs = (const unsigned int[]) { GSO_TEST_SIZE, GSO_TEST_SIZE },
108108
.nr_segs = 2,
109-
.segs = (const unsigned int[]) { gso_size, gso_size },
109+
.segs = (const unsigned int[]) { GSO_TEST_SIZE, GSO_TEST_SIZE },
110110
},
111111
{
112112
/* commit 43170c4e0ba7: GRO of frag_list trains */
113113
.id = GSO_TEST_FRAG_LIST_NON_UNIFORM,
114114
.name = "frag_list_non_uniform",
115-
.linear_len = gso_size,
115+
.linear_len = GSO_TEST_SIZE,
116116
.nr_frag_skbs = 4,
117-
.frag_skbs = (const unsigned int[]) { gso_size, 1, gso_size, 2 },
117+
.frag_skbs = (const unsigned int[]) { GSO_TEST_SIZE, 1, GSO_TEST_SIZE, 2 },
118118
.nr_segs = 4,
119-
.segs = (const unsigned int[]) { gso_size, gso_size, gso_size, 3 },
119+
.segs = (const unsigned int[]) { GSO_TEST_SIZE, GSO_TEST_SIZE, GSO_TEST_SIZE, 3 },
120120
},
121121
{
122122
/* commit 3953c46c3ac7 ("sk_buff: allow segmenting based on frag sizes") and

0 commit comments

Comments
 (0)