ethdev: convert string initialization
RFC 1/1 ethdev: convert string initialization
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.
I don't know if this behaviour will change in gcc15, as it is still under development. But if not we may need to update our initialization.
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.
[1]
gcc (GCC) 15.0.0 20240801 (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",
| ^~~~~~~~~~~~~~
--- lib/ethdev/rte_flow.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
lib/ethdev/rte_flow.h +7 -9
@@ -903,8 +903,8 @@ struct rte_flow_item_eth {/** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */ #ifndef __cplusplusstatic const struct rte_flow_item_eth rte_flow_item_eth_mask = { - .hdr.dst_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , - .hdr.src_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , + .hdr.dst_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .hdr.src_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, .hdr.ether_type =RTE_BE16 (0x0000 ), };#endif
@@ -1005,12 +1005,10 @@ struct rte_flow_item_ipv6 {#ifndef __cplusplusstatic const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = { .hdr = { - .src_addr = -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , - .dst_addr = -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , + .src_addr = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .dst_addr = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, }, };#endif
@@ -1132,7 +1130,7 @@ struct rte_flow_item_vxlan {/** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */ #ifndef __cplusplusstatic const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = { - .hdr.vni ="\xff\xff\xff" , + .hdr.vni = {0xff ,0xff ,0xff }, };#endif
Signature · 1 line
2.43.0
Quoted 87 lines · Ferruh Yigit
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.
I don't know if this behaviour will change in gcc15, as it is still under development. But if not we may need to update our initialization.
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.[1]
gcc (GCC) 15.0.0 20240801 (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 <[email protected]>--- lib/ethdev/rte_flow.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)lib/ethdev/rte_flow.h +6
-8@@ -903,8 +903,8 @@ struct rte_flow_item_eth {/** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */ #ifndef __cplusplusstatic const struct rte_flow_item_eth rte_flow_item_eth_mask = { - .hdr.dst_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , - .hdr.src_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , + .hdr.dst_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .hdr.src_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, .hdr.ether_type =RTE_BE16 (0x0000 ), };#endif @@ -1005,12 +1005,10 @@ struct rte_flow_item_ipv6 {#ifndef __cplusplusstatic const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = { .hdr = { - .src_addr = -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , - .dst_addr = -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , + .src_addr = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .dst_addr = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, }, };#endif
lib/ethdev/rte_flow.h struct rte_flow_item_vxlan { · line 1135
Quoted 7 lines
lib/ethdev/rte_flow.h +1
-1@@ -1132,7 +1130,7 @@ struct rte_flow_item_vxlan {/** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */ #ifndef __cplusplusstatic const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = { - .hdr.vni ="\xff\xff\xff" , + .hdr.vni = {0xff ,0xff ,0xff }, };#endif
This solution LGTM.
Quoted 10 lines
From: Ferruh Yigit [mailto:[email protected]]
Sent: Thursday, 1 August 2024 11.27gcc 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.
Quoted 7 lines
I don't know if this behaviour will change in gcc15, as it is still under development. But if not we may need to update our initialization.
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.
Compiler warnings are here to help, so +1 for fixing the code.
Quoted 45 lines
[1]
gcc (GCC) 15.0.0 20240801 (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 <[email protected]>--- lib/ethdev/rte_flow.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)lib/ethdev/rte_flow.h +0
-0
lib/ethdev/rte_flow.h struct rte_flow_item_eth { · line 907
Quoted 7 lines
lib/ethdev/rte_flow.h +2
-2@@ -903,8 +903,8 @@ struct rte_flow_item_eth {/** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */ #ifndef __cplusplusstatic const struct rte_flow_item_eth rte_flow_item_eth_mask = { - .hdr.dst_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , - .hdr.src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff", + .hdr.dst_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .hdr.src_addr.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
Please define and use an RTE_ETHER_ADDR() macro like RTE_IPV4() [1]:
/** Create Ethernet address */
#define RTE_ETHER_ADDR(a, b, c, d, e, f) \
(struct rte_ether_addr){{a, b, c, d, e, f}}Or even better, also add and use an RTE_ETHER_ADDR_BROADCAST definition like RTE_IPV4_BROADCAST [2]:
#define RTE_ETHER_ADDR_BROADCAST RTE_ETHER_ADDR(0xff, 0xff, 0xff, 0xff, 0xff, 0xff)
Then the above code could become:
+ .hdr.dst_addr = RTE_ETHER_ADDR_BROADCAST,
+ .hdr.src_addr = RTE_ETHER_ADDR_BROADCAST,
On the other hand, if they are address masks, maybe using RTE_ETHER_ADDR(0xff, 0xff, 0xff, 0xff, 0xff, 0xff) would be more appropriate.
[1]: https://elixir.bootlin.com/dpdk/v24.07/source/lib/net/rte_ip.h#L67
[2]: https://elixir.bootlin.com/dpdk/v24.07/source/lib/net/rte_ip.h#L111
Quoted 20 lines
lib/ethdev/rte_flow.h +4
-6.hdr.ether_type = RTE_BE16(0x0000), };#endif @@ -1005,12 +1005,10 @@ struct rte_flow_item_ipv6 { #ifndef __cplusplus static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = { .hdr = { - .src_addr = -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , - .dst_addr = -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , + .src_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, + .dst_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
Quoted 1 line
},
Please define and use an RTE_IPV6() macro like RTE_IPV4() [1].
Or even better, add and use an RTE_IPV6_BROADCAST definition like RTE_IPV4_BROADCAST [2].
(Same comment about maybe using RTE_IPV6() instead of RTE_IPV6_BROADCAST for masks being more appropriate.)
Note: Robin is working on a series to introduce an IPv6 address type [3], so you should coordinate the definition of the IPV6 macros/definitions with him.
[3]: https://inbox.dpdk.org/dev/[email protected]/
lib/ethdev/rte_flow.h struct rte_flow_item_vxlan { · line 1133
Quoted 9 lines
lib/ethdev/rte_flow.h +1
-1}, };#endif @@ -1132,7 +1130,7 @@ struct rte_flow_item_vxlan {/** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */ #ifndef __cplusplusstatic const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = { - .hdr.vni = "\xff\xff\xff", + .hdr.vni = { 0xff, 0xff, 0xff },
Yes you your suggestion here. (No special type/macro required.)
Quoted 5 lines
lib/ethdev/rte_flow.h +0
-1};#endif --2.43.0
With suggested changes,
Quoted 87 lines · Morten Brørup
Quoted 10 lines
From: Ferruh Yigit [mailto:[email protected]]
Sent: Thursday, 1 August 2024 11.27gcc 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.
Quoted 7 lines
I don't know if this behaviour will change in gcc15, as it is still under development. But if not we may need to update our initialization.
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.Compiler warnings are here to help, so +1 for fixing the code.
Quoted 45 lines
[1]
gcc (GCC) 15.0.0 20240801 (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 <[email protected]>--- lib/ethdev/rte_flow.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)lib/ethdev/rte_flow.h +0
-0lib/ethdev/rte_flow.h struct rte_flow_item_eth { · line 907
Quoted 7 lines
lib/ethdev/rte_flow.h +2
-2@@ -903,8 +903,8 @@ struct rte_flow_item_eth {/** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */ #ifndef __cplusplusstatic const struct rte_flow_item_eth rte_flow_item_eth_mask = { - .hdr.dst_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , - .hdr.src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff", + .hdr.dst_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .hdr.src_addr.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },Please define and use an
RTE_ETHER_ADDR()macro likeRTE_IPV4()[1]:/** Create Ethernet address */
#define RTE_ETHER_ADDR(a, b, c, d, e, f) \ (struct rte_ether_addr){{a, b, c, d, e, f}}Or even better, also add and use an
RTE_ETHER_ADDR_BROADCASTdefinition likeRTE_IPV4_BROADCAST[2]:#define
RTE_ETHER_ADDR_BROADCASTRTE_ETHER_ADDR(0xff, 0xff, 0xff, 0xff, 0xff, 0xff)Then the above code could become:
(quoted diff) +2
-0+ .hdr.dst_addr = RTE_ETHER_ADDR_BROADCAST, + .hdr.src_addr = RTE_ETHER_ADDR_BROADCAST,
Quoted 2 lines
On the other hand, if they are address masks, maybe using
RTE_ETHER_ADDR(0xff, 0xff, 0xff, 0xff, 0xff, 0xff)would be more appropriate.
Hi Morten,
These are all masks used for flow API, and as mentioned in the commit log there are bunch of them, not just the ones in the patch, I am not sure about creating a macro for each is necessary.
Quoted 56 lines
[1]: https://elixir.bootlin.com/dpdk/v24.07/source/lib/net/rte_ip.h#L67
[2]: https://elixir.bootlin.com/dpdk/v24.07/source/lib/net/rte_ip.h#L111Quoted 20 lines
lib/ethdev/rte_flow.h +4
-6.hdr.ether_type = RTE_BE16(0x0000), };#endif @@ -1005,12 +1005,10 @@ struct rte_flow_item_ipv6 { #ifndef __cplusplus static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = { .hdr = { - .src_addr = -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , - .dst_addr = -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , + .src_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, + .dst_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xffQuoted 1 line
},
Please define and use an
RTE_IPV6()macro likeRTE_IPV4()[1].
Or even better, add and use anRTE_IPV6_BROADCASTdefinition likeRTE_IPV4_BROADCAST[2].(Same comment about maybe using
RTE_IPV6()instead ofRTE_IPV6_BROADCASTfor masks being more appropriate.)Note: Robin is working on a series to introduce an IPv6 address type [3], so you should coordinate the definition of the IPV6 macros/definitions with him.
[3]: https://inbox.dpdk.org/dev/[email protected]/
lib/ethdev/rte_flow.h struct rte_flow_item_vxlan { · line 1133
Quoted 9 lines
lib/ethdev/rte_flow.h +1
-1}, };#endif @@ -1132,7 +1130,7 @@ struct rte_flow_item_vxlan {/** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */ #ifndef __cplusplusstatic const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = { - .hdr.vni = "\xff\xff\xff", + .hdr.vni = { 0xff, 0xff, 0xff },Yes you your suggestion here. (No special type/macro required.)
Quoted 5 lines
lib/ethdev/rte_flow.h +0
-1};#endif --2.43.0
With suggested changes,
Acked-by Morten Brørup <[email protected]>
Morten Brørup
Acked-byQuoted 101 lines
From: Ferruh Yigit [mailto:[email protected]]
Sent: Thursday, 1 August 2024 14.43Quoted 7 lines · Morten Brørup
Quoted 7 lines
From: Ferruh Yigit [mailto:[email protected]]
Sent: Thursday, 1 August 2024 11.27gcc 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
Quoted 5 lines
Quoted 5 lines
string, since assignment is missing the required null terminator for this case. But warning is useless for our usecase.
I don't know if this behaviour will change in gcc15, as it is still under development. But if not we may need to update our
initialization.
Quoted 2 lines
Quoted 2 lines
In this patch only updated a few instance to show the issue, there
are
Quoted 61 lines
Quoted 3 lines
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.
Compiler warnings are here to help, so +1 for fixing the code.
Quoted 45 lines
[1]
gcc (GCC) 15.0.0 20240801 (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 <[email protected]>--- lib/ethdev/rte_flow.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)lib/ethdev/rte_flow.h +0
-0lib/ethdev/rte_flow.h struct rte_flow_item_eth { · line 907
Quoted 7 lines
lib/ethdev/rte_flow.h +2
-2@@ -903,8 +903,8 @@ struct rte_flow_item_eth {/** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */ #ifndef __cplusplusstatic const struct rte_flow_item_eth rte_flow_item_eth_mask = { - .hdr.dst_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , - .hdr.src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff", + .hdr.dst_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .hdr.src_addr.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },Please define and use an
RTE_ETHER_ADDR()macro likeRTE_IPV4()[1]:Quoted 5 lines
/** Create Ethernet address */
#define RTE_ETHER_ADDR(a, b, c, d, e, f) \ (struct rte_ether_addr){{a, b, c, d, e, f}}Or even better, also add and use an
RTE_ETHER_ADDR_BROADCASTdefinition like
RTE_IPV4_BROADCAST[2]:Quoted 2 lines
#define
RTE_ETHER_ADDR_BROADCASTRTE_ETHER_ADDR(0xff,0xff,0xff,
0xff,0xff,0xff)Quoted 6 lines
Then the above code could become:
(quoted diff) +2
-0+ .hdr.dst_addr = RTE_ETHER_ADDR_BROADCAST, + .hdr.src_addr = RTE_ETHER_ADDR_BROADCAST,On the other hand, if they are address masks, maybe using
RTE_ETHER_ADDR(0xff, 0xff, 0xff, 0xff, 0xff, 0xff)would be more appropriate.Quoted 1 line
Quoted 5 lines
Hi Morten,
These are all masks used for flow API, and as mentioned in the commit log there are bunch of them, not just the ones in the patch, I am not sure about creating a macro for each is necessary.
I consider an IP address mask as having the same "type" as an IP address; e.g. if using rte_be32_t for an IP address, I would use the same type for an IP address mask. Similarly for Ethernet address masks.
So I'm requesting that you use macros for the IP and Ethernet types. (If they are all masks, forget about the _BROADCAST definitions.)
It seems the existing code [4] already follows this principle.
[4]: https://elixir.bootlin.com/dpdk/v24.07/source/lib/ethdev/rte_flow.h#L965
Using specific types also gives us type checking, which reduces the risk of bugs.
And since the macros don't already exist for IPv6 and Ethernet addresses, I'm also requesting that you create them - coordinate with Robin regarding the IPv6 address type and macros.
The fields that do not have existing types can use arrays, such as you did for the .hdr.vni = { 0xff, 0xff, 0xff }.
Alternatively...
Use the arrays as you originally suggested.
Then we can revisit the need for specific IPv6 and Ethernet types here, as part of Robin's IPv6 address type series. It might be more straight forward. :-)
Either way,
Quoted 66 lines
Quoted 3 lines
[1]:
https://elixir.bootlin.com/dpdk/v24.07/source/lib/net/rte_ip.h#L67
Quoted 1 line
[2]:
https://elixir.bootlin.com/dpdk/v24.07/source/lib/net/rte_ip.h#L111
Quoted 17 lines
Quoted 17 lines
lib/ethdev/rte_flow.h +2
-6.hdr.ether_type = RTE_BE16(0x0000), };#endif @@ -1005,12 +1005,10 @@ struct rte_flow_item_ipv6 { #ifndef __cplusplus static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = { .hdr = { - .src_addr = - "\xff\xff\xff\xff\xff\xff\xff\xff" - "\xff\xff\xff\xff\xff\xff\xff\xff", - .dst_addr = - "\xff\xff\xff\xff\xff\xff\xff\xff" - "\xff\xff\xff\xff\xff\xff\xff\xff", + .src_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xffQuoted 8 lines
Quoted 5 lines
lib/ethdev/rte_flow.h +2
-0}, + .dst_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff },
Please define and use an
RTE_IPV6()macro likeRTE_IPV4()[1]. Or even better, add and use anRTE_IPV6_BROADCASTdefinition like
RTE_IPV4_BROADCAST[2].Quoted 2 lines
(Same comment about maybe using
RTE_IPV6()instead of
RTE_IPV6_BROADCASTfor masks being more appropriate.)Quoted 2 lines
Note: Robin is working on a series to introduce an IPv6 address type
[3], so you should coordinate the definition of the IPV6 macros/definitions with him.
Quoted 2 lines
[3]:
https://inbox.dpdk.org/dev/98CBD80474FA8B44BF855DF32C47DC35E9F5B1@smarts
erver.smartshare.dk/Quoted 23 lines
lib/ethdev/rte_flow.h struct rte_flow_item_vxlan { · line 1133
Quoted 10 lines
lib/ethdev/rte_flow.h +1
-1}, };#endif @@ -1132,7 +1130,7 @@ struct rte_flow_item_vxlan {/** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */ #ifndef __cplusplusstatic const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = { - .hdr.vni = "\xff\xff\xff", + .hdr.vni = { 0xff, 0xff, 0xff },Yes you your suggestion here. (No special type/macro required.)
Quoted 5 lines
lib/ethdev/rte_flow.h +0
-1};#endif --2.43.0
With suggested changes,
Acked-by Morten Brørup <[email protected]>
Quoted 9 lines · Ferruh Yigit
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.
I don't know if this behaviour will change in gcc15, as it is still under development. But if not we may need to update our initialization.
i investigated this when msvc had some issues with it as well. we determined that it is actually iso c standard compliant.
what basically happens is the characters of the string are copied up to the destination size and any remaining characters from the string literal (including the NUL) are discarded and that is what leads to the warning.
yes, the copied bytes lost their NUL terminator but the destination isn't a string so meh, whatever.
either way i support your fix, it deals with the problem with msvc as well.
thank you!
Quoted 88 lines
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.[1]
gcc (GCC) 15.0.0 20240801 (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 <[email protected]>--- lib/ethdev/rte_flow.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)lib/ethdev/rte_flow.h +7
-9@@ -903,8 +903,8 @@ struct rte_flow_item_eth {/** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */ #ifndef __cplusplusstatic const struct rte_flow_item_eth rte_flow_item_eth_mask = { - .hdr.dst_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , - .hdr.src_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , + .hdr.dst_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .hdr.src_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, .hdr.ether_type =RTE_BE16 (0x0000 ), };#endif @@ -1005,12 +1005,10 @@ struct rte_flow_item_ipv6 {#ifndef __cplusplusstatic const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = { .hdr = { - .src_addr = -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , - .dst_addr = -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , + .src_addr = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .dst_addr = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, }, };#endif @@ -1132,7 +1130,7 @@ struct rte_flow_item_vxlan {/** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */ #ifndef __cplusplusstatic const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = { - .hdr.vni ="\xff\xff\xff" , + .hdr.vni = {0xff ,0xff ,0xff }, };#endif Signature · 1 line
2.43.0
PATCH 1/1 ethdev: convert string initialization
In reply to Ferruh Yigitgcc 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",
| ^~~~~~~~~~~~~~
--- app/test-pmd/cmdline_flow.c | 31 ++++----- app/test/test_bpf.c | 2 +- app/test/test_pcapng.c | 2 +- app/test/test_security_inline_macsec.c | 4 +- doc/guides/prog_guide/ethdev/flow_offload.rst | 2 +- drivers/net/cxgbe/cxgbe_flow.c | 14 ++-- drivers/net/dpaa2/dpaa2_flow.c | 14 ++-- drivers/net/mlx4/mlx4_flow.c | 6 +- drivers/net/mlx5/mlx5_flow.c | 20 +++--- drivers/net/mlx5/mlx5_flow_dv.c | 26 ++++---- drivers/net/mlx5/mlx5_flow_hw.c | 66 +++++++++---------- drivers/net/mlx5/mlx5_trigger.c | 20 +++--- drivers/net/nfp/flower/nfp_flower_flow.c | 14 ++-- drivers/net/nfp/nfp_net_flow.c | 8 +-- drivers/net/tap/tap_flow.c | 30 ++++----- examples/l2fwd-macsec/main.c | 4 +- lib/ethdev/rte_flow.h | 44 ++++++------- 17 files changed, 144 insertions(+), 163 deletions(-)
app/test-pmd/cmdline_flow.c +16 -15
@@ -898,20 +898,20 @@ struct vxlan_encap_conf vxlan_encap_conf = { .select_ipv4 = 1, .select_vlan = 0, .select_tos_ttl = 0, - .vni = "\x00\x00\x00", + .vni = { 0x00, 0x00, 0x00 }, .udp_src = 0, .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT), .ipv4_src = RTE_IPV4(127, 0, 0, 1), .ipv4_dst = RTE_IPV4(255, 255, 255, 255), - .ipv6_src ="\x00\x00\x00\x00\x00\x00\x00\x00" - "\x00\x00\x00\x00\x00\x00\x00\x01", - .ipv6_dst ="\x00\x00\x00\x00\x00\x00\x00\x00" - "\x00\x00\x00\x00\x00\x00\x11\x11", + .ipv6_src = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }, + .ipv6_dst = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11 }, .vlan_tci = 0, .ip_tos = 0, .ip_ttl = 255, - .eth_src = "\x00\x00\x00\x00\x00\x00", - .eth_dst = "\xff\xff\xff\xff\xff\xff", + .eth_src = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + .eth_dst = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, };/** Maximum number of items in struct rte_flow_action_vxlan_encap. */
@@ -934,16 +934,16 @@ struct action_vxlan_encap_data {struct nvgre_encap_conf nvgre_encap_conf = { .select_ipv4 =1 , .select_vlan =0 , - .tni ="\x00\x00\x00" , + .tni = {0x00 ,0x00 ,0x00 }, .ipv4_src =RTE_IPV4 (127 ,0 ,0 ,1 ), .ipv4_dst =RTE_IPV4 (255 ,255 ,255 ,255 ), - .ipv6_src ="\x00\x00\x00\x00\x00\x00\x00\x00" -"\x00\x00\x00\x00\x00\x00\x00\x01" , - .ipv6_dst ="\x00\x00\x00\x00\x00\x00\x00\x00" -"\x00\x00\x00\x00\x00\x00\x11\x11" , + .ipv6_src = {0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x01 }, + .ipv6_dst = {0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x11 ,0x11 }, .vlan_tci =0 , - .eth_src ="\x00\x00\x00\x00\x00\x00" , - .eth_dst ="\xff\xff\xff\xff\xff\xff" , + .eth_src = {0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 }, + .eth_dst = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, };/** Maximum number of items in struct rte_flow_action_nvgre_encap. */
@@ -8304,7 +8304,8 @@ parse_prefix(struct context *ctx, const struct token *token, void *buf, unsigned int size) {const struct arg *arg =pop_args (ctx); -static const uint8_t conv[] ="\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff" ; +static const uint8_t conv[] = {0x00 ,0x80 ,0xc0 ,0xe0 ,0xf0 , +0xf8 ,0xfc ,0xfe ,0xff };char *end;uintmax_t u;unsigned int bytes;
app/test/test_bpf.c +1 -1
@@ -3361,7 +3361,7 @@ test_bpf_filter_sanity(pcap_t *pcap) hdr =rte_pktmbuf_mtod (m,typeof (hdr)); hdr->eth_hdr = (struct rte_ether_hdr ) { - .dst_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , + .dst_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, .ether_type =rte_cpu_to_be_16 (RTE_ETHER_TYPE_IPV4 ), }; hdr->ip_hdr = (struct rte_ipv4_hdr ) {
app/test/test_pcapng.c +1 -1
@@ -73,7 +73,7 @@ mbuf1_prepare(struct dummy_mbuf *dm, uint32_t plen)struct rte_udp_hdr udp; } pkt = { .eth = { - .dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff", + .dst_addr.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, .ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4), }, .ip = {
app/test/test_security_inline_macsec.c +2 -2
@@ -318,8 +318,8 @@ create_default_flow(const struct mcs_test_vector *td, uint16_t portid,struct rte_flow *flow;struct rte_flow_item_eth eth = { .hdr.ether_type =0 , };static const struct rte_flow_item_eth eth_mask = { - .hdr.dst_addr.addr_bytes ="\x00\x00\x00\x00\x00\x00" , - .hdr.src_addr.addr_bytes ="\x00\x00\x00\x00\x00\x00" , + .hdr.dst_addr.addr_bytes = {0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 }, + .hdr.src_addr.addr_bytes = {0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 }, .hdr.ether_type =RTE_BE16 (0x0000 ), };
doc/guides/prog_guide/ethdev/flow_offload.rst +1 -1
@@ -3865,7 +3865,7 @@ For example, to create a pattern template to match on the destination MAC: const struct rte_flow_pattern_template_attr attr = {.ingress = 1}; struct rte_flow_item_eth eth_m = { - .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff"; + .dst.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; }; struct rte_flow_item pattern[] = { [0] = {.type = RTE_FLOW_ITEM_TYPE_ETH,
drivers/net/cxgbe/cxgbe_flow.c +6 -8
@@ -889,8 +889,8 @@ static struct chrte_fparse parseitem[] = { [RTE_FLOW_ITEM_TYPE_ETH] = { .fptr = ch_rte_parsetype_eth, .dmask = &(const struct rte_flow_item_eth ){ - .hdr.dst_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , - .hdr.src_addr.addr_bytes ="\x00\x00\x00\x00\x00\x00" , + .hdr.dst_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .hdr.src_addr.addr_bytes = {0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 }, .hdr.ether_type =0xffff , } },
@@ -918,12 +918,10 @@ static struct chrte_fparse parseitem[] = { .fptr = ch_rte_parsetype_ipv6, .dmask = &(const struct rte_flow_item_ipv6 ) { .hdr = { - .src_addr = -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , - .dst_addr = -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , + .src_addr = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .dst_addr = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, .vtc_flow =RTE_BE32 (0xff000000 ), }, },
drivers/net/dpaa2/dpaa2_flow.c +6 -8
@@ -100,8 +100,8 @@ enum rte_flow_action_type dpaa2_supported_fs_action_type[] = {#ifndef __cplusplusstatic const struct rte_flow_item_eth dpaa2_flow_item_eth_mask = { - .hdr.dst_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , - .hdr.src_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , + .hdr.dst_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .hdr.src_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, .hdr.ether_type =RTE_BE16 (0xffff ), };
@@ -117,12 +117,10 @@ static const struct rte_flow_item_ipv4 dpaa2_flow_item_ipv4_mask = {static const struct rte_flow_item_ipv6 dpaa2_flow_item_ipv6_mask = { .hdr = { - .src_addr = -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , - .dst_addr = -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , + .src_addr = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .dst_addr = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, .proto =0xff }, };
drivers/net/mlx4/mlx4_flow.c +3 -3
@@ -582,7 +582,7 @@ static const struct mlx4_flow_proc_item mlx4_flow_proc_item_list[] = { RTE_FLOW_ITEM_TYPE_IPV4), .mask_support = &(const struct rte_flow_item_eth ){/* Only destination MAC can be matched. */ - .hdr.dst_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , + .hdr.dst_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, }, .mask_default = &rte_flow_item_eth_mask, .mask_sz = sizeof(struct rte_flow_item_eth),
@@ -1304,10 +1304,10 @@ mlx4_flow_internal(struct mlx4_priv *priv, struct rte_flow_error *error) };struct rte_flow_item_eth eth_spec;const struct rte_flow_item_eth eth_mask = { - .hdr.dst_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , + .hdr.dst_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, };const struct rte_flow_item_eth eth_allmulti = { - .hdr.dst_addr.addr_bytes ="\x01\x00\x00\x00\x00\x00" , + .hdr.dst_addr.addr_bytes = {0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 }, };struct rte_flow_item_vlan vlan_spec;const struct rte_flow_item_vlan vlan_mask = {
drivers/net/mlx5/mlx5_flow.c +9 -11
@@ -2668,8 +2668,8 @@ mlx5_flow_validate_item_eth(const struct rte_eth_dev *dev, {const struct rte_flow_item_eth *mask = item->mask;const struct rte_flow_item_eth nic_mask = { - .hdr.dst_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , - .hdr.src_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , + .hdr.dst_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .hdr.src_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, .hdr.ether_type =RTE_BE16 (0xffff ), .has_vlan = ext_vlan_sup ?1 :0 , };
@@ -2933,12 +2933,10 @@ mlx5_flow_validate_item_ipv6(const struct rte_eth_dev *dev,const struct rte_flow_item_ipv6 *spec = item->spec;const struct rte_flow_item_ipv6 nic_mask = { .hdr = { - .src_addr = -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , - .dst_addr = -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , + .src_addr = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .dst_addr = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, .vtc_flow =RTE_BE32 (0xffffffff ), .proto =0xff , },
@@ -3163,7 +3161,7 @@ mlx5_flow_validate_item_vxlan(struct rte_eth_dev *dev,uint8_t vni[4 ]; } id = { .vlan_id = 0, };const struct rte_flow_item_vxlan nic_mask = { - .hdr.vni ="\xff\xff\xff" , + .hdr.vni = {0xff ,0xff ,0xff }, .hdr.rsvd1 =0xff , };const struct rte_flow_item_vxlan *valid_mask;
@@ -3249,7 +3247,7 @@ mlx5_flow_validate_item_vxlan_gpe(const struct rte_flow_item *item, } id = { .vlan_id = 0, };struct rte_flow_item_vxlan_gpe nic_mask = { - .vni ="\xff\xff\xff" , + .vni = {0xff ,0xff ,0xff }, .protocol =0xff , .flags =0xff , };
@@ -3563,7 +3561,7 @@ mlx5_flow_validate_item_geneve(const struct rte_flow_item *item, MLX5_GENEVE_OPT_LEN_1 :MLX5_GENEVE_OPT_LEN_0 ;const struct rte_flow_item_geneve nic_mask = { .ver_opt_len_o_c_rsvd0 =RTE_BE16 (0x3f80 ), - .vni ="\xff\xff\xff" , + .vni = {0xff ,0xff ,0xff }, .protocol =RTE_BE16 (UINT16_MAX ), };
drivers/net/mlx5/mlx5_flow_dv.c +11 -15
@@ -7697,12 +7697,10 @@ const struct rte_flow_item_ipv4 nic_ipv4_mask = {const struct rte_flow_item_ipv6 nic_ipv6_mask = { .hdr = { - .src_addr = -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , - .dst_addr = -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , + .src_addr = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .dst_addr = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, .vtc_flow =RTE_BE32 (0xffffffff ), .proto =0xff , .hop_limits =0xff ,
@@ -9291,8 +9289,8 @@ flow_dv_translate_item_eth(void *key, const struct rte_flow_item *item,const struct rte_flow_item_eth *eth_m;const struct rte_flow_item_eth *eth_v;const struct rte_flow_item_eth nic_mask = { - .hdr.dst_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , - .hdr.src_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , + .hdr.dst_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .hdr.src_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, .hdr.ether_type =RTE_BE16 (0xffff ), .has_vlan =0 , };
@@ -9549,12 +9547,10 @@ flow_dv_translate_item_ipv6(void *key, const struct rte_flow_item *item,const struct rte_flow_item_ipv6 *ipv6_v;const struct rte_flow_item_ipv6 nic_mask = { .hdr = { - .src_addr = -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , - .dst_addr = -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , + .src_addr = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .dst_addr = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, .vtc_flow =RTE_BE32 (0xffffffff ), .proto =0xff , .hop_limits =0xff ,
@@ -10064,7 +10060,7 @@ flow_dv_translate_item_vxlan(struct rte_eth_dev *dev,int i;struct mlx5_priv *priv = dev->data->dev_private;const struct rte_flow_item_vxlan nic_mask = { - .hdr.vni ="\xff\xff\xff" , + .hdr.vni = {0xff ,0xff ,0xff }, .hdr.rsvd1 =0xff , };
drivers/net/mlx5/mlx5_flow_hw.c +32 -34
149 lines not on this page · raw message
drivers/net/mlx5/mlx5_trigger.c +10 -10
@@ -1568,23 +1568,23 @@ mlx5_traffic_enable(struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;struct rte_flow_item_eth bcast = { - .hdr.dst_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , + .hdr.dst_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, };struct rte_flow_item_eth ipv6_multi_spec = { - .hdr.dst_addr.addr_bytes ="\x33\x33\x00\x00\x00\x00" , + .hdr.dst_addr.addr_bytes = {0x33 ,0x33 ,0x00 ,0x00 ,0x00 ,0x00 }, };struct rte_flow_item_eth ipv6_multi_mask = { - .hdr.dst_addr.addr_bytes ="\xff\xff\x00\x00\x00\x00" , + .hdr.dst_addr.addr_bytes = {0xff ,0xff ,0x00 ,0x00 ,0x00 ,0x00 }, };struct rte_flow_item_eth unicast = { - .hdr.src_addr.addr_bytes ="\x00\x00\x00\x00\x00\x00" , + .hdr.src_addr.addr_bytes = {0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 }, };struct rte_flow_item_eth unicast_mask = { - .hdr.dst_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , + .hdr.dst_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, };const unsigned int vlan_filter_n = priv->vlan_filter_n;const struct rte_ether_addr cmp = { - .addr_bytes ="\x00\x00\x00\x00\x00\x00" , + .addr_bytes = {0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 }, };unsigned int i;unsigned int j;
@@ -1653,8 +1653,8 @@ mlx5_traffic_enable(struct rte_eth_dev *dev)return 0 ;if (dev->data->promiscuous) {struct rte_flow_item_eth promisc = { - .hdr.dst_addr.addr_bytes ="\x00\x00\x00\x00\x00\x00" , - .hdr.src_addr.addr_bytes ="\x00\x00\x00\x00\x00\x00" , + .hdr.dst_addr.addr_bytes = {0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 }, + .hdr.src_addr.addr_bytes = {0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 }, .hdr.ether_type =0 , };
@@ -1664,8 +1664,8 @@ mlx5_traffic_enable(struct rte_eth_dev *dev) }if (dev->data->all_multicast) {struct rte_flow_item_eth multicast = { - .hdr.dst_addr.addr_bytes ="\x01\x00\x00\x00\x00\x00" , - .hdr.src_addr.addr_bytes ="\x00\x00\x00\x00\x00\x00" , + .hdr.dst_addr.addr_bytes = {0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 }, + .hdr.src_addr.addr_bytes = {0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 }, .hdr.ether_type =0 , };
drivers/net/nfp/flower/nfp_flower_flow.c +7 -7
@@ -2504,8 +2504,8 @@ static const struct nfp_flow_item_proc nfp_flow_item_proc_list[] = { RTE_FLOW_ITEM_TYPE_IPV6), .mask_support = &(const struct rte_flow_item_eth ) { .hdr = { - .dst_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , - .src_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , + .dst_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .src_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, .ether_type =RTE_BE16 (0xffff ), }, .has_vlan =1 ,
@@ -2557,10 +2557,10 @@ static const struct nfp_flow_item_proc nfp_flow_item_proc_list[] = { .vtc_flow = RTE_BE32(0x0ff00000), .proto = 0xff, .hop_limits = 0xff, - .src_addr ="\xff\xff\xff\xff\xff\xff\xff\xff" - "\xff\xff\xff\xff\xff\xff\xff\xff", - .dst_addr ="\xff\xff\xff\xff\xff\xff\xff\xff" - "\xff\xff\xff\xff\xff\xff\xff\xff", + .src_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, + .dst_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, }, .has_frag_ext = 1, },
@@ -2618,7 +2618,7 @@ static const struct nfp_flow_item_proc nfp_flow_item_proc_list[] = { [RTE_FLOW_ITEM_TYPE_GENEVE] = { .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_ETH), .mask_support = &(const struct rte_flow_item_geneve ) { - .vni ="\xff\xff\xff" , + .vni = {0xff ,0xff ,0xff }, }, .mask_default = &rte_flow_item_geneve_mask, .mask_sz = sizeof(struct rte_flow_item_geneve),
drivers/net/nfp/nfp_net_flow.c +4 -4
@@ -403,10 +403,10 @@ static const struct nfp_net_flow_item_proc nfp_net_flow_item_proc_list[] = { .mask_support = &(const struct rte_flow_item_ipv6){ .hdr = { .proto =0xff , - .src_addr ="\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , - .dst_addr ="\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , + .src_addr = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .dst_addr = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, }, }, .mask_default = &rte_flow_item_ipv6_mask,
drivers/net/tap/tap_flow.c +13 -17
@@ -166,8 +166,8 @@ static const struct tap_flow_items tap_flow_items[] = { RTE_FLOW_ITEM_TYPE_IPV4, RTE_FLOW_ITEM_TYPE_IPV6), .mask = &(const struct rte_flow_item_eth){ - .hdr.dst_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , - .hdr.src_addr.addr_bytes ="\xff\xff\xff\xff\xff\xff" , + .hdr.dst_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .hdr.src_addr.addr_bytes = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, .hdr.ether_type =-1 , }, .mask_sz = sizeof(struct rte_flow_item_eth),
@@ -209,14 +209,10 @@ static const struct tap_flow_items tap_flow_items[] = { RTE_FLOW_ITEM_TYPE_TCP), .mask = &(const struct rte_flow_item_ipv6 ){ .hdr = { - .src_addr = { -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , - }, - .dst_addr = { -"\xff\xff\xff\xff\xff\xff\xff\xff" -"\xff\xff\xff\xff\xff\xff\xff\xff" , - }, + .src_addr = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, + .dst_addr = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff }, .proto =-1 , }, },
@@ -299,7 +295,7 @@ static struct remote_rule implicit_rte_flows[TAP_REMOTE_MAX_IDX] = { .items[0] = { .type = RTE_FLOW_ITEM_TYPE_ETH, .mask = &(const struct rte_flow_item_eth){ - .hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff", + .hdr.dst_addr.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, }, }, .items[1] = {
@@ -316,10 +312,10 @@ static struct remote_rule implicit_rte_flows[TAP_REMOTE_MAX_IDX] = { .items[0] = { .type = RTE_FLOW_ITEM_TYPE_ETH, .mask = &(const struct rte_flow_item_eth){ - .hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff", + .hdr.dst_addr.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, }, .spec = &(const struct rte_flow_item_eth){ - .hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff", + .hdr.dst_addr.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, }, }, .items[1] = {
@@ -336,10 +332,10 @@ static struct remote_rule implicit_rte_flows[TAP_REMOTE_MAX_IDX] = { .items[0] = { .type = RTE_FLOW_ITEM_TYPE_ETH, .mask = &(const struct rte_flow_item_eth){ - .hdr.dst_addr.addr_bytes = "\x33\x33\x00\x00\x00\x00", + .hdr.dst_addr.addr_bytes = { 0x33, 0x33, 0x00, 0x00, 0x00, 0x00 }, }, .spec = &(const struct rte_flow_item_eth){ - .hdr.dst_addr.addr_bytes = "\x33\x33\x00\x00\x00\x00", + .hdr.dst_addr.addr_bytes = { 0x33, 0x33, 0x00, 0x00, 0x00, 0x00 }, }, }, .items[1] = {
@@ -370,10 +366,10 @@ static struct remote_rule implicit_rte_flows[TAP_REMOTE_MAX_IDX] = { .items[0] = { .type = RTE_FLOW_ITEM_TYPE_ETH, .mask = &(const struct rte_flow_item_eth){ - .hdr.dst_addr.addr_bytes = "\x01\x00\x00\x00\x00\x00", + .hdr.dst_addr.addr_bytes = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 }, }, .spec = &(const struct rte_flow_item_eth){ - .hdr.dst_addr.addr_bytes = "\x01\x00\x00\x00\x00\x00", + .hdr.dst_addr.addr_bytes = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 }, }, }, .items[1] = {
examples/l2fwd-macsec/main.c +2 -2
@@ -510,8 +510,8 @@ create_default_flow(uint16_t portid)struct rte_flow *flow;struct rte_flow_item_eth eth;static const struct rte_flow_item_eth eth_mask = { - .hdr.dst_addr.addr_bytes ="\x00\x00\x00\x00\x00\x00" , - .hdr.src_addr.addr_bytes ="\x00\x00\x00\x00\x00\x00" , + .hdr.dst_addr.addr_bytes = {0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 }, + .hdr.src_addr.addr_bytes = {0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 }, .hdr.ether_type =RTE_BE16 (0xFFFF ), };int ret;
lib/ethdev/rte_flow.h +20 -24
123 lines not on this page · raw message
Signature · 1 line
2.43.0
Quoted 46 lines · Ferruh Yigit
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",
Quoted 5 lines
| ^~~~~~~~~~~~~~Signed-off-by Ferruh Yigit <[email protected]>Acked-by Morten Brørup <[email protected]>Acked-by Bruce Richardson <[email protected]>
Dariusz Sosnowski
Acked-byQuoted 70 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Friday, October 4, 2024 09:27
To: Ferruh Yigit <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Ori Kam <[email protected]>; Aman Singh <[email protected]>; Konstantin Ananyev <[email protected]>; Reshma Pattan <[email protected]>; Stephen Hemminger <[email protected]>; Akhil Goyal <[email protected]>; Anoob Joseph <[email protected]>; Potnuri Bharat Teja <[email protected]>; Hemant Agrawal <[email protected]>; Sachin Saxena <[email protected]>; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Dariusz Sosnowski <[email protected]>; Bing Zhao <[email protected]>; Suanming Mou <[email protected]>; Chaoyong He <[email protected]>
Cc: [email protected]; Morten Brørup <[email protected]>; Bruce Richardson <[email protected]>
Subject: Re: [PATCH] ethdev: convert string initializationExternal email: Use caution opening links or attachments
Quoted 48 lines · Ferruh Yigit
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",| ^~~~~~~~~~~~~~
Quoted 6 lines
Quoted 3 lines
Signed-off-by Ferruh Yigit <[email protected]>Acked-by Morten Brørup <[email protected]>Acked-by Bruce Richardson <[email protected]>Acked-by Andrew Rybchenko <[email protected]>
Best regards,
Dariusz Sosnowski
Ferruh Yigit
AppliedQuoted 70 lines · Dariusz Sosnowski
Quoted 70 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Friday, October 4, 2024 09:27
To: Ferruh Yigit <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Ori Kam <[email protected]>; Aman Singh <[email protected]>; Konstantin Ananyev <[email protected]>; Reshma Pattan <[email protected]>; Stephen Hemminger <[email protected]>; Akhil Goyal <[email protected]>; Anoob Joseph <[email protected]>; Potnuri Bharat Teja <[email protected]>; Hemant Agrawal <[email protected]>; Sachin Saxena <[email protected]>; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Dariusz Sosnowski <[email protected]>; Bing Zhao <[email protected]>; Suanming Mou <[email protected]>; Chaoyong He <[email protected]>
Cc: [email protected]; Morten Brørup <[email protected]>; Bruce Richardson <[email protected]>
Subject: Re: [PATCH] ethdev: convert string initializationExternal email: Use caution opening links or attachments
Quoted 48 lines · Ferruh Yigit
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",| ^~~~~~~~~~~~~~
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Signed-off-by Ferruh Yigit <[email protected]>Acked-by Morten Brørup <[email protected]>Acked-by Bruce Richardson <[email protected]>Acked-by Andrew Rybchenko <[email protected]>
Applied to dpdk-next-net/main, thanks.
Quoted 10 lines · On Thu, 1 Aug 2024 02:27:22 -0700 Ferruh Yigit <[email protected]> wrote:
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.
I don't know if this behaviour will change in gcc15, as it is still under development. But if not we may need to update our initialization.
Quoted 7 lines
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.[1]
gcc (GCC) 15.0.0 20240801 (experimental)
I saw Robin added a bunch more of these in the ipv6 struct changes.
Quoted 18 lines · Stephen Hemminger
Quoted 15 lines · On Thu, 1 Aug 2024 02:27:22 -0700 Ferruh Yigit <[email protected]> wrote:
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.
I don't know if this behaviour will change in gcc15, as it is still under development. But if not we may need to update our initialization.
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.
Quoted 6 lines
Quoted 2 lines
[1]
gcc (GCC) 15.0.0 20240801 (experimental)I saw Robin added a bunch more of these in the ipv6 struct changes.
Thanks for the heads up, I will comment on his patch.