Skip to content

Commit 8749356

Browse files
ferruhyShani Peretz
authored andcommitted
ethdev: convert string initialization
[ upstream commit e0d947a ] gcc 15 experimental [1], with -Wextra flag, gives warning in variable initialization as string [2]. The warning has a point when initialized variable is intended to use as string, since assignment is missing the required null terminator for this case. But warning is useless for our usecase. In this patch only updated a few instance to show the issue, there are many instances to fix, if we prefer to go this way. Other option is to disable warning but it can be useful for actual string usecases, so I prefer to keep it. Converted string initialization to array initialization. [1] gcc (GCC) 15.0.0 20241003 (experimental) [2] ../lib/ethdev/rte_flow.h:906:36: error: initializer-string for array of ‘unsigned char’ is too long [-Werror=unterminated-string-initialization] 906 | .hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff", | ^~~~~~~~~~~~~~~~~~~~~~~~~~ ../lib/ethdev/rte_flow.h:907:36: error: initializer-string for array of ‘unsigned char’ is too long [-Werror=unterminated-string-initialization] 907 | .hdr.src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff", | ^~~~~~~~~~~~~~~~~~~~~~~~~~ ../lib/ethdev/rte_flow.h:1009:25: error: initializer-string for array of ‘unsigned char’ is too long [-Werror=unterminated-string-initialization] 1009 | "\xff\xff\xff\xff\xff\xff\xff\xff" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../lib/ethdev/rte_flow.h:1012:25: error: initializer-string for array of ‘unsigned char’ is too long [-Werror=unterminated-string-initialization] 1012 | "\xff\xff\xff\xff\xff\xff\xff\xff" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../lib/ethdev/rte_flow.h:1135:20: error: initializer-string for array of ‘unsigned char’ is too long [-Werror=unterminated-string-initialization] 1135 | .hdr.vni = "\xff\xff\xff", | ^~~~~~~~~~~~~~ Signed-off-by: Ferruh Yigit <ferruh.yigit@amd.com> Acked-by: Morten Brørup <mb@smartsharesystems.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com> Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru> Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
1 parent 29a4f79 commit 8749356

File tree

15 files changed

+112
-123
lines changed

15 files changed

+112
-123
lines changed

app/test-pmd/cmdline_flow.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -833,20 +833,20 @@ struct vxlan_encap_conf vxlan_encap_conf = {
833833
.select_ipv4 = 1,
834834
.select_vlan = 0,
835835
.select_tos_ttl = 0,
836-
.vni = "\x00\x00\x00",
836+
.vni = { 0x00, 0x00, 0x00 },
837837
.udp_src = 0,
838838
.udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
839839
.ipv4_src = RTE_IPV4(127, 0, 0, 1),
840840
.ipv4_dst = RTE_IPV4(255, 255, 255, 255),
841-
.ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
842-
"\x00\x00\x00\x00\x00\x00\x00\x01",
843-
.ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
844-
"\x00\x00\x00\x00\x00\x00\x11\x11",
841+
.ipv6_src = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
842+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
843+
.ipv6_dst = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
844+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11 },
845845
.vlan_tci = 0,
846846
.ip_tos = 0,
847847
.ip_ttl = 255,
848-
.eth_src = "\x00\x00\x00\x00\x00\x00",
849-
.eth_dst = "\xff\xff\xff\xff\xff\xff",
848+
.eth_src = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
849+
.eth_dst = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
850850
};
851851

852852
/** Maximum number of items in struct rte_flow_action_vxlan_encap. */
@@ -869,16 +869,16 @@ struct action_vxlan_encap_data {
869869
struct nvgre_encap_conf nvgre_encap_conf = {
870870
.select_ipv4 = 1,
871871
.select_vlan = 0,
872-
.tni = "\x00\x00\x00",
872+
.tni = { 0x00, 0x00, 0x00 },
873873
.ipv4_src = RTE_IPV4(127, 0, 0, 1),
874874
.ipv4_dst = RTE_IPV4(255, 255, 255, 255),
875-
.ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
876-
"\x00\x00\x00\x00\x00\x00\x00\x01",
877-
.ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
878-
"\x00\x00\x00\x00\x00\x00\x11\x11",
875+
.ipv6_src = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
876+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
877+
.ipv6_dst = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
878+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11 },
879879
.vlan_tci = 0,
880-
.eth_src = "\x00\x00\x00\x00\x00\x00",
881-
.eth_dst = "\xff\xff\xff\xff\xff\xff",
880+
.eth_src = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
881+
.eth_dst = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
882882
};
883883

884884
/** Maximum number of items in struct rte_flow_action_nvgre_encap. */
@@ -7676,7 +7676,8 @@ parse_prefix(struct context *ctx, const struct token *token,
76767676
void *buf, unsigned int size)
76777677
{
76787678
const struct arg *arg = pop_args(ctx);
7679-
static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
7679+
static const uint8_t conv[] = { 0x00, 0x80, 0xc0, 0xe0, 0xf0,
7680+
0xf8, 0xfc, 0xfe, 0xff };
76807681
char *end;
76817682
uintmax_t u;
76827683
unsigned int bytes;

app/test/test_bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3346,7 +3346,7 @@ test_bpf_filter_sanity(pcap_t *pcap)
33463346

33473347
hdr = rte_pktmbuf_mtod(m, typeof(hdr));
33483348
hdr->eth_hdr = (struct rte_ether_hdr) {
3349-
.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
3349+
.dst_addr.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
33503350
.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4),
33513351
};
33523352
hdr->ip_hdr = (struct rte_ipv4_hdr) {

app/test/test_pcapng.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ mbuf1_prepare(struct dummy_mbuf *dm, uint32_t plen)
7373
struct rte_udp_hdr udp;
7474
} pkt = {
7575
.eth = {
76-
.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
76+
.dst_addr.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
7777
.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4),
7878
},
7979
.ip = {

app/test/test_security_inline_macsec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ create_default_flow(const struct mcs_test_vector *td, uint16_t portid,
318318
struct rte_flow *flow;
319319
struct rte_flow_item_eth eth = { .hdr.ether_type = 0, };
320320
static const struct rte_flow_item_eth eth_mask = {
321-
.hdr.dst_addr.addr_bytes = "\x00\x00\x00\x00\x00\x00",
322-
.hdr.src_addr.addr_bytes = "\x00\x00\x00\x00\x00\x00",
321+
.hdr.dst_addr.addr_bytes = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
322+
.hdr.src_addr.addr_bytes = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
323323
.hdr.ether_type = RTE_BE16(0x0000),
324324
};
325325

doc/guides/prog_guide/rte_flow.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3836,7 +3836,7 @@ For example, to create a pattern template to match on the destination MAC:
38363836
38373837
const struct rte_flow_pattern_template_attr attr = {.ingress = 1};
38383838
struct rte_flow_item_eth eth_m = {
3839-
.dst.addr_bytes = "\xff\xff\xff\xff\xff\xff";
3839+
.dst.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
38403840
};
38413841
struct rte_flow_item pattern[] = {
38423842
[0] = {.type = RTE_FLOW_ITEM_TYPE_ETH,

drivers/net/cxgbe/cxgbe_flow.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -889,8 +889,8 @@ static struct chrte_fparse parseitem[] = {
889889
[RTE_FLOW_ITEM_TYPE_ETH] = {
890890
.fptr = ch_rte_parsetype_eth,
891891
.dmask = &(const struct rte_flow_item_eth){
892-
.hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
893-
.hdr.src_addr.addr_bytes = "\x00\x00\x00\x00\x00\x00",
892+
.hdr.dst_addr.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
893+
.hdr.src_addr.addr_bytes = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
894894
.hdr.ether_type = 0xffff,
895895
}
896896
},
@@ -918,12 +918,10 @@ static struct chrte_fparse parseitem[] = {
918918
.fptr = ch_rte_parsetype_ipv6,
919919
.dmask = &(const struct rte_flow_item_ipv6) {
920920
.hdr = {
921-
.src_addr =
922-
"\xff\xff\xff\xff\xff\xff\xff\xff"
923-
"\xff\xff\xff\xff\xff\xff\xff\xff",
924-
.dst_addr =
925-
"\xff\xff\xff\xff\xff\xff\xff\xff"
926-
"\xff\xff\xff\xff\xff\xff\xff\xff",
921+
.src_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
922+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
923+
.dst_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
924+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
927925
.vtc_flow = RTE_BE32(0xff000000),
928926
},
929927
},

drivers/net/dpaa2/dpaa2_flow.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ enum rte_flow_action_type dpaa2_supported_fs_action_type[] = {
100100

101101
#ifndef __cplusplus
102102
static const struct rte_flow_item_eth dpaa2_flow_item_eth_mask = {
103-
.hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
104-
.hdr.src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
103+
.hdr.dst_addr.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
104+
.hdr.src_addr.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
105105
.hdr.ether_type = RTE_BE16(0xffff),
106106
};
107107

@@ -117,12 +117,10 @@ static const struct rte_flow_item_ipv4 dpaa2_flow_item_ipv4_mask = {
117117

118118
static const struct rte_flow_item_ipv6 dpaa2_flow_item_ipv6_mask = {
119119
.hdr = {
120-
.src_addr =
121-
"\xff\xff\xff\xff\xff\xff\xff\xff"
122-
"\xff\xff\xff\xff\xff\xff\xff\xff",
123-
.dst_addr =
124-
"\xff\xff\xff\xff\xff\xff\xff\xff"
125-
"\xff\xff\xff\xff\xff\xff\xff\xff",
120+
.src_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
121+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
122+
.dst_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
123+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
126124
.proto = 0xff
127125
},
128126
};

drivers/net/mlx4/mlx4_flow.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ static const struct mlx4_flow_proc_item mlx4_flow_proc_item_list[] = {
582582
RTE_FLOW_ITEM_TYPE_IPV4),
583583
.mask_support = &(const struct rte_flow_item_eth){
584584
/* Only destination MAC can be matched. */
585-
.hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
585+
.hdr.dst_addr.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
586586
},
587587
.mask_default = &rte_flow_item_eth_mask,
588588
.mask_sz = sizeof(struct rte_flow_item_eth),
@@ -1304,10 +1304,10 @@ mlx4_flow_internal(struct mlx4_priv *priv, struct rte_flow_error *error)
13041304
};
13051305
struct rte_flow_item_eth eth_spec;
13061306
const struct rte_flow_item_eth eth_mask = {
1307-
.hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1307+
.hdr.dst_addr.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
13081308
};
13091309
const struct rte_flow_item_eth eth_allmulti = {
1310-
.hdr.dst_addr.addr_bytes = "\x01\x00\x00\x00\x00\x00",
1310+
.hdr.dst_addr.addr_bytes = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 },
13111311
};
13121312
struct rte_flow_item_vlan vlan_spec;
13131313
const struct rte_flow_item_vlan vlan_mask = {

drivers/net/mlx5/mlx5_flow.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2742,8 +2742,8 @@ mlx5_flow_validate_item_eth(const struct rte_flow_item *item,
27422742
{
27432743
const struct rte_flow_item_eth *mask = item->mask;
27442744
const struct rte_flow_item_eth nic_mask = {
2745-
.hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
2746-
.hdr.src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
2745+
.hdr.dst_addr.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
2746+
.hdr.src_addr.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
27472747
.hdr.ether_type = RTE_BE16(0xffff),
27482748
.has_vlan = ext_vlan_sup ? 1 : 0,
27492749
};
@@ -3005,12 +3005,10 @@ mlx5_flow_validate_item_ipv6(const struct rte_flow_item *item,
30053005
const struct rte_flow_item_ipv6 *spec = item->spec;
30063006
const struct rte_flow_item_ipv6 nic_mask = {
30073007
.hdr = {
3008-
.src_addr =
3009-
"\xff\xff\xff\xff\xff\xff\xff\xff"
3010-
"\xff\xff\xff\xff\xff\xff\xff\xff",
3011-
.dst_addr =
3012-
"\xff\xff\xff\xff\xff\xff\xff\xff"
3013-
"\xff\xff\xff\xff\xff\xff\xff\xff",
3008+
.src_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3009+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
3010+
.dst_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3011+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
30143012
.vtc_flow = RTE_BE32(0xffffffff),
30153013
.proto = 0xff,
30163014
},
@@ -3230,7 +3228,7 @@ mlx5_flow_validate_item_vxlan(struct rte_eth_dev *dev,
32303228
uint8_t vni[4];
32313229
} id = { .vlan_id = 0, };
32323230
const struct rte_flow_item_vxlan nic_mask = {
3233-
.hdr.vni = "\xff\xff\xff",
3231+
.hdr.vni = { 0xff, 0xff, 0xff },
32343232
.hdr.rsvd1 = 0xff,
32353233
};
32363234
const struct rte_flow_item_vxlan *valid_mask;
@@ -3313,7 +3311,7 @@ mlx5_flow_validate_item_vxlan_gpe(const struct rte_flow_item *item,
33133311
} id = { .vlan_id = 0, };
33143312

33153313
struct rte_flow_item_vxlan_gpe nic_mask = {
3316-
.vni = "\xff\xff\xff",
3314+
.vni = { 0xff, 0xff, 0xff },
33173315
.protocol = 0xff,
33183316
};
33193317

@@ -3611,7 +3609,7 @@ mlx5_flow_validate_item_geneve(const struct rte_flow_item *item,
36113609
MLX5_GENEVE_OPT_LEN_1 : MLX5_GENEVE_OPT_LEN_0;
36123610
const struct rte_flow_item_geneve nic_mask = {
36133611
.ver_opt_len_o_c_rsvd0 = RTE_BE16(0x3f80),
3614-
.vni = "\xff\xff\xff",
3612+
.vni = { 0xff, 0xff, 0xff },
36153613
.protocol = RTE_BE16(UINT16_MAX),
36163614
};
36173615

drivers/net/mlx5/mlx5_flow_dv.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7431,11 +7431,11 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
74317431
const struct rte_flow_item_ipv6 nic_ipv6_mask = {
74327432
.hdr = {
74337433
.src_addr =
7434-
"\xff\xff\xff\xff\xff\xff\xff\xff"
7435-
"\xff\xff\xff\xff\xff\xff\xff\xff",
7434+
{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
7435+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
74367436
.dst_addr =
7437-
"\xff\xff\xff\xff\xff\xff\xff\xff"
7438-
"\xff\xff\xff\xff\xff\xff\xff\xff",
7437+
{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
7438+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
74397439
.vtc_flow = RTE_BE32(0xffffffff),
74407440
.proto = 0xff,
74417441
.hop_limits = 0xff,
@@ -8951,8 +8951,8 @@ flow_dv_translate_item_eth(void *key, const struct rte_flow_item *item,
89518951
const struct rte_flow_item_eth *eth_m;
89528952
const struct rte_flow_item_eth *eth_v;
89538953
const struct rte_flow_item_eth nic_mask = {
8954-
.hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
8955-
.hdr.src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
8954+
.hdr.dst_addr.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
8955+
.hdr.src_addr.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
89568956
.hdr.ether_type = RTE_BE16(0xffff),
89578957
.has_vlan = 0,
89588958
};
@@ -9209,12 +9209,10 @@ flow_dv_translate_item_ipv6(void *key, const struct rte_flow_item *item,
92099209
const struct rte_flow_item_ipv6 *ipv6_v;
92109210
const struct rte_flow_item_ipv6 nic_mask = {
92119211
.hdr = {
9212-
.src_addr =
9213-
"\xff\xff\xff\xff\xff\xff\xff\xff"
9214-
"\xff\xff\xff\xff\xff\xff\xff\xff",
9215-
.dst_addr =
9216-
"\xff\xff\xff\xff\xff\xff\xff\xff"
9217-
"\xff\xff\xff\xff\xff\xff\xff\xff",
9212+
.src_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
9213+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
9214+
.dst_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
9215+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
92189216
.vtc_flow = RTE_BE32(0xffffffff),
92199217
.proto = 0xff,
92209218
.hop_limits = 0xff,
@@ -9734,7 +9732,7 @@ flow_dv_translate_item_vxlan(struct rte_eth_dev *dev,
97349732
int i;
97359733
struct mlx5_priv *priv = dev->data->dev_private;
97369734
const struct rte_flow_item_vxlan nic_mask = {
9737-
.hdr.vni = "\xff\xff\xff",
9735+
.hdr.vni = { 0xff, 0xff, 0xff },
97389736
.hdr.rsvd1 = 0xff,
97399737
};
97409738

0 commit comments

Comments
 (0)