[v5,07/10] net/mlx5: replace zero length array with flex array
Checks
Commit Message
Zero length arrays are GNU extension. Replace with
standard flex array.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
---
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(-)
Comments
29/11/2023 03:39, Stephen Hemminger:
> --- a/drivers/net/mlx5/mlx5_tx.h
> +++ b/drivers/net/mlx5/mlx5_tx.h
> @@ -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 {
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.
23/01/2024 10:44, Thomas Monjalon:
> 29/11/2023 03:39, Stephen Hemminger:
> > --- a/drivers/net/mlx5/mlx5_tx.h
> > +++ b/drivers/net/mlx5/mlx5_tx.h
> > @@ -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 {
>
> 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.
If I remove __extension__:
error: invalid use of structure with flexible array member [-Werror=pedantic]
Is it a problem only in pedantic mode?
From: Thomas Monjalon <thomas@monjalon.net>
Sent: Tuesday, January 23, 2024 11:28
> 23/01/2024 10:44, Thomas Monjalon:
> > 29/11/2023 03:39, Stephen Hemminger:
> > > --- a/drivers/net/mlx5/mlx5_tx.h
> > > +++ b/drivers/net/mlx5/mlx5_tx.h
> > > @@ -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 {
> >
> > 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.
>
> 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
@@ -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 {
@@ -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
@@ -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
@@ -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. */