replace zero length arrays
Subsystems (2)
cover replace zero length arrays
Zero length arrays are a GNU extension that has been superseded by flex arrays.
https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
These are places found by cocci/zero_length_array.cocci
Stephen Hemminger (7):
member: replace zero length array with flex array
cryptodev: replace zero length array with flex array
security: replace zero length array with flex array
mlx5: replace zero length array with flex array
nfp: replace zero length array with flex array
enic: replace zero length array with flex array
dpaax: replace zero length array with flex array
drivers/common/dpaax/caamflib/desc/ipsec.h | 2 +- drivers/net/enic/base/vnic_devcmd.h | 2 +- drivers/net/mlx5/mlx5.h | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 2 +- drivers/net/mlx5/mlx5_tx.h | 2 +- drivers/net/nfp/flower/nfp_flower_cmsg.h | 2 +- lib/cryptodev/cryptodev_pmd.h | 2 +- lib/member/rte_member_heap.h | 2 +- lib/security/rte_security_driver.h | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-)
Signature · 1 line
2.39.0
PATCH 1/7 member: replace zero length array with flex array
Zero length arrays are GNU extension. Replace with standard flex array.
--- lib/member/rte_member_heap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/member/rte_member_heap.h +1 -1
@@ -26,7 +26,7 @@ struct hash {uint16_t bkt_cnt;uint16_t num_item;uint32_t seed; -struct hash_bkt buckets[0 ]; +struct hash_bkt buckets[]; };struct node {
Signature · 1 line
2.39.0
Re: [PATCH 1/7] member: replace zero length array with flex array
Quoted 14 lines · Stephen Hemminger
Zero length arrays are GNU extension. Replace with standard flex array.
Signed-off-by Stephen Hemminger <[email protected]>--- lib/member/rte_member_heap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/member/rte_member_heap.h +0
-0
lib/member/rte_member_heap.h struct hash { · line 32
Quoted 8 lines
lib/member/rte_member_heap.h +1
-1@@ -26,7 +26,7 @@ struct hash {uint16_t bkt_cnt;uint16_t num_item;uint32_t seed; -struct hash_bkt buckets[0 ]; +struct hash_bkt buckets[]; };struct node {
i suppose arguably this series depends on the series Bruce is putting up defaulting the minimum C standard to C99 since technically that's the minimum needed for the flexible array members.
Re: [PATCH 1/7] member: replace zero length array with flex array
Quoted 21 lines · On Fri, 13 Jan 2023 16:19:21 -0800 Tyler Retzlaff…
Quoted 20 lines · Stephen Hemminger
Zero length arrays are GNU extension. Replace with standard flex array.
Signed-off-by Stephen Hemminger <[email protected]>--- lib/member/rte_member_heap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/member/rte_member_heap.h +1
-1@@ -26,7 +26,7 @@ struct hash {uint16_t bkt_cnt;uint16_t num_item;uint32_t seed; -struct hash_bkt buckets[0 ]; +struct hash_bkt buckets[]; };
Quoted 9 lines
lib/member/rte_member_heap.h struct hash { · line 32
Quoted 2 lines
lib/member/rte_member_heap.h +0
-0struct node {i suppose arguably this series depends on the series Bruce is putting up defaulting the minimum C standard to C99 since technically that's the minimum needed for the flexible array members.
Series-acked-by Tyler Retzlaff <[email protected]>
There is already flex array usage in several places in DPDK. Therefore this won't be raising the requirements.
Re: [PATCH 1/7] member: replace zero length array with flex array
Quoted 31 lines · Stephen Hemminger
Quoted 28 lines · On Fri, 13 Jan 2023 16:19:21 -0800 Tyler Retzlaff…
Quoted 14 lines · Stephen Hemminger
Zero length arrays are GNU extension. Replace with standard flex array.
Signed-off-by Stephen Hemminger <[email protected]>--- lib/member/rte_member_heap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/member/rte_member_heap.h +0
-0lib/member/rte_member_heap.h struct hash { · line 32
Quoted 8 lines
lib/member/rte_member_heap.h +1
-1@@ -26,7 +26,7 @@ struct hash {uint16_t bkt_cnt;uint16_t num_item;uint32_t seed; -struct hash_bkt buckets[0 ]; +struct hash_bkt buckets[]; };struct node {i suppose arguably this series depends on the series Bruce is putting up defaulting the minimum C standard to C99 since technically that's the minimum needed for the flexible array members.
Quoted 5 lines
Quoted 2 lines
Series-acked-by Tyler Retzlaff <[email protected]>There is already flex array usage in several places in DPDK. Therefore this won't be raising the requirements.
agreed.
PATCH 2/7 cryptodev: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- lib/cryptodev/cryptodev_pmd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/cryptodev/cryptodev_pmd.h +1 -1
@@ -153,7 +153,7 @@ struct rte_cryptodev_sym_session { RTE_MARKER cacheline1 __rte_cache_min_aligned;/**< Second cache line - start of the driver session data */ -uint8_t driver_priv_data[0 ]; +uint8_t driver_priv_data[];/**< Driver specific session data, variable size */ };
Signature · 1 line
2.39.0
PATCH 3/7 security: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- lib/security/rte_security_driver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/security/rte_security_driver.h +1 -1
@@ -34,7 +34,7 @@ struct rte_security_session {/**< session private data IOVA address */ RTE_MARKER cacheline1 __rte_cache_min_aligned; -uint8_t driver_priv_data[0 ]; +uint8_t driver_priv_data[];/**< Private session material, variable size (depends on driver) */ };
Signature · 1 line
2.39.0
PATCH 4/7 mlx5: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- drivers/net/mlx5/mlx5.h | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 2 +- drivers/net/mlx5/mlx5_tx.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/mlx5/mlx5.h +2 -2
@@ -1273,7 +1273,7 @@ struct mlx5_aso_ct_pool { };struct mlx5_aso_sq *sq;/* Async ASO SQ. */ struct mlx5_aso_sq *shared_sq;/* Shared ASO SQ. */ -struct mlx5_aso_ct_action actions[0 ]; +struct mlx5_aso_ct_action actions[];/* CT action structures bulk. */ };
@@ -1290,7 +1290,7 @@ struct mlx5_aso_ct_pools_mng {rte_spinlock_t ct_sl;/* The ASO CT free list lock. */ rte_rwlock_t resize_rwl;/* The ASO CT pool resize lock. */ struct aso_ct_list free_cts;/* Free ASO CT objects list. */ -struct mlx5_aso_sq aso_sqs[0 ];/* ASO queue objects. */ +struct mlx5_aso_sq aso_sqs[];/* ASO queue objects. */ };#ifdef PEDANTIC
drivers/net/mlx5/mlx5_flow.h +1 -1
@@ -1149,7 +1149,7 @@ struct rte_flow_hw {uint32_t age_idx;cnt_id_t cnt_id;uint32_t mtr_id; -uint8_t rule[0 ];/* HWS layer data struct. */ +uint8_t rule[];/* HWS layer data struct. */ } __rte_packed;#ifdef PEDANTIC
drivers/net/mlx5/mlx5_tx.h +1 -1
@@ -166,7 +166,7 @@ struct mlx5_txq_data {struct mlx5_txq_stats stats;/* TX queue counters. */ struct mlx5_txq_stats stats_reset;/* stats on last reset. */ struct mlx5_uar_data uar_data; -struct rte_mbuf *elts[0 ]; +struct rte_mbuf * elts[];/* Storage for queued packets, must be the last field. */ } __rte_cache_aligned;
Signature · 1 line
2.39.0
Re: [PATCH 4/7] mlx5: replace zero length array with flex array
Quoted 5 lines · On Fri, 13 Jan 2023 13:52:02 -0800 Stephen Hemminger…
Zero length arrays are GNU extension. Replace with standard flex array.
Signed-off-by Stephen Hemminger <[email protected]>---
Since Mlx driver enables pedantic checking, this causes build failure on some versions of gcc.
In file included from ../drivers/net/mlx5/mlx5.c:40:../drivers/net/mlx5/mlx5_tx.h:187:23: error: invalid use of structure with flexible array member [-Werror=pedantic] 187 | struct mlx5_txq_data txq; /* Data path structure. */
| ^~~
Understand that the driver wants to enable more checking since Nvidia does good job of keeping the code up to date. But having driver specific compiler flags like this creates more unnecessary complexity and doesn't improve the resulting code.
RE: [PATCH 4/7] mlx5: replace zero length array with flex array
Hi, Stephen
IIUC - for now all of the compilers claimed for DPDK compilation support the zero-length-array and we do not have an issue ? We could eliminate this GNU extension and have workaround, like this:
/* Verbs headers do not support -pedantic. */
#ifdef PEDANTIC
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
#include <infiniband/mlx5dv.h>
#include <infiniband/verbs.h>
#ifdef PEDANTIC
#pragma GCC diagnostic error "-Wpedantic"
#endif
I'm not sure this would make code more readable.
Should we do this WA?
With best regards,
Slava
Quoted 32 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: суббота, 14 января 2023 г. 19:08
To: [email protected]
Cc: Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>
Subject: Re: [PATCH 4/7] mlx5: replace zero length array with flex arrayQuoted 5 lines · On Fri, 13 Jan 2023 13:52:02 -0800 Stephen Hemminger…
Zero length arrays are GNU extension. Replace with standard flex array.
Signed-off-by Stephen Hemminger <[email protected]>---
Since Mlx driver enables pedantic checking, this causes build failure on some versions of gcc.
In file included from
../drivers/net/mlx5/mlx5.c:40:../drivers/net/mlx5/mlx5_tx.h:187:23: error: invalid use of structure with flexible array member [-Werror=pedantic]
187 | structmlx5_txq_datatxq; /* Data path structure. */
| ^~~Understand that the driver wants to enable more checking since Nvidia does good job of keeping the code up to date. But having driver specific compiler flags like this creates more unnecessary complexity and doesn't improve the resulting code.
PATCH 5/7 nfp: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- drivers/net/nfp/flower/nfp_flower_cmsg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/nfp/flower/nfp_flower_cmsg.h +1 -1
@@ -73,7 +73,7 @@ struct nfp_flower_cmsg_mac_repr {uint8_t info;uint8_t nbi_port;uint8_t phys_port; - } ports[0 ]; + } ports[]; };/*
Signature · 1 line
2.39.0
Re: [PATCH 5/7] nfp: replace zero length array with flex array
Hi Stephen,
Thanks for your patch.
Quoted 4 lines · Stephen Hemminger
Zero length arrays are GNU extension. Replace with standard flex array.
Signed-off-by Stephen Hemminger <[email protected]>
I understand this works might depend on another work to raise the minimum compiler versions to support this change. Provided this is sorted out as part of the full series to move to flex arrays, for the change itself.
Quoted 20 lines
--- drivers/net/nfp/flower/nfp_flower_cmsg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/nfp/flower/nfp_flower_cmsg.h +1
-1@@ -73,7 +73,7 @@ struct nfp_flower_cmsg_mac_repr {uint8_t info;uint8_t nbi_port;uint8_t phys_port; - } ports[0 ]; + } ports[]; };/* Signature · 1 line
2.39.0
Signature · 2 lines
Kind Regards, Niklas Söderlund
PATCH 6/7 enic: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- drivers/net/enic/base/vnic_devcmd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/enic/base/vnic_devcmd.h +1 -1
@@ -765,7 +765,7 @@ struct vnic_devcmd_notify {struct vnic_devcmd_provinfo {uint8_t oui[3 ];uint8_t type; -uint8_t data[0 ]; +uint8_t data[]; };/*
Signature · 1 line
2.39.0
Re: [PATCH 6/7] enic: replace zero length array with flex array
From: Stephen Hemminger <[email protected]>
Date: Friday, January 13, 2023 at 1:52 PM
To: [email protected] <[email protected]>
Cc: Stephen Hemminger <[email protected]>, John Daley (johndale) <[email protected]>, Hyong Youb Kim (hyonkim) <[email protected]>
Subject: [PATCH 6/7] enic: replace zero length array with flex array
Zero length arrays are GNU extension. Replace with
standard flex array.
--- drivers/net/enic/base/vnic_devcmd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/enic/base/vnic_devcmd.h +1 -1
@@ -765,7 +765,7 @@ struct vnic_devcmd_notify {struct vnic_devcmd_provinfo {uint8_t oui[3 ];uint8_t type; -uint8_t data[0 ]; +uint8_t data[]; };/*
--
2.39.0
PATCH 7/7 dpaax: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- drivers/common/dpaax/caamflib/desc/ipsec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/common/dpaax/caamflib/desc/ipsec.h +1 -1
@@ -350,7 +350,7 @@ struct ipsec_encap_pdb { };uint32_t spi;uint32_t ip_hdr_len; -uint8_t ip_hdr[0 ]; +uint8_t ip_hdr[]; }; static inline unsigned int
Signature · 1 line
2.39.0
RE: [PATCH 7/7] dpaax: replace zero length array with flex array
Quoted 9 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Friday, 13 January 2023 22.52Zero length arrays are a GNU extension that has been superseded by flex arrays.
https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
These are places found by
cocci/zero_length_array.cocci
v2 cover replace zero length arrays
In reply to Stephen HemmingerZero length arrays are a GNU extension that has been superseded by flex arrays.
https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
These are places found by cocci/zero_length_array.cocci
v2 - rebased on 23.11-rc3
more places started using zero length array
Stephen Hemminger (10):
member: replace zero length array with flex array
cryptodev: replace zero length array with flex array
security: replace zero length array with flex array
pipeline: replace zero length array with flex array net/nfp: replace zero length array with flex array net/enic: replace zero length array with flex array net/mlx5: replace zero length array with flex array
pdcp: replace zero length array with flex array net/cpfl: replace zero length array with flex array common/dpaxx: replace zero length array with flex array
drivers/common/dpaax/caamflib/desc/ipsec.h | 2 +- drivers/common/mlx5/mlx5_prm.h | 2 +- drivers/net/cpfl/cpfl_flow_engine_fxp.c | 2 +- drivers/net/enic/base/vnic_devcmd.h | 2 +- drivers/net/mlx5/mlx5.h | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 2 +- drivers/net/mlx5/mlx5_tx.h | 2 +- drivers/net/nfp/flower/nfp_flower_cmsg.h | 2 +- lib/cryptodev/cryptodev_pmd.h | 2 +- lib/member/rte_member_heap.h | 2 +- lib/pdcp/pdcp_entity.h | 2 +- lib/pipeline/rte_swx_pipeline_internal.h | 2 +- lib/security/rte_security_driver.h | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-)
Signature · 1 line
2.42.0
PATCH v2 1/10 member: replace zero length array with flex array
Zero length arrays are GNU extension. Replace with standard flex array.
--- lib/member/rte_member_heap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/member/rte_member_heap.h +1 -1
@@ -26,7 +26,7 @@ struct hash {uint16_t bkt_cnt;uint16_t num_item;uint32_t seed; -struct hash_bkt buckets[0 ]; +struct hash_bkt buckets[]; };struct node {
Signature · 1 line
2.42.0
Re: [PATCH v2 01/10] member: replace zero length array with flex array
Quoted 5 lines · Stephen Hemminger
Zero length arrays are GNU extension. Replace with standard flex array.
Signed-off-by Stephen Hemminger <[email protected]>---
PATCH v2 2/10 cryptodev: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- lib/cryptodev/cryptodev_pmd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/cryptodev/cryptodev_pmd.h +1 -1
@@ -153,7 +153,7 @@ struct rte_cryptodev_sym_session { RTE_MARKER cacheline1 __rte_cache_min_aligned;/**< Second cache line - start of the driver session data */ -uint8_t driver_priv_data[0 ]; +uint8_t driver_priv_data[];/**< Driver specific session data, variable size */ };
Signature · 1 line
2.42.0
Re: [PATCH v2 02/10] cryptodev: replace zero length array with flex array
Quoted 5 lines · Stephen Hemminger
Zero length arrays are GNU extension. Replace with standard flex array.
Signed-off-by Stephen Hemminger <[email protected]>---
PATCH v2 3/10 security: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- lib/security/rte_security_driver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/security/rte_security_driver.h +1 -1
@@ -33,7 +33,7 @@ struct rte_security_session {/**< session private data IOVA address */ RTE_MARKER cacheline1 __rte_cache_min_aligned; -uint8_t driver_priv_data[0 ]; +uint8_t driver_priv_data[];/**< Private session material, variable size (depends on driver) */ };
Signature · 1 line
2.42.0
Re: [PATCH v2 03/10] security: replace zero length array with flex array
Quoted 5 lines · Stephen Hemminger
Zero length arrays are GNU extension. Replace with standard flex array.
Signed-off-by Stephen Hemminger <[email protected]>---
PATCH v2 4/10 pipeline: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- lib/pipeline/rte_swx_pipeline_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/pipeline/rte_swx_pipeline_internal.h +1 -1
@@ -213,7 +213,7 @@ TAILQ_HEAD(rss_tailq, rss);struct rss_runtime {uint32_t key_size;/* key size in bytes. */ -uint8_t key[0 ];/* key. */ +uint8_t key[];/* key. */ };/*
Signature · 1 line
2.42.0
Re: [PATCH v2 04/10] pipeline: replace zero length array with flex array
Quoted 5 lines · Stephen Hemminger
Zero length arrays are GNU extension. Replace with standard flex array.
Signed-off-by Stephen Hemminger <[email protected]>---
PATCH v2 5/10 net/nfp: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- drivers/net/nfp/flower/nfp_flower_cmsg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/nfp/flower/nfp_flower_cmsg.h +1 -1
@@ -73,7 +73,7 @@ struct nfp_flower_cmsg_mac_repr {uint8_t info;uint8_t nbi_port;uint8_t phys_port; - } ports[0 ]; + } ports[]; };/*
Signature · 1 line
2.42.0
Re: [PATCH v2 05/10] net/nfp: replace zero length array with flex array
Quoted 6 lines · Stephen Hemminger
Zero length arrays are GNU extension. Replace with standard flex array.
Signed-off-by Stephen Hemminger <[email protected]>Acked-by Niklas Söderlund <[email protected]>---
PATCH v2 6/10 net/enic: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- drivers/net/enic/base/vnic_devcmd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/enic/base/vnic_devcmd.h +1 -1
@@ -765,7 +765,7 @@ struct vnic_devcmd_notify {struct vnic_devcmd_provinfo {uint8_t oui[3 ];uint8_t type; -uint8_t data[0 ]; +uint8_t data[]; };/*
Signature · 1 line
2.42.0
Re: [PATCH v2 06/10] net/enic: replace zero length array with flex array
Quoted 6 lines · Stephen Hemminger
Zero length arrays are GNU extension. Replace with standard flex array.
Signed-off-by Stephen Hemminger <[email protected]>Acked-by John Daley <[email protected]>---
PATCH v2 7/10 net/mlx5: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- drivers/common/mlx5/mlx5_prm.h | 2 +- drivers/net/mlx5/mlx5.h | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 2 +- drivers/net/mlx5/mlx5_tx.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
drivers/common/mlx5/mlx5_prm.h +1 -1
@@ -5181,7 +5181,7 @@ struct mlx5_ifc_flow_context_bits {u8 reserved_at_e0[0x40 ];u8 encrypt_decrypt_obj_id[0x20 ];u8 reserved_at_140[0x16c0 ]; -union mlx5_ifc_dest_format_flow_counter_list_auto_bits destination[0 ]; +union mlx5_ifc_dest_format_flow_counter_list_auto_bits destination[]; };struct mlx5_ifc_set_fte_in_bits {
drivers/net/mlx5/mlx5.h +2 -2
@@ -1308,7 +1308,7 @@ struct mlx5_aso_ct_pool { };struct mlx5_aso_sq *sq;/* Async ASO SQ. */ struct mlx5_aso_sq *shared_sq;/* Shared ASO SQ. */ -struct mlx5_aso_ct_action actions[0 ]; +struct mlx5_aso_ct_action actions[];/* CT action structures bulk. */ };
@@ -1325,7 +1325,7 @@ struct mlx5_aso_ct_pools_mng {rte_spinlock_t ct_sl;/* The ASO CT free list lock. */ rte_rwlock_t resize_rwl;/* The ASO CT pool resize lock. */ struct aso_ct_list free_cts;/* Free ASO CT objects list. */ -struct mlx5_aso_sq aso_sqs[0 ];/* ASO queue objects. */ +struct mlx5_aso_sq aso_sqs[];/* ASO queue objects. */ };#ifdef PEDANTIC
drivers/net/mlx5/mlx5_flow.h +1 -1
@@ -1257,7 +1257,7 @@ struct rte_flow_hw {cnt_id_t cnt_id;uint32_t mtr_id;uint32_t rule_idx; -uint8_t rule[0 ];/* HWS layer data struct. */ +uint8_t rule[];/* HWS layer data struct. */ } __rte_packed;#ifdef PEDANTIC
drivers/net/mlx5/mlx5_tx.h +1 -1
@@ -171,7 +171,7 @@ struct mlx5_txq_data {struct mlx5_txq_stats stats;/* TX queue counters. */ struct mlx5_txq_stats stats_reset;/* stats on last reset. */ struct mlx5_uar_data uar_data; -struct rte_mbuf *elts[0 ]; +struct rte_mbuf *elts[];/* Storage for queued packets, must be the last field. */ } __rte_cache_aligned;
Signature · 1 line
2.42.0
Re: [PATCH v2 07/10] net/mlx5: replace zero length array with flex array
Quoted 5 lines · Stephen Hemminger
Zero length arrays are GNU extension. Replace with standard flex array.
Signed-off-by Stephen Hemminger <[email protected]>---
PATCH v2 8/10 pdcp: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- lib/pdcp/pdcp_entity.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/pdcp/pdcp_entity.h +1 -1
@@ -185,7 +185,7 @@ struct entity_priv_dl_part {/** Reorder packet buffer */ struct pdcp_reorder reorder;/** Bitmap memory region */ -uint8_t bitmap_mem[0 ]; +uint8_t bitmap_mem[]; };struct entity_priv_ul_part {
Signature · 1 line
2.42.0
Re: [PATCH v2 08/10] pdcp: replace zero length array with flex array
Quoted 5 lines · Stephen Hemminger
Zero length arrays are GNU extension. Replace with standard flex array.
Signed-off-by Stephen Hemminger <[email protected]>---
RE: [EXT] [PATCH v2 08/10] pdcp: replace zero length array with flex array
In reply to Stephen HemmingerQuoted 3 lines
Zero length arrays are GNU extension. Replace with standard flex array.
Signed-off-by Stephen Hemminger <[email protected]>
PATCH v2 9/10 net/cpfl: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- drivers/net/cpfl/cpfl_flow_engine_fxp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/cpfl/cpfl_flow_engine_fxp.c +1 -1
@@ -53,7 +53,7 @@ struct cpfl_rule_info_meta {uint32_t pr_num;/* number of pattern rules */ uint32_t mr_num;/* number of modification rules */ uint32_t rule_num;/* number of all rules */ -struct cpfl_rule_info rules[0 ]; +struct cpfl_rule_info rules[]; };static uint32_t cpfl_fxp_mod_idx_alloc (struct cpfl_adapter_ext *ad);
Signature · 1 line
2.42.0
Re: [PATCH v2 09/10] net/cpfl: replace zero length array with flex array
Quoted 5 lines · Stephen Hemminger
Zero length arrays are GNU extension. Replace with standard flex array.
Signed-off-by Stephen Hemminger <[email protected]>---
PATCH v2 10/10 common/dpaxx: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- drivers/common/dpaax/caamflib/desc/ipsec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/common/dpaax/caamflib/desc/ipsec.h +1 -1
@@ -350,7 +350,7 @@ struct ipsec_encap_pdb { };uint32_t spi;uint32_t ip_hdr_len; -uint8_t ip_hdr[0 ]; +uint8_t ip_hdr[]; }; static inline unsigned int
Signature · 1 line
2.42.0
Re: [PATCH v2 10/10] common/dpaxx: replace zero length array with flex array
Quoted 5 lines · Stephen Hemminger
Zero length arrays are GNU extension. Replace with standard flex array.
Signed-off-by Stephen Hemminger <[email protected]>---
Reviewed-by Tyler Retzlaff <[email protected]>
Quoted 9 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Friday, 17 November 2023 05.03Zero length arrays are a GNU extension that has been superseded by flex arrays.
https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
These are places found by
cocci/zero_length_array.cocci
Suggest checkpatches to disallow this, if it doesn't already.
Quoted 3 lines · On Fri, 17 Nov 2023 09:31:11 +0100 Morten Brørup <[email protected]>…
Series-acked-by Morten Brørup <[email protected]>Suggest checkpatches to disallow this, if it doesn't already.
Unfortunately, matching this with awk is too hard. Coccinelle can do it but don't want to introduce dependency on that.
Maybe a compiler flag would be possible, but could not find one.
Quoted 11 lines · Stephen Hemminger
Quoted 3 lines · On Fri, 17 Nov 2023 09:31:11 +0100 Morten Brørup <[email protected]>…
Series-acked-by Morten Brørup <[email protected]>Suggest checkpatches to disallow this, if it doesn't already.
Unfortunately, matching this with awk is too hard. Coccinelle can do it but don't want to introduce dependency on that.
Maybe a compiler flag would be possible, but could not find one.
-pedantic will warn, but to use it without clobbering the build with warnings we would probably need to qualify all use of non-standard extensions with the __extension__ keyword.
```
struct foo {
int a;
int b;
char buffer[0];
};
```
zhora ~> gcc -Wall -pedantic oink.c
oink.c:7:14: warning: ISO C forbids zero-size array ‘buffer’ [-Wpedantic]
7 | char buffer[0];v4 cover Replace zero length arrays
In reply to Stephen HemmingerZero length arrays are a GNU extension that has been superseded by flex arrays.
https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
These are places found by cocci/zero_length_array.cocci
v4 - fix issues reported by clang where zero length
array was embedded in security structures in cn10k and txq being embedded in mlx5 was missing extension
Stephen Hemminger (10):
member: replace zero length array with flex array
cryptodev: replace zero length array with flex array
security: replace zero length array with flex array
pipeline: replace zero length array with flex array net/nfp: replace zero length array with flex array net/enic: replace zero length array with flex array net/mlx5: replace zero length array with flex array
pdcp: replace zero length array with flex array net/cpfl: replace zero length array with flex array common/dpaxx: remove zero length array
drivers/common/dpaax/caamflib/desc/ipsec.h | 6 ++---- drivers/common/mlx5/mlx5_prm.h | 2 +- drivers/crypto/cnxk/cn10k_ipsec.h | 4 +++- drivers/crypto/cnxk/cn9k_ipsec.h | 4 +++- drivers/crypto/cnxk/cnxk_se.h | 5 ++++- drivers/net/cpfl/cpfl_flow_engine_fxp.c | 2 +- drivers/net/enic/base/vnic_devcmd.h | 2 +- drivers/net/mlx5/mlx5.h | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 2 +- drivers/net/mlx5/mlx5_tx.h | 3 ++- drivers/net/nfp/flower/nfp_flower_cmsg.h | 2 +- lib/cryptodev/cryptodev_pmd.h | 2 +- lib/member/rte_member_heap.h | 2 +- lib/pdcp/pdcp_entity.h | 2 +- lib/pipeline/rte_swx_pipeline_internal.h | 2 +- lib/security/rte_security_driver.h | 2 +- 16 files changed, 26 insertions(+), 20 deletions(-)
Signature · 1 line
2.42.0
PATCH v4 1/10 member: replace zero length array with flex array
Zero length arrays are GNU extension. Replace with standard flex array.
--- lib/member/rte_member_heap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/member/rte_member_heap.h +1 -1
@@ -26,7 +26,7 @@ struct hash {uint16_t bkt_cnt;uint16_t num_item;uint32_t seed; -struct hash_bkt buckets[0 ]; +struct hash_bkt buckets[]; };struct node {
Signature · 1 line
2.42.0
PATCH v4 2/10 cryptodev: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- drivers/crypto/cnxk/cnxk_se.h | 5 ++++- lib/cryptodev/cryptodev_pmd.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/crypto/cnxk/cnxk_se.h +4 -1
@@ -29,8 +29,11 @@ enum cpt_dp_thread_type { CPT_DP_THREAD_TYPE_PT, }; +#define SYM_SESS_SIZE sizeof(struct rte_cryptodev_sym_session) +struct cnxk_se_sess { -struct rte_cryptodev_sym_session rte_sess; +uint8_t rte_sess[SYM_SESS_SIZE ]; +uint8_t aes_gcm :1 ;uint8_t aes_ccm :1 ;uint8_t aes_ctr :1 ;
lib/cryptodev/cryptodev_pmd.h +1 -1
@@ -153,7 +153,7 @@ struct rte_cryptodev_sym_session { RTE_MARKER cacheline1 __rte_cache_min_aligned;/**< Second cache line - start of the driver session data */ -uint8_t driver_priv_data[0 ]; +uint8_t driver_priv_data[];/**< Driver specific session data, variable size */ };
Signature · 1 line
2.42.0
RE: [EXT] [PATCH v4 02/10] cryptodev: replace zero length array with flex array
Quoted 4 lines
Zero length arrays are GNU extension. Replace with standard flex array.
Signed-off-by Stephen Hemminger <[email protected]>Reviewed-by Tyler Retzlaff <[email protected]>
PATCH v4 3/10 security: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- drivers/crypto/cnxk/cn10k_ipsec.h | 4 +++- drivers/crypto/cnxk/cn9k_ipsec.h | 4 +++- lib/security/rte_security_driver.h | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-)
drivers/crypto/cnxk/cn10k_ipsec.h +3 -1
@@ -24,8 +24,10 @@ struct cn10k_ipsec_sa { }; }__rte_aligned (ROC_ALIGN ); +#define SEC_SESS_SIZE sizeof(struct rte_security_session) +struct cn10k_sec_session { -struct rte_security_session rte_sess; +uint8_t rte_sess[SEC_SESS_SIZE ];/** PMD private space */
drivers/crypto/cnxk/cn9k_ipsec.h +3 -1
@@ -20,8 +20,10 @@ struct cn9k_ipsec_sa { }; }__rte_aligned (8 ); +#define SEC_SESS_SIZE sizeof(struct rte_security_session) +struct cn9k_sec_session { -struct rte_security_session rte_sess; +uint8_t rte_sess[SEC_SESS_SIZE ];/** PMD private space */
lib/security/rte_security_driver.h +1 -1
@@ -33,7 +33,7 @@ struct rte_security_session {/**< session private data IOVA address */ RTE_MARKER cacheline1 __rte_cache_min_aligned; -uint8_t driver_priv_data[0 ]; +uint8_t driver_priv_data[];/**< Private session material, variable size (depends on driver) */ };
Signature · 1 line
2.42.0
RE: [EXT] [PATCH v4 03/10] security: replace zero length array with flex array
Quoted 4 lines
Zero length arrays are GNU extension. Replace with standard flex array.
Signed-off-by Stephen Hemminger <[email protected]>Reviewed-by Tyler Retzlaff <[email protected]>
PATCH v4 4/10 pipeline: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- lib/pipeline/rte_swx_pipeline_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/pipeline/rte_swx_pipeline_internal.h +1 -1
@@ -213,7 +213,7 @@ TAILQ_HEAD(rss_tailq, rss);struct rss_runtime {uint32_t key_size;/* key size in bytes. */ -uint8_t key[0 ];/* key. */ +uint8_t key[];/* key. */ };/*
Signature · 1 line
2.42.0
PATCH v4 5/10 net/nfp: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- drivers/net/nfp/flower/nfp_flower_cmsg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/nfp/flower/nfp_flower_cmsg.h +1 -1
@@ -73,7 +73,7 @@ struct nfp_flower_cmsg_mac_repr {uint8_t info;uint8_t nbi_port;uint8_t phys_port; - } ports[0 ]; + } ports[]; };/*
Signature · 1 line
2.42.0
RE: [PATCH v4 05/10] net/nfp: replace zero length array with flex array
Quoted 25 lines
Zero length arrays are GNU extension. Replace with standard flex array.
Signed-off-by Stephen Hemminger <[email protected]>Acked-by Niklas Söderlund <[email protected]>Reviewed-by Tyler Retzlaff <[email protected]>--- drivers/net/nfp/flower/nfp_flower_cmsg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/nfp/flower/nfp_flower_cmsg.h +1
-2@@ -73,7 +73,7 @@ struct nfp_flower_cmsg_mac_repr {uint8_t info;uint8_t nbi_port;uint8_t phys_port; - } ports[0 ]; + } ports[]; };/* -- 2.42.0
PATCH v4 6/10 net/enic: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- drivers/net/enic/base/vnic_devcmd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/enic/base/vnic_devcmd.h +1 -1
@@ -765,7 +765,7 @@ struct vnic_devcmd_notify {struct vnic_devcmd_provinfo {uint8_t oui[3 ];uint8_t type; -uint8_t data[0 ]; +uint8_t data[]; };/*
Signature · 1 line
2.42.0
PATCH v4 7/10 net/mlx5: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- drivers/common/mlx5/mlx5_prm.h | 2 +- drivers/net/mlx5/mlx5.h | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 2 +- drivers/net/mlx5/mlx5_tx.h | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-)
drivers/common/mlx5/mlx5_prm.h +1 -1
@@ -5181,7 +5181,7 @@ struct mlx5_ifc_flow_context_bits {u8 reserved_at_e0[0x40 ];u8 encrypt_decrypt_obj_id[0x20 ];u8 reserved_at_140[0x16c0 ]; -union mlx5_ifc_dest_format_flow_counter_list_auto_bits destination[0 ]; +union mlx5_ifc_dest_format_flow_counter_list_auto_bits destination[]; };struct mlx5_ifc_set_fte_in_bits {
drivers/net/mlx5/mlx5.h +2 -2
@@ -1308,7 +1308,7 @@ struct mlx5_aso_ct_pool { };struct mlx5_aso_sq *sq;/* Async ASO SQ. */ struct mlx5_aso_sq *shared_sq;/* Shared ASO SQ. */ -struct mlx5_aso_ct_action actions[0 ]; +struct mlx5_aso_ct_action actions[];/* CT action structures bulk. */ };
@@ -1325,7 +1325,7 @@ struct mlx5_aso_ct_pools_mng {rte_spinlock_t ct_sl;/* The ASO CT free list lock. */ rte_rwlock_t resize_rwl;/* The ASO CT pool resize lock. */ struct aso_ct_list free_cts;/* Free ASO CT objects list. */ -struct mlx5_aso_sq aso_sqs[0 ];/* ASO queue objects. */ +struct mlx5_aso_sq aso_sqs[];/* ASO queue objects. */ };#ifdef PEDANTIC
drivers/net/mlx5/mlx5_flow.h +1 -1
@@ -1257,7 +1257,7 @@ struct rte_flow_hw {cnt_id_t cnt_id;uint32_t mtr_id;uint32_t rule_idx; -uint8_t rule[0 ];/* HWS layer data struct. */ +uint8_t rule[];/* HWS layer data struct. */ } __rte_packed;#ifdef PEDANTIC
drivers/net/mlx5/mlx5_tx.h +2 -1
@@ -171,11 +171,12 @@ struct mlx5_txq_data {struct mlx5_txq_stats stats;/* TX queue counters. */ struct mlx5_txq_stats stats_reset;/* stats on last reset. */ struct mlx5_uar_data uar_data; -struct rte_mbuf *elts[0 ]; +struct rte_mbuf *elts[];/* Storage for queued packets, must be the last field. */ } __rte_cache_aligned;/* TX queue control descriptor. */ +__extension__ struct mlx5_txq_ctrl { LIST_ENTRY(mlx5_txq_ctrl) next; /* Pointer to the next element. */ uint32_t refcnt; /* Reference counter. */
Signature · 1 line
2.42.0
RE: [PATCH v4 07/10] net/mlx5: replace zero length array with flex array
Hi,
Quoted 7 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Monday, November 20, 2023 18:07
Subject: [PATCH v4 07/10] net/mlx5: replace zero length array with flex arrayZero length arrays are GNU extension. Replace with standard flex array.
Quoted 8 lines
Signed-off-by Stephen Hemminger <[email protected]>Reviewed-by Tyler Retzlaff <[email protected]>--- drivers/common/mlx5/mlx5_prm.h | 2 +- drivers/net/mlx5/mlx5.h | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 2 +- drivers/net/mlx5/mlx5_tx.h | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-)
Look good to me. Thank you.
Best regards,
Dariusz Sosnowski
PATCH v4 8/10 pdcp: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- lib/pdcp/pdcp_entity.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/pdcp/pdcp_entity.h +1 -1
@@ -185,7 +185,7 @@ struct entity_priv_dl_part {/** Reorder packet buffer */ struct pdcp_reorder reorder;/** Bitmap memory region */ -uint8_t bitmap_mem[0 ]; +uint8_t bitmap_mem[]; };struct entity_priv_ul_part {
Signature · 1 line
2.42.0
PATCH v4 9/10 net/cpfl: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- drivers/net/cpfl/cpfl_flow_engine_fxp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/cpfl/cpfl_flow_engine_fxp.c +1 -1
@@ -53,7 +53,7 @@ struct cpfl_rule_info_meta {uint32_t pr_num;/* number of pattern rules */ uint32_t mr_num;/* number of modification rules */ uint32_t rule_num;/* number of all rules */ -struct cpfl_rule_info rules[0 ]; +struct cpfl_rule_info rules[]; };static uint32_t cpfl_fxp_mod_idx_alloc (struct cpfl_adapter_ext *ad);
Signature · 1 line
2.42.0
PATCH v4 10/10 common/dpaxx: remove zero length array
In reply to Stephen HemmingerThere is a place holder zero length array in this driver. But since the structure is embedded in other structures, it could not have been safely used anyway.
There doesn't appear to be any uses of it in the current code.
--- drivers/common/dpaax/caamflib/desc/ipsec.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/common/dpaax/caamflib/desc/ipsec.h +2 -4
@@ -336,7 +336,6 @@ struct ipsec_encap_gcm {* @ip_hdr_len: optional IP Header length (in bytes) * reserved - 16b * Opt. IP Hdr Len - 16b -* @ip_hdr: optional IP Header content (only for IPsec legacy mode) */ struct ipsec_encap_pdb {uint32_t options;
@@ -350,7 +349,6 @@ struct ipsec_encap_pdb { };uint32_t spi;uint32_t ip_hdr_len; -uint8_t ip_hdr[0 ]; }; static inline unsigned int
@@ -776,7 +774,7 @@ cnstr_shdsc_ipsec_encap(uint32_t *descbuf, bool ps, bool swap,PROGRAM_SET_36BIT_ADDR (p); phdr =SHR_HDR (p, share, hdr,0 );__rta_copy_ipsec_encap_pdb (p, pdb, cipherdata->algtype); -COPY_DATA (p, pdb->ip_hdr, pdb->ip_hdr_len); +SET_LABEL (p, hdr); pkeyjmp =JUMP (p, keyjmp,LOCAL_JUMP ,ALL_TRUE ,BOTH |SHRD );if (authdata->keylen)
@@ -913,7 +911,7 @@ cnstr_shdsc_ipsec_encap_des_aes_xcbc(uint32_t *descbuf,PROGRAM_CNTXT_INIT (p, descbuf,0 ); phdr =SHR_HDR (p, share, hdr,0 );__rta_copy_ipsec_encap_pdb (p, pdb, cipherdata->algtype); -COPY_DATA (p, pdb->ip_hdr, pdb->ip_hdr_len); +SET_LABEL (p, hdr); pkeyjump =JUMP (p, keyjump,LOCAL_JUMP ,ALL_TRUE ,SHRD |SELF );/*
Signature · 1 line
2.42.0
RE: [PATCH v4 10/10] common/dpaxx: remove zero length array
Quoted 24 lines
There is a place holder zero length array in this driver. But since the structure is embedded in other structures, it could not have been safely used anyway.
There doesn't appear to be any uses of it in the current code.Signed-off-by Stephen Hemminger <[email protected]>--- drivers/common/dpaax/caamflib/desc/ipsec.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/common/dpaax/caamflib/desc/ipsec.h +0
-1@@ -336,7 +336,6 @@ struct ipsec_encap_gcm {* @ip_hdr_len: optional IP Header length (in bytes) * reserved - 16b * Opt. IP Hdr Len - 16b -* @ip_hdr: optional IP Header content (only for IPsec legacy mode) */ struct ipsec_encap_pdb {uint32_t options;
drivers/common/dpaax/caamflib/desc/ipsec.h struct ipsec_encap_pdb { · line 353
Quoted 4 lines
drivers/common/dpaax/caamflib/desc/ipsec.h +0
-1@@ -350,7 +349,6 @@ struct ipsec_encap_pdb { };uint32_t spi;uint32_t ip_hdr_len; -uint8_t ip_hdr[0 ];
[Hemant] This should be replaced with
uint8_t ip_hdr[];
drivers/common/dpaax/caamflib/desc/ipsec.h cnstr_shdsc_ipsec_encap(uint32_t *descbuf, bool ps, · line 778
Quoted 10 lines
drivers/common/dpaax/caamflib/desc/ipsec.h +1
-1}; static inline unsigned int@@ -776,7 +774,7 @@ cnstr_shdsc_ipsec_encap(uint32_t *descbuf, bool ps,bool swap,PROGRAM_SET_36BIT_ADDR (p ); phdr =SHR_HDR (p, share, hdr,0 );__rta_copy_ipsec_encap_pdb (p, pdb, cipherdata->algtype); -COPY_DATA (p, pdb->ip_hdr, pdb->ip_hdr_len); +
[Hemant] Don't remove it. It will break the code.
drivers/common/dpaax/caamflib/desc/ipsec.h cnstr_shdsc_ipsec_encap_des_aes_xcbc(uint32_t · line 915
Quoted 10 lines
drivers/common/dpaax/caamflib/desc/ipsec.h +0
-0SET_LABEL (p, hdr); pkeyjmp =JUMP (p, keyjmp,LOCAL_JUMP ,ALL_TRUE ,BOTH |SHRD );drivers/common/dpaax/caamflib/desc/ipsec.h +1
-1if (authdata->keylen)@@ -913,7 +911,7 @@ cnstr_shdsc_ipsec_encap_des_aes_xcbc(uint32_t *descbuf,PROGRAM_CNTXT_INIT (p, descbuf,0 ); phdr =SHR_HDR (p, share, hdr,0 );__rta_copy_ipsec_encap_pdb (p, pdb, cipherdata->algtype); -COPY_DATA (p, pdb->ip_hdr, pdb->ip_hdr_len); +
[Hemant] Don't remove it
Quoted 6 lines
drivers/common/dpaax/caamflib/desc/ipsec.h +0
-0SET_LABEL (p, hdr); pkeyjump = JUMP(p, keyjump, LOCAL_JUMP, ALL_TRUE, SHRD |SELF);
/*
--
2.42.0
Re: [PATCH v4 10/10] common/dpaxx: remove zero length array
Quoted 11 lines · On Tue, 21 Nov 2023 10:49:59 +0000 Hemant Agrawal <[email protected]>…
drivers/common/dpaax/caamflib/desc/ipsec.h struct ipsec_encap_pdb { · line 353
Quoted 7 lines
struct
ipsec_encap_pdb{drivers/common/dpaax/caamflib/desc/ipsec.h +0
-1uint32_t options;@@ -350,7 +349,6 @@ struct ipsec_encap_pdb { };uint32_t spi;uint32_t ip_hdr_len; -uint8_t ip_hdr[0 ];[Hemant] This should be replaced with
uint8_t ip_hdr[];Quoted 2 lines
(quoted diff) +0
-0};
That won't work because the structure is embedded in another struct and then clang will correctly report an error.
Re: [PATCH v4 10/10] common/dpaxx: remove zero length array
Quoted 12 lines · On Tue, 21 Nov 2023 08:46:41 -0800 Stephen Hemminger…
Quoted 9 lines · On Tue, 21 Nov 2023 10:49:59 +0000 Hemant Agrawal <[email protected]>…
drivers/common/dpaax/caamflib/desc/ipsec.h struct ipsec_encap_pdb { · line 353
Quoted 7 lines
struct
ipsec_encap_pdb{drivers/common/dpaax/caamflib/desc/ipsec.h +0
-1uint32_t options;@@ -350,7 +349,6 @@ struct ipsec_encap_pdb { };uint32_t spi;uint32_t ip_hdr_len; -uint8_t ip_hdr[0 ];[Hemant] This should be replaced with
uint8_t ip_hdr[];
Quoted 5 lines
Quoted 2 lines
Review struct ipsec_encap_pdb { · line 353
Quoted 2 lines
(quoted diff) +0
-0};That won't work because the structure is embedded in another struct and then clang will correctly report an error.
[2155/2868] Compiling C object drivers..._jr.a.p/crypto_caam_jr_caam_jr_uio.c.o
In file included from ../drivers/crypto/caam_jr/caam_jr_uio.c:23:../drivers/crypto/caam_jr/caam_jr_pvt.h:139:25: warning: field 'encap_pdb' with variable sized type 'struct ipsec_encap_pdb' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct ipsec_encap_pdb encap_pdb;
^1 warning generated.
[2160/2868] Compiling C object drivers...m_jr.a.p/crypto_caam_jr_caam_jr_hw.c.o
In file included from ../drivers/crypto/caam_jr/caam_jr_hw.c:16:../drivers/crypto/caam_jr/caam_jr_pvt.h:139:25: warning: field 'encap_pdb' with variable sized type 'struct ipsec_encap_pdb' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct ipsec_encap_pdb encap_pdb;
^1 warning generated.
[2174/2868] Compiling C object drivers....p/crypto_dpaa_sec_dpaa_sec_raw_dp.c.o
In file included from ../drivers/crypto/dpaa_sec/dpaa_sec_raw_dp.c:17:../drivers/crypto/dpaa_sec/dpaa_sec.h:190:27: warning: field 'encap_pdb' with variable sized type 'struct ipsec_encap_pdb' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct ipsec_encap_pdb encap_pdb;
^1 warning generated.
[2176/2868] Compiling C object drivers...caam_jr.a.p/crypto_caam_jr_caam_jr.c.o
In file included from ../drivers/crypto/caam_jr/caam_jr.c:23:../drivers/crypto/caam_jr/caam_jr_pvt.h:139:25: warning: field 'encap_pdb' with variable sized type 'struct ipsec_encap_pdb' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct ipsec_encap_pdb encap_pdb;
^1 warning generated.
[2246/2868] Compiling C object drivers...a_sec.a.p/crypto_dpaa_sec_dpaa_sec.c.o
In file included from ../drivers/crypto/dpaa_sec/dpaa_sec.c:43:../drivers/crypto/dpaa_sec/dpaa_sec.h:190:27: warning: field 'encap_pdb' with variable sized type 'struct ipsec_encap_pdb' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct ipsec_encap_pdb encap_pdb;
^1 warning generated.
Re: [PATCH v4 10/10] common/dpaxx: remove zero length array
In reply to Stephen HemmingerQuoted 12 lines · Stephen Hemminger
Quoted 9 lines · On Tue, 21 Nov 2023 10:49:59 +0000 Hemant Agrawal <[email protected]>…
drivers/common/dpaax/caamflib/desc/ipsec.h struct ipsec_encap_pdb { · line 353
Quoted 7 lines
struct
ipsec_encap_pdb{drivers/common/dpaax/caamflib/desc/ipsec.h +0
-1uint32_t options;@@ -350,7 +349,6 @@ struct ipsec_encap_pdb { };uint32_t spi;uint32_t ip_hdr_len; -uint8_t ip_hdr[0 ];[Hemant] This should be replaced with
uint8_t ip_hdr[];
Quoted 5 lines
Quoted 2 lines
Review struct ipsec_encap_pdb { · line 353
Quoted 2 lines
(quoted diff) +0
-0};That won't work because the structure is embedded in another struct and then clang will correctly report an error.
Hemant if the field is not referenced what's the harm in removing it?
RE: [PATCH v4 10/10] common/dpaxx: remove zero length array
Quoted 24 lines
-----Original Message-----
From: Tyler Retzlaff <[email protected]>
Sent: Tuesday, November 21, 2023 10:49 PM
To: Stephen Hemminger <[email protected]>
Cc: Hemant Agrawal <[email protected]>; [email protected]; Sachin Saxena <[email protected]>; Gagandeep Singh <[email protected]>
Subject: Re: [PATCH v4 10/10] common/dpaxx: remove zero length array
Importance: HighQuoted 12 lines · Stephen Hemminger
Quoted 9 lines · On Tue, 21 Nov 2023 10:49:59 +0000 Hemant Agrawal <[email protected]>…
drivers/common/dpaax/caamflib/desc/ipsec.h struct ipsec_encap_pdb { · line 353
Quoted 7 lines
struct
ipsec_encap_pdb{drivers/common/dpaax/caamflib/desc/ipsec.h +0
-1uint32_t options;@@ -350,7 +349,6 @@ struct ipsec_encap_pdb { };uint32_t spi;uint32_t ip_hdr_len; -uint8_t ip_hdr[0 ];[Hemant] This should be replaced with
uint8_t ip_hdr[];
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Review struct ipsec_encap_pdb { · line 353
Quoted 2 lines
(quoted diff) +0
-0};That won't work because the structure is embedded in another struct and then clang will correctly report an error.
Hemant if the field is not referenced what's the harm in removing it?
It is being used indirectly, e.g. dpaa_sec.h usages it for ip address description preparation for the hardware.
struct ipsec_encap_pdb encap_pdb;
union {
struct ip ip4_hdr;
struct rte_ipv6_hdr ip6_hdr;
};We need to change it, however in the interim, I will like to add "-Wno-gnu-variable-sized-type-not-at-end" for both caam_jr and dpaa_sec to avoid this warning.
Re: [PATCH v4 10/10] common/dpaxx: remove zero length array
Quoted 32 lines · On Wed, 22 Nov 2023 07:23:36 +0000 Hemant Agrawal <[email protected]>…
Quoted 22 lines
-----Original Message-----
From: Tyler Retzlaff <[email protected]>
Sent: Tuesday, November 21, 2023 10:49 PM
To: Stephen Hemminger <[email protected]>
Cc: Hemant Agrawal <[email protected]>; [email protected]; Sachin Saxena <[email protected]>; Gagandeep Singh <[email protected]>
Subject: Re: [PATCH v4 10/10] common/dpaxx: remove zero length array
Importance: HighQuoted 12 lines · Stephen Hemminger
Quoted 9 lines · On Tue, 21 Nov 2023 10:49:59 +0000 Hemant Agrawal <[email protected]>…
drivers/common/dpaax/caamflib/desc/ipsec.h struct ipsec_encap_pdb { · line 353
Quoted 7 lines
struct
ipsec_encap_pdb{drivers/common/dpaax/caamflib/desc/ipsec.h +0
-1uint32_t options;@@ -350,7 +349,6 @@ struct ipsec_encap_pdb { };uint32_t spi;uint32_t ip_hdr_len; -uint8_t ip_hdr[0 ];[Hemant] This should be replaced with
uint8_t ip_hdr[];Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Review struct ipsec_encap_pdb { · line 353
Quoted 2 lines
(quoted diff) +0
-0};That won't work because the structure is embedded in another struct and then clang will correctly report an error.
Hemant if the field is not referenced what's the harm in removing it?
It is being used indirectly, e.g.
dpaa_sec.husages it for ip address description preparation for the hardware.
Quoted 7 lines
struct ipsec_encap_pdb encap_pdb; union { struct ip ip4_hdr; struct rte_ipv6_hdr ip6_hdr; };We need to change it, however in the interim, I will like to add "-Wno-gnu-variable-sized-type-not-at-end" for both
caam_jranddpaa_secto avoid this warning.
Ok, there are several ways to fix that. Driver specific compiler flags are the one that is least favored.
Re: [PATCH v4 10/10] common/dpaxx: remove zero length array
In reply to Hemant AgrawalThis is a better alternative.
From 52c805b9526dbef62377276c4499c997fbc96268 Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <[email protected]>
Date: Thu, 23 Nov 2023 11:12:02 -0800
Subject: [PATCH] common/dpaxx: replace zero length array
The zero length ip_header is used as an overlay to the encap IP header. Since the code is already assuming the layout of the structure, replace the array with direct access.
--- drivers/common/dpaax/caamflib/desc/ipsec.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/common/dpaax/caamflib/desc/ipsec.h +14 -6
@@ -334,9 +334,7 @@ struct ipsec_encap_gcm {* @seq_num: IPsec sequence number * @spi: IPsec SPI (Security Parameters Index) * @ip_hdr_len: optional IP Header length (in bytes) -* reserved - 16b -* Opt. IP Hdr Len - 16b -* @ip_hdr: optional IP Header content (only for IPsec legacy mode) +* Ip header must follow directly after ipsec_encap_pdb */ struct ipsec_encap_pdb {uint32_t options;
@@ -350,7 +348,6 @@ struct ipsec_encap_pdb { };uint32_t spi;uint32_t ip_hdr_len; -uint8_t ip_hdr[0 ]; }; static inline unsigned int
@@ -776,7 +773,12 @@ cnstr_shdsc_ipsec_encap(uint32_t *descbuf, bool ps, bool swap,PROGRAM_SET_36BIT_ADDR (p); phdr =SHR_HDR (p, share, hdr,0 );__rta_copy_ipsec_encap_pdb (p, pdb, cipherdata->algtype); -COPY_DATA (p, pdb->ip_hdr, pdb->ip_hdr_len); + +/* ip header if any follows the encap_pdb */ +if (pdb->ip_hdr_len >0 ) { +void *ip_hdr = pdb +1 ; +COPY_DATA (p, ip_hdr, pdb->ip_hdr_len); + }SET_LABEL (p, hdr); pkeyjmp =JUMP (p, keyjmp,LOCAL_JUMP ,ALL_TRUE ,BOTH |SHRD );if (authdata->keylen)
@@ -913,7 +915,13 @@ cnstr_shdsc_ipsec_encap_des_aes_xcbc(uint32_t *descbuf,PROGRAM_CNTXT_INIT (p, descbuf,0 ); phdr =SHR_HDR (p, share, hdr,0 );__rta_copy_ipsec_encap_pdb (p, pdb, cipherdata->algtype); -COPY_DATA (p, pdb->ip_hdr, pdb->ip_hdr_len); + +/* ip header if any follows the encap_pdb */ +if (pdb->ip_hdr_len >0 ) { +void *ip_hdr = pdb +1 ; +COPY_DATA (p, ip_hdr, pdb->ip_hdr_len); + } +SET_LABEL (p, hdr); pkeyjump =JUMP (p, keyjump,LOCAL_JUMP ,ALL_TRUE ,SHRD |SELF );/*
Signature · 1 line
2.42.0
Hemant Agrawal
Acked-byRE: [PATCH v4 10/10] common/dpaxx: remove zero length array
Quoted 84 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Friday, November 24, 2023 12:49 AM
To: Hemant Agrawal <[email protected]>
Cc: Tyler Retzlaff <[email protected]>; [email protected]; Sachin Saxena <[email protected]>; Gagandeep Singh <[email protected]>
Subject: Re: [PATCH v4 10/10] common/dpaxx: remove zero length array
Importance: HighThis is a better alternative.
From
52c805b9526dbef62377276c4499c997fbc96268Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <[email protected]>
Date: Thu, 23 Nov 2023 11:12:02 -0800
Subject: [PATCH] common/dpaxx: replace zero length arrayThe zero length
ip_headeris used as an overlay to the encap IP header. Since the code is already assuming the layout of the structure, replace the array with direct access.Signed-off-by Stephen Hemminger <[email protected]>--- drivers/common/dpaax/caamflib/desc/ipsec.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)drivers/common/dpaax/caamflib/desc/ipsec.h +7
-5@@ -334,9 +334,7 @@ struct ipsec_encap_gcm {* @seq_num: IPsec sequence number * @spi: IPsec SPI (Security Parameters Index) * @ip_hdr_len: optional IP Header length (in bytes) -* reserved - 16b -* Opt. IP Hdr Len - 16b -* @ip_hdr: optional IP Header content (only for IPsec legacy mode) +* Ip header must follow directly after ipsec_encap_pdb */ struct ipsec_encap_pdb {uint32_t options;@@ -350,7 +348,6 @@ struct ipsec_encap_pdb { };uint32_t spi;uint32_t ip_hdr_len; -uint8_t ip_hdr[0 ]; }; static inline unsigned int@@ -776,7 +773,12 @@ cnstr_shdsc_ipsec_encap(uint32_t *descbuf, bool ps, bool swap,PROGRAM_SET_36BIT_ADDR (p); phdr =SHR_HDR (p, share, hdr,0 );__rta_copy_ipsec_encap_pdb (p, pdb, cipherdata->algtype); -COPY_DATA (p, pdb->ip_hdr, pdb->ip_hdr_len); + +/* ip header if any follows the encap_pdb */ +if (pdb->ip_hdr_len >0 ) { +void *ip_hdr = pdb +1 ; +COPY_DATA (p, ip_hdr, pdb->ip_hdr_len); + }SET_LABEL (p, hdr); pkeyjmp =JUMP (p, keyjmp,LOCAL_JUMP ,ALL_TRUE ,BOTH |SHRD );drivers/common/dpaax/caamflib/desc/ipsec.h +7
-1if (authdata->keylen)@@ -913,7 +915,13 @@ cnstr_shdsc_ipsec_encap_des_aes_xcbc(uint32_t *descbuf,PROGRAM_CNTXT_INIT (p, descbuf,0 ); phdr =SHR_HDR (p, share, hdr,0 );__rta_copy_ipsec_encap_pdb (p, pdb, cipherdata->algtype); -COPY_DATA (p, pdb->ip_hdr, pdb->ip_hdr_len); + +/* ip header if any follows the encap_pdb */ +if (pdb->ip_hdr_len >0 ) { +void *ip_hdr = pdb +1 ; +COPY_DATA (p, ip_hdr, pdb->ip_hdr_len); + } +SET_LABEL (p, hdr); pkeyjump = JUMP(p, keyjump, LOCAL_JUMP, ALL_TRUE, SHRD |SELF);
/*
--
2.42.0
RE: [PATCH v4 00/10] Replace zero length arrays
In reply to Stephen HemmingerQuoted 6 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Monday, 20 November 2023 18.07Zero length arrays are a GNU extension that has been superseded by flex arrays.
Quoted 7 lines
https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
These are places found by
cocci/zero_length_array.cocciv4 - fix issues reported by clang where zero length
array was embedded in security structures in cn10k and txq being embedded in mlx5 was missing extension
Thanks for cleaning this up.
Re: [PATCH v4 00/10] Replace zero length arrays
Quoted 18 lines · Morten Brørup
Quoted 6 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Monday, 20 November 2023 18.07Zero length arrays are a GNU extension that has been superseded by flex arrays.
Quoted 7 lines
https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
These are places found by
cocci/zero_length_array.cocciv4 - fix issues reported by clang where zero length
array was embedded in security structures in cn10k and txq being embedded in mlx5 was missing extensionThanks for cleaning this up.
Series-acked-by Morten Brørup <[email protected]>
v5 cover Replace zero length arrays
In reply to Stephen HemmingerZero length arrays are a GNU extension that has been superseded by flex arrays.
https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
These are places found by cocci/zero_length_array.cocci
v5 - revised version of dpaxx ip_hdr fix
rebase to 23.11
Stephen Hemminger (10):
member: replace zero length array with flex array
cryptodev: replace zero length array with flex array
security: replace zero length array with flex array
pipeline: replace zero length array with flex array net/nfp: replace zero length array with flex array net/enic: replace zero length array with flex array net/mlx5: replace zero length array with flex array
pdcp: replace zero length array with flex array net/cpfl: replace zero length array with flex array common/dpaxx: replace zero length array
drivers/common/dpaax/caamflib/desc/ipsec.h | 20 ++++++++++++++------ drivers/common/mlx5/mlx5_prm.h | 2 +- drivers/crypto/cnxk/cn10k_ipsec.h | 4 +++- drivers/crypto/cnxk/cn9k_ipsec.h | 4 +++- drivers/crypto/cnxk/cnxk_se.h | 5 ++++- drivers/net/cpfl/cpfl_flow_engine_fxp.c | 2 +- drivers/net/enic/base/vnic_devcmd.h | 2 +- drivers/net/mlx5/mlx5.h | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 2 +- drivers/net/mlx5/mlx5_tx.h | 3 ++- drivers/net/nfp/flower/nfp_flower_cmsg.h | 2 +- lib/cryptodev/cryptodev_pmd.h | 2 +- lib/member/rte_member_heap.h | 2 +- lib/pdcp/pdcp_entity.h | 2 +- lib/pipeline/rte_swx_pipeline_internal.h | 2 +- lib/security/rte_security_driver.h | 2 +- 16 files changed, 38 insertions(+), 22 deletions(-)
Signature · 1 line
2.42.0
PATCH v5 1/10 member: replace zero length array with flex array
Zero length arrays are GNU extension. Replace with standard flex array.
--- lib/member/rte_member_heap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/member/rte_member_heap.h +1 -1
@@ -26,7 +26,7 @@ struct hash {uint16_t bkt_cnt;uint16_t num_item;uint32_t seed; -struct hash_bkt buckets[0 ]; +struct hash_bkt buckets[]; };struct node {
Signature · 1 line
2.42.0
PATCH v5 2/10 cryptodev: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- drivers/crypto/cnxk/cnxk_se.h | 5 ++++- lib/cryptodev/cryptodev_pmd.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/crypto/cnxk/cnxk_se.h +4 -1
@@ -29,8 +29,11 @@ enum cpt_dp_thread_type { CPT_DP_THREAD_TYPE_PT, }; +#define SYM_SESS_SIZE sizeof(struct rte_cryptodev_sym_session) +struct cnxk_se_sess { -struct rte_cryptodev_sym_session rte_sess; +uint8_t rte_sess[SYM_SESS_SIZE ]; +uint8_t aes_gcm :1 ;uint8_t aes_ccm :1 ;uint8_t aes_ctr :1 ;
lib/cryptodev/cryptodev_pmd.h +1 -1
@@ -153,7 +153,7 @@ struct rte_cryptodev_sym_session { RTE_MARKER cacheline1 __rte_cache_min_aligned;/**< Second cache line - start of the driver session data */ -uint8_t driver_priv_data[0 ]; +uint8_t driver_priv_data[];/**< Driver specific session data, variable size */ };
Signature · 1 line
2.42.0
PATCH v5 3/10 security: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- drivers/crypto/cnxk/cn10k_ipsec.h | 4 +++- drivers/crypto/cnxk/cn9k_ipsec.h | 4 +++- lib/security/rte_security_driver.h | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-)
drivers/crypto/cnxk/cn10k_ipsec.h +3 -1
@@ -24,8 +24,10 @@ struct cn10k_ipsec_sa { }; }__rte_aligned (ROC_ALIGN ); +#define SEC_SESS_SIZE sizeof(struct rte_security_session) +struct cn10k_sec_session { -struct rte_security_session rte_sess; +uint8_t rte_sess[SEC_SESS_SIZE ];/** PMD private space */
drivers/crypto/cnxk/cn9k_ipsec.h +3 -1
@@ -20,8 +20,10 @@ struct cn9k_ipsec_sa { }; }__rte_aligned (8 ); +#define SEC_SESS_SIZE sizeof(struct rte_security_session) +struct cn9k_sec_session { -struct rte_security_session rte_sess; +uint8_t rte_sess[SEC_SESS_SIZE ];/** PMD private space */
lib/security/rte_security_driver.h +1 -1
@@ -33,7 +33,7 @@ struct rte_security_session {/**< session private data IOVA address */ RTE_MARKER cacheline1 __rte_cache_min_aligned; -uint8_t driver_priv_data[0 ]; +uint8_t driver_priv_data[];/**< Private session material, variable size (depends on driver) */ };
Signature · 1 line
2.42.0
PATCH v5 4/10 pipeline: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- lib/pipeline/rte_swx_pipeline_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/pipeline/rte_swx_pipeline_internal.h +1 -1
@@ -213,7 +213,7 @@ TAILQ_HEAD(rss_tailq, rss);struct rss_runtime {uint32_t key_size;/* key size in bytes. */ -uint8_t key[0 ];/* key. */ +uint8_t key[];/* key. */ };/*
Signature · 1 line
2.42.0
PATCH v5 5/10 net/nfp: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- drivers/net/nfp/flower/nfp_flower_cmsg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/nfp/flower/nfp_flower_cmsg.h +1 -1
@@ -73,7 +73,7 @@ struct nfp_flower_cmsg_mac_repr {uint8_t info;uint8_t nbi_port;uint8_t phys_port; - } ports[0 ]; + } ports[]; };/*
Signature · 1 line
2.42.0
RE: [PATCH v5 05/10] net/nfp: replace zero length array with flex array
Looks good to me, thanks.
Quoted 35 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Wednesday, November 29, 2023 10:39 AM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>; Niklas Söderlund <[email protected]>; Tyler Retzlaff <[email protected]>; Chaoyong He <[email protected]>
Subject: [PATCH v5 05/10] net/nfp: replace zero length array with flex arrayZero length arrays are GNU extension. Replace with standard flex array.
Signed-off-by Stephen Hemminger <[email protected]>Acked-by Niklas Söderlund <[email protected]>Reviewed-by Tyler Retzlaff <[email protected]>Acked-by Chaoyong He <[email protected]>--- drivers/net/nfp/flower/nfp_flower_cmsg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/nfp/flower/nfp_flower_cmsg.h +1
-2@@ -73,7 +73,7 @@ struct nfp_flower_cmsg_mac_repr {uint8_t info;uint8_t nbi_port;uint8_t phys_port; - } ports[0 ]; + } ports[]; };/* -- 2.42.0
PATCH v5 6/10 net/enic: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- drivers/net/enic/base/vnic_devcmd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/enic/base/vnic_devcmd.h +1 -1
@@ -765,7 +765,7 @@ struct vnic_devcmd_notify {struct vnic_devcmd_provinfo {uint8_t oui[3 ];uint8_t type; -uint8_t data[0 ]; +uint8_t data[]; };/*
Signature · 1 line
2.42.0
PATCH v5 7/10 net/mlx5: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- drivers/common/mlx5/mlx5_prm.h | 2 +- drivers/net/mlx5/mlx5.h | 4 ++-- drivers/net/mlx5/mlx5_flow.h | 2 +- drivers/net/mlx5/mlx5_tx.h | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-)
drivers/common/mlx5/mlx5_prm.h +1 -1
@@ -5181,7 +5181,7 @@ struct mlx5_ifc_flow_context_bits {u8 reserved_at_e0[0x40 ];u8 encrypt_decrypt_obj_id[0x20 ];u8 reserved_at_140[0x16c0 ]; -union mlx5_ifc_dest_format_flow_counter_list_auto_bits destination[0 ]; +union mlx5_ifc_dest_format_flow_counter_list_auto_bits destination[]; };struct mlx5_ifc_set_fte_in_bits {
drivers/net/mlx5/mlx5.h +2 -2
@@ -1314,7 +1314,7 @@ struct mlx5_aso_ct_pool { };struct mlx5_aso_sq *sq;/* Async ASO SQ. */ struct mlx5_aso_sq *shared_sq;/* Shared ASO SQ. */ -struct mlx5_aso_ct_action actions[0 ]; +struct mlx5_aso_ct_action actions[];/* CT action structures bulk. */ };
@@ -1331,7 +1331,7 @@ struct mlx5_aso_ct_pools_mng {rte_spinlock_t ct_sl;/* The ASO CT free list lock. */ rte_rwlock_t resize_rwl;/* The ASO CT pool resize lock. */ struct aso_ct_list free_cts;/* Free ASO CT objects list. */ -struct mlx5_aso_sq aso_sqs[0 ];/* ASO queue objects. */ +struct mlx5_aso_sq aso_sqs[];/* ASO queue objects. */ };#ifdef PEDANTIC
drivers/net/mlx5/mlx5_flow.h +1 -1
@@ -1257,7 +1257,7 @@ struct rte_flow_hw {cnt_id_t cnt_id;uint32_t mtr_id;uint32_t rule_idx; -uint8_t rule[0 ];/* HWS layer data struct. */ +uint8_t rule[];/* HWS layer data struct. */ } __rte_packed;#ifdef PEDANTIC
drivers/net/mlx5/mlx5_tx.h +2 -1
@@ -171,11 +171,12 @@ struct mlx5_txq_data {struct mlx5_txq_stats stats;/* TX queue counters. */ struct mlx5_txq_stats stats_reset;/* stats on last reset. */ struct mlx5_uar_data uar_data; -struct rte_mbuf *elts[0 ]; +struct rte_mbuf *elts[];/* Storage for queued packets, must be the last field. */ } __rte_cache_aligned;/* TX queue control descriptor. */ +__extension__ struct mlx5_txq_ctrl { LIST_ENTRY(mlx5_txq_ctrl) next; /* Pointer to the next element. */ uint32_t refcnt; /* Reference counter. */
Signature · 1 line
2.42.0
Re: [PATCH v5 07/10] net/mlx5: replace zero length array with flex array
29/11/2023 03:39, Stephen Hemminger:
Quoted 4 lines
drivers/net/mlx5/mlx5_tx.h +0
-0@@ -171,11 +171,12 @@ struct mlx5_txq_data {struct mlx5_txq_stats stats;/* TX queue counters. */
drivers/net/mlx5/mlx5_tx.h struct mlx5_txq_data { · line 180
Quoted 10 lines
drivers/net/mlx5/mlx5_tx.h +2
-1struct mlx5_txq_stats stats_reset;/* stats on last reset. */ struct mlx5_uar_data uar_data; -struct rte_mbuf *elts[0 ]; +struct rte_mbuf *elts[];/* Storage for queued packets, must be the last field. */ } __rte_cache_aligned;/* TX queue control descriptor. */ +__extension__ struct mlx5_txq_ctrl {
struct mlx5_txq_data is included at the end of struct mlx5_txq_ctrl I don't understand why we need to declare an extension here.
Re: [PATCH v5 07/10] net/mlx5: replace zero length array with flex array
23/01/2024 10:44, Thomas Monjalon:
Quoted 12 lines
29/11/2023 03:39, Stephen Hemminger:
Quoted 11 lines
drivers/net/mlx5/mlx5_tx.h +1
-1@@ -171,11 +171,12 @@ struct mlx5_txq_data {struct mlx5_txq_stats stats;/* TX queue counters. */ struct mlx5_txq_stats stats_reset;/* stats on last reset. */ struct mlx5_uar_data uar_data; -struct rte_mbuf *elts[0 ]; +struct rte_mbuf *elts[];/* Storage for queued packets, must be the last field. */ } __rte_cache_aligned;
Quoted 6 lines
drivers/net/mlx5/mlx5_tx.h struct mlx5_txq_data { · line 180
Quoted 3 lines
drivers/net/mlx5/mlx5_tx.h +1
-0/* TX queue control descriptor. */ +__extension__ struct mlx5_txq_ctrl {struct
mlx5_txq_datais included at the end of structmlx5_txq_ctrlI don't understand why we need to declare an extension here.
If I remove __extension__:
error: invalid use of structure with flexible array member [-Werror=pedantic]
Is it a problem only in pedantic mode?
RE: [PATCH v5 07/10] net/mlx5: replace zero length array with flex array
From: Thomas Monjalon <[email protected]>
Sent: Tuesday, January 23, 2024 11:28
Quoted 20 lines
23/01/2024 10:44, Thomas Monjalon:
Quoted 12 lines
29/11/2023 03:39, Stephen Hemminger:
Quoted 11 lines
drivers/net/mlx5/mlx5_tx.h +1
-1@@ -171,11 +171,12 @@ struct mlx5_txq_data {struct mlx5_txq_stats stats;/* TX queue counters. */ struct mlx5_txq_stats stats_reset;/* stats on last reset. */ struct mlx5_uar_data uar_data; -struct rte_mbuf *elts[0 ]; +struct rte_mbuf *elts[];/* Storage for queued packets, must be the last field. */ } __rte_cache_aligned;Quoted 6 lines
drivers/net/mlx5/mlx5_tx.h struct mlx5_txq_data { · line 180
Quoted 3 lines
drivers/net/mlx5/mlx5_tx.h +1
-0/* TX queue control descriptor. */ +__extension__ struct mlx5_txq_ctrl {struct
mlx5_txq_datais included at the end of structmlx5_txq_ctrlI don't understand why we need to declare an extension here.
Quoted 4 lines
If I remove
__extension__:
error: invalid use of structure with flexible array member [-Werror=pedantic]Is it a problem only in pedantic mode?
Yes, because this usage is nonstandard. Using a struct which has a flexible array member, inside another struct is a compiler extension.
Best regards,
Dariusz Sosnowski
PATCH v5 8/10 pdcp: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- lib/pdcp/pdcp_entity.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/pdcp/pdcp_entity.h +1 -1
@@ -185,7 +185,7 @@ struct entity_priv_dl_part {/** Reorder packet buffer */ struct pdcp_reorder reorder;/** Bitmap memory region */ -uint8_t bitmap_mem[0 ]; +uint8_t bitmap_mem[]; };struct entity_priv_ul_part {
Signature · 1 line
2.42.0
PATCH v5 9/10 net/cpfl: replace zero length array with flex array
In reply to Stephen HemmingerZero length arrays are GNU extension. Replace with standard flex array.
--- drivers/net/cpfl/cpfl_flow_engine_fxp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/cpfl/cpfl_flow_engine_fxp.c +1 -1
@@ -53,7 +53,7 @@ struct cpfl_rule_info_meta {uint32_t pr_num;/* number of pattern rules */ uint32_t mr_num;/* number of modification rules */ uint32_t rule_num;/* number of all rules */ -struct cpfl_rule_info rules[0 ]; +struct cpfl_rule_info rules[]; };static uint32_t cpfl_fxp_mod_idx_alloc (struct cpfl_adapter_ext *ad);
Signature · 1 line
2.42.0
PATCH v5 10/10 common/dpaxx: replace zero length array
In reply to Stephen HemmingerThe zero length ip_header is used as an overlay to the encap IP header. Since the code is already assuming the layout of the structure, replace the array with direct access.
--- drivers/common/dpaax/caamflib/desc/ipsec.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/common/dpaax/caamflib/desc/ipsec.h +14 -6
@@ -334,9 +334,7 @@ struct ipsec_encap_gcm {* @seq_num: IPsec sequence number * @spi: IPsec SPI (Security Parameters Index) * @ip_hdr_len: optional IP Header length (in bytes) -* reserved - 16b -* Opt. IP Hdr Len - 16b -* @ip_hdr: optional IP Header content (only for IPsec legacy mode) +* Ip header must follow directly after ipsec_encap_pdb */ struct ipsec_encap_pdb {uint32_t options;
@@ -350,7 +348,6 @@ struct ipsec_encap_pdb { };uint32_t spi;uint32_t ip_hdr_len; -uint8_t ip_hdr[0 ]; }; static inline unsigned int
@@ -776,7 +773,12 @@ cnstr_shdsc_ipsec_encap(uint32_t *descbuf, bool ps, bool swap,PROGRAM_SET_36BIT_ADDR (p); phdr =SHR_HDR (p, share, hdr,0 );__rta_copy_ipsec_encap_pdb (p, pdb, cipherdata->algtype); -COPY_DATA (p, pdb->ip_hdr, pdb->ip_hdr_len); + +/* ip header if any follows the encap_pdb */ +if (pdb->ip_hdr_len >0 ) { +void *ip_hdr = pdb +1 ; +COPY_DATA (p, ip_hdr, pdb->ip_hdr_len); + }SET_LABEL (p, hdr); pkeyjmp =JUMP (p, keyjmp,LOCAL_JUMP ,ALL_TRUE ,BOTH |SHRD );if (authdata->keylen)
@@ -913,7 +915,13 @@ cnstr_shdsc_ipsec_encap_des_aes_xcbc(uint32_t *descbuf,PROGRAM_CNTXT_INIT (p, descbuf,0 ); phdr =SHR_HDR (p, share, hdr,0 );__rta_copy_ipsec_encap_pdb (p, pdb, cipherdata->algtype); -COPY_DATA (p, pdb->ip_hdr, pdb->ip_hdr_len); + +/* ip header if any follows the encap_pdb */ +if (pdb->ip_hdr_len >0 ) { +void *ip_hdr = pdb +1 ; +COPY_DATA (p, ip_hdr, pdb->ip_hdr_len); + } +SET_LABEL (p, hdr); pkeyjump =JUMP (p, keyjump,LOCAL_JUMP ,ALL_TRUE ,SHRD |SELF );/*
Signature · 1 line
2.42.0
Re: [PATCH v5 10/10] common/dpaxx: replace zero length array
29/11/2023 03:39, Stephen Hemminger:
Quoted 1 line
+ * Ip header must follow directly after
ipsec_encap_pdb
[...]
Quoted 2 lines
(quoted diff) +2
-0+ + /* ip header if any follows the encap_pdb */
[...]
Review
Quoted 1 line
(quoted diff) +1
-0+ /* ip header if any follows the encap_pdb */
I would change "ip" to "IP".
Thomas Monjalon
AppliedRe: [PATCH v5 00/10] Replace zero length arrays
In reply to Stephen Hemminger29/11/2023 03:39, Stephen Hemminger:
Quoted 10 lines
Zero length arrays are a GNU extension that has been superseded by flex arrays.
https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
These are places found by
cocci/zero_length_array.cocciv5 - revised version of dpaxx
ip_hdrfixrebase to 23.11
Quoted 11 lines
Stephen Hemminger (10):
member: replace zero length array with flex array
cryptodev: replace zero length array with flex array
security: replace zero length array with flex array
pipeline: replace zero length array with flex array net/nfp: replace zero length array with flex array net/enic: replace zero length array with flex array net/mlx5: replace zero length array with flex array
pdcp: replace zero length array with flex array net/cpfl: replace zero length array with flex array common/dpaxx: replace zero length array
There is no more left with
devtools/cocci.sh devtools/cocci/zero_length_array.cocci
Applied, thanks.