All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mlx4: style: replace zero-length array with flexible-array member.
@ 2020-12-30  6:28 YANG LI
  2020-12-30  9:37 ` Tariq Toukan
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: YANG LI @ 2020-12-30  6:28 UTC (permalink / raw)
  To: kuba
  Cc: davem, tariqt, ast, daniel, hawk, john.fastabend, andrii, kafai,
	songliubraving, yhs, kpsingh, netdev, linux-rdma, linux-kernel,
	bpf, YANG LI

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 {
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mlx4: style: replace zero-length array with flexible-array member.
  2020-12-30  6:28 [PATCH] mlx4: style: replace zero-length array with flexible-array member YANG LI
@ 2020-12-30  9:37 ` Tariq Toukan
  2020-12-30 13:05 ` kernel test robot
  2021-01-04 20:40 ` Jakub Kicinski
  2 siblings, 0 replies; 4+ messages in thread
From: Tariq Toukan @ 2020-12-30  9:37 UTC (permalink / raw)
  To: YANG LI, kuba
  Cc: davem, ast, daniel, hawk, john.fastabend, andrii, kafai,
	songliubraving, yhs, kpsingh, netdev, linux-rdma, linux-kernel,
	bpf



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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mlx4: style: replace zero-length array with flexible-array member.
  2020-12-30  6:28 [PATCH] mlx4: style: replace zero-length array with flexible-array member YANG LI
  2020-12-30  9:37 ` Tariq Toukan
@ 2020-12-30 13:05 ` kernel test robot
  2021-01-04 20:40 ` Jakub Kicinski
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2020-12-30 13:05 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2519 bytes --]

Hi YANG,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on ipvs/master]
[also build test ERROR on linus/master sparc-next/master v5.11-rc1 next-20201223]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/YANG-LI/mlx4-style-replace-zero-length-array-with-flexible-array-member/20201230-143531
base:   https://git.kernel.org/pub/scm/linux/kernel/git/horms/ipvs.git master
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/9ba529666d9d11ec16093f038c0d325ebad98b01
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review YANG-LI/mlx4-style-replace-zero-length-array-with-flexible-array-member/20201230-143531
        git checkout 9ba529666d9d11ec16093f038c0d325ebad98b01
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from drivers/net/ethernet/mellanox/mlx4/en_main.c:44:
>> 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[];
         |                           ^~~~

Kconfig warnings: (for reference only)
   WARNING: unmet direct dependencies detected for FRAME_POINTER
   Depends on DEBUG_KERNEL && (M68K || UML || SUPERH) || ARCH_WANT_FRAME_POINTERS
   Selected by
   - FAULT_INJECTION_STACKTRACE_FILTER && FAULT_INJECTION_DEBUG_FS && STACKTRACE_SUPPORT && !X86_64 && !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM && !ARC && !X86


vim +316 drivers/net/ethernet/mellanox/mlx4/mlx4_en.h

   313	
   314	struct mlx4_en_rx_desc {
   315		/* actual number of entries depends on rx ring stride */
 > 316		struct mlx4_wqe_data_seg data[];
   317	};
   318	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 62931 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mlx4: style: replace zero-length array with flexible-array member.
  2020-12-30  6:28 [PATCH] mlx4: style: replace zero-length array with flexible-array member YANG LI
  2020-12-30  9:37 ` Tariq Toukan
  2020-12-30 13:05 ` kernel test robot
@ 2021-01-04 20:40 ` Jakub Kicinski
  2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2021-01-04 20:40 UTC (permalink / raw)
  To: YANG LI
  Cc: davem, tariqt, ast, daniel, hawk, john.fastabend, andrii, kafai,
	songliubraving, yhs, kpsingh, netdev, linux-rdma, linux-kernel,
	bpf

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[];
      |                           ^~~~

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-04 20:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-30  6:28 [PATCH] mlx4: style: replace zero-length array with flexible-array member YANG LI
2020-12-30  9:37 ` Tariq Toukan
2020-12-30 13:05 ` kernel test robot
2021-01-04 20:40 ` Jakub Kicinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.