Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <willemb@google.com>
Reported-by: Tasmiya Nalatwad <tasmiya@linux.vnet.ibm.com>
Closes: https://lore.kernel.org/netdev/79fbe35c-4dd1-4f27-acb2-7a60794bc348@linux.vnet.ibm.com/
Fixes: 1b4fa28a8b07 ("net: parametrize skb_segment unit test to expand coverage")
Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://lore.kernel.org/r/20231012120901.10765-1-fw@strlen.de
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Florian Westphal and committed by
Paolo Abeni
2f0968a0 04317b12

+22 -22
+22 -22
net/core/gso_test.c
··· 4 4 #include <linux/skbuff.h> 5 5 6 6 static const char hdr[] = "abcdefgh"; 7 - static const int gso_size = 1000; 7 + #define GSO_TEST_SIZE 1000 8 8 9 9 static void __init_skb(struct sk_buff *skb) 10 10 { ··· 18 18 19 19 /* proto is arbitrary, as long as not ETH_P_TEB or vlan */ 20 20 skb->protocol = htons(ETH_P_ATALK); 21 - skb_shinfo(skb)->gso_size = gso_size; 21 + skb_shinfo(skb)->gso_size = GSO_TEST_SIZE; 22 22 } 23 23 24 24 enum gso_test_nr { ··· 53 53 { 54 54 .id = GSO_TEST_NO_GSO, 55 55 .name = "no_gso", 56 - .linear_len = gso_size, 56 + .linear_len = GSO_TEST_SIZE, 57 57 .nr_segs = 1, 58 - .segs = (const unsigned int[]) { gso_size }, 58 + .segs = (const unsigned int[]) { GSO_TEST_SIZE }, 59 59 }, 60 60 { 61 61 .id = GSO_TEST_LINEAR, 62 62 .name = "linear", 63 - .linear_len = gso_size + gso_size + 1, 63 + .linear_len = GSO_TEST_SIZE + GSO_TEST_SIZE + 1, 64 64 .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 }, 66 66 }, 67 67 { 68 68 .id = GSO_TEST_FRAGS, 69 69 .name = "frags", 70 - .linear_len = gso_size, 70 + .linear_len = GSO_TEST_SIZE, 71 71 .nr_frags = 2, 72 - .frags = (const unsigned int[]) { gso_size, 1 }, 72 + .frags = (const unsigned int[]) { GSO_TEST_SIZE, 1 }, 73 73 .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 }, 75 75 }, 76 76 { 77 77 .id = GSO_TEST_FRAGS_PURE, 78 78 .name = "frags_pure", 79 79 .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 }, 81 81 .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 }, 83 83 }, 84 84 { 85 85 .id = GSO_TEST_GSO_PARTIAL, 86 86 .name = "gso_partial", 87 - .linear_len = gso_size, 87 + .linear_len = GSO_TEST_SIZE, 88 88 .nr_frags = 2, 89 - .frags = (const unsigned int[]) { gso_size, 3 }, 89 + .frags = (const unsigned int[]) { GSO_TEST_SIZE, 3 }, 90 90 .nr_segs = 2, 91 - .segs = (const unsigned int[]) { 2 * gso_size, 3 }, 91 + .segs = (const unsigned int[]) { 2 * GSO_TEST_SIZE, 3 }, 92 92 }, 93 93 { 94 94 /* commit 89319d3801d1: frag_list on mss boundaries */ 95 95 .id = GSO_TEST_FRAG_LIST, 96 96 .name = "frag_list", 97 - .linear_len = gso_size, 97 + .linear_len = GSO_TEST_SIZE, 98 98 .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 }, 100 100 .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 }, 102 102 }, 103 103 { 104 104 .id = GSO_TEST_FRAG_LIST_PURE, 105 105 .name = "frag_list_pure", 106 106 .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 }, 108 108 .nr_segs = 2, 109 - .segs = (const unsigned int[]) { gso_size, gso_size }, 109 + .segs = (const unsigned int[]) { GSO_TEST_SIZE, GSO_TEST_SIZE }, 110 110 }, 111 111 { 112 112 /* commit 43170c4e0ba7: GRO of frag_list trains */ 113 113 .id = GSO_TEST_FRAG_LIST_NON_UNIFORM, 114 114 .name = "frag_list_non_uniform", 115 - .linear_len = gso_size, 115 + .linear_len = GSO_TEST_SIZE, 116 116 .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 }, 118 118 .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 }, 120 120 }, 121 121 { 122 122 /* commit 3953c46c3ac7 ("sk_buff: allow segmenting based on frag sizes") and