mbox

[0/7] replace zero length arrays

Message ID 20230113215205.125767-1-stephen@networkplumber.org (mailing list archive)
Headers

Message

Stephen Hemminger Jan. 13, 2023, 9:51 p.m. UTC
  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(-)
  

Comments

Morten Brørup Nov. 17, 2023, 8:31 a.m. UTC | #1
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Friday, 17 November 2023 05.03
> 
> 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

Series-acked-by: Morten Brørup <mb@smartsharesystems.com>

Suggest checkpatches to disallow this, if it doesn't already.
  
Stephen Hemminger Nov. 17, 2023, 4:18 p.m. UTC | #2
On Fri, 17 Nov 2023 09:31:11 +0100
Morten Brørup <mb@smartsharesystems.com> wrote:

> Series-acked-by: Morten Brørup <mb@smartsharesystems.com>
> 
> 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.
  
Tyler Retzlaff Nov. 17, 2023, 7:59 p.m. UTC | #3
On Fri, Nov 17, 2023 at 08:18:23AM -0800, Stephen Hemminger wrote:
> On Fri, 17 Nov 2023 09:31:11 +0100
> Morten Brørup <mb@smartsharesystems.com> wrote:
> 
> > Series-acked-by: Morten Brørup <mb@smartsharesystems.com>
> > 
> > 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];
  
Morten Brørup Nov. 21, 2023, 7:26 a.m. UTC | #4
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Monday, 20 November 2023 18.07
> 
> 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
> 
> 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

Thanks for cleaning this up.

Series-acked-by: Morten Brørup <mb@smartsharesystems.com>
  
fengchengwen Nov. 21, 2023, 8:30 a.m. UTC | #5
Series-acked-by: Chengwen Feng <fengchengwen@huawei.com>

On 2023/11/21 15:26, Morten Brørup wrote:
>> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
>> Sent: Monday, 20 November 2023 18.07
>>
>> 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
>>
>> 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
> 
> Thanks for cleaning this up.
> 
> Series-acked-by: Morten Brørup <mb@smartsharesystems.com>
>
  
Thomas Monjalon Jan. 23, 2024, 10:48 a.m. UTC | #6
29/11/2023 03:39, Stephen Hemminger:
> 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
> 
> 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

There is no more left with
	devtools/cocci.sh devtools/cocci/zero_length_array.cocci

Applied, thanks.