]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Cleanup: Use C99 flexible array members instead of zero length arrays
authorRichard Yao <richard.yao@alumni.stonybrook.edu>
Tue, 10 Jan 2023 20:14:59 +0000 (15:14 -0500)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 12 Jan 2023 23:59:41 +0000 (15:59 -0800)
The Linux 5.16.14 kernel's coccicheck caught this. The semantic
patch that caught it was:

./scripts/coccinelle/misc/flexible_array.cocci

The Linux kernel's documentation makes a good case for why we should not
use these:

https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14372

module/os/linux/spl/spl-zone.c
module/os/linux/zfs/vdev_disk.c
module/zfs/dsl_scan.c

index b489179f1257754821089a0ed357caa7c2496120..e821fbb4f3a124777194c04a88360cba2355c1f6 100644 (file)
@@ -50,7 +50,7 @@ typedef struct zone_datasets {
 typedef struct zone_dataset {
        struct list_head zd_list;       /* zone_dataset linkage */
        size_t zd_dsnamelen;            /* length of name */
-       char zd_dsname[0];              /* name of the member dataset */
+       char zd_dsname[];               /* name of the member dataset */
 } zone_dataset_t;
 
 #if defined(CONFIG_USER_NS) && defined(HAVE_USER_NS_COMMON_INUM)
index 9e330e462eb06bc5e87685ea5219d675b1f9aa39..2b5c4956dd020d1e0b4b9c803931718233c0005d 100644 (file)
@@ -71,7 +71,7 @@ typedef struct dio_request {
        atomic_t                dr_ref;         /* References */
        int                     dr_error;       /* Bio error */
        int                     dr_bio_count;   /* Count of bio's */
-       struct bio              *dr_bio[0];     /* Attached bio's */
+       struct bio              *dr_bio[];      /* Attached bio's */
 } dio_request_t;
 
 /*
index c4b90991a4452fb6f04485ee0a74aa2b637e0bab..f9e437f0c9475617f2c6955f8cb10b474b4a7973 100644 (file)
@@ -281,7 +281,7 @@ typedef struct scan_io {
         * event of an error. This array must go at the end of the
         * struct to allow this for the variable number of elements.
         */
-       dva_t                   sio_dva[0];
+       dva_t                   sio_dva[];
 } scan_io_t;
 
 #define        SIO_SET_OFFSET(sio, x)          DVA_SET_OFFSET(&(sio)->sio_dva[0], x)