Message ID | 1609309731-70464-1-git-send-email-abaci-bugfix@linux.alibaba.com |
---|---|
State | New |
Headers | show |
Series | mlx4: style: replace zero-length array with flexible-array member. | expand |
On 12/30/2020 8:28 AM, YANG LI wrote: > There is a regular need in the kernel to provide a way to declare > having a dynamically sized set of trailing elements in a structure. > Kernel code should always use "flexible array members"[1] for these > cases. The older style of one-element or zero-length arrays should > no longer be used[2]. > > [1] https://en.wikipedia.org/wiki/Flexible_array_member > [2] https://www.kernel.org/doc/html/v5.9/process/ > deprecated.html#zero-length-and-one-element-arrays > > Signed-off-by: YANG LI <abaci-bugfix@linux.alibaba.com> > Reported-by: Abaci <abaci@linux.alibaba.com> > --- > drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h > index e8ed2319..4029a8b 100644 > --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h > +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h > @@ -314,7 +314,7 @@ struct mlx4_en_tx_ring { > > struct mlx4_en_rx_desc { > /* actual number of entries depends on rx ring stride */ > - struct mlx4_wqe_data_seg data[0]; > + struct mlx4_wqe_data_seg data[]; > }; > > struct mlx4_en_rx_ring { > Reviewed-by: Tariq Toukan <tariqt@nvidia.com> Thanks.
On Wed, 30 Dec 2020 14:28:51 +0800 YANG LI wrote: > There is a regular need in the kernel to provide a way to declare > having a dynamically sized set of trailing elements in a structure. > Kernel code should always use "flexible array members"[1] for these > cases. The older style of one-element or zero-length arrays should > no longer be used[2]. > > [1] https://en.wikipedia.org/wiki/Flexible_array_member > [2] https://www.kernel.org/doc/html/v5.9/process/ > deprecated.html#zero-length-and-one-element-arrays > > Signed-off-by: YANG LI <abaci-bugfix@linux.alibaba.com> > Reported-by: Abaci <abaci@linux.alibaba.com> This breaks the build with allmodconfig, could you double check? Are there dependencies? In file included from drivers/net/ethernet/mellanox/mlx4/en_netdev.c:50: drivers/net/ethernet/mellanox/mlx4/mlx4_en.h:316:27: error: flexible array member in a struct with no named members 316 | struct mlx4_wqe_data_seg data[]; | ^~~~
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h index e8ed2319..4029a8b 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h @@ -314,7 +314,7 @@ struct mlx4_en_tx_ring { struct mlx4_en_rx_desc { /* actual number of entries depends on rx ring stride */ - struct mlx4_wqe_data_seg data[0]; + struct mlx4_wqe_data_seg data[]; }; struct mlx4_en_rx_ring {
There is a regular need in the kernel to provide a way to declare having a dynamically sized set of trailing elements in a structure. Kernel code should always use "flexible array members"[1] for these cases. The older style of one-element or zero-length arrays should no longer be used[2]. [1] https://en.wikipedia.org/wiki/Flexible_array_member [2] https://www.kernel.org/doc/html/v5.9/process/ deprecated.html#zero-length-and-one-element-arrays Signed-off-by: YANG LI <abaci-bugfix@linux.alibaba.com> Reported-by: Abaci <abaci@linux.alibaba.com> --- drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)