Skip to contentSkip to conversation

main - gcc: use more zero length arrays

PATCH Zdenek Kabelac 1 participant 1 message Sep 23, 2021

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9eafd44734d32207dce7d0b0829e3c94c07d95c9
Commit:        9eafd44734d32207dce7d0b0829e3c94c07d95c9
Parent:        4515acf73430a8734f477b10ae6e3473d02999ae
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Wed Sep 22 17:05:09 2021 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Wed Sep 22 17:18:50 2021 +0200

gcc: use more zero length arrays

Define last array struct member with zero size.

---
 base/data-struct/hash.c       | 2 +-
 device_mapper/libdm-common.c  | 2 +-
 device_mapper/misc/dm-ioctl.h | 8 ++++----
 lib/activate/fs.c             | 2 +-
 lib/device/dev-cache.c        | 2 +-
 lib/label/label.c             | 2 +-
 libdm/datastruct/hash.c       | 2 +-
 libdm/libdm-common.c          | 2 +-
 libdm/misc/dm-ioctl.h         | 8 ++++----
 libdm/misc/dm-log-userspace.h | 2 +-
 10 files changed, 16 insertions(+), 16 deletions(-)
base/data-struct/hash.c +1 -1
index 5fee9cf85..db3dcd543 100644
@@ -23,7 +23,7 @@ struct dm_hash_node {
 	unsigned data_len;
 	unsigned keylen;
 	unsigned hash;
-	char key[];
+	char key[0];
 };
 
 struct dm_hash_table {
device_mapper/libdm-common.c +1 -1
index af2178e95..a90ece78a 100644
@@ -1445,7 +1445,7 @@ struct node_op_parms {
 	char *old_name;
 	int warn_if_udev_failed;
 	unsigned rely_on_udev;
-	char names[];
+	char names[0];
 };
 
 static void _store_str(char **pos, char **ptr, const char *str)
device_mapper/misc/dm-ioctl.h +4 -4
index 49954a764..cc2374c36 100644
@@ -183,7 +183,7 @@ struct dm_target_spec {
 struct dm_target_deps {
 	uint32_t count;	/* Array size */
 	uint32_t padding;	/* unused */
-	uint64_t dev[];		/* out */
+	uint64_t dev[0];	/* out */
 };
 
 /*
@@ -193,7 +193,7 @@ struct dm_name_list {
 	uint64_t dev;
 	uint32_t next;		/* offset to the next record from
 				   the _start_ of this */
-	char name[];
+	char name[0];
 };
 
 /*
@@ -203,7 +203,7 @@ struct dm_target_versions {
         uint32_t next;
         uint32_t version[3];
 
-        char name[];
+        char name[0];
 };
 
 /*
@@ -212,7 +212,7 @@ struct dm_target_versions {
 struct dm_target_msg {
 	uint64_t sector;	/* Device sector */
 
-	char message[];
+	char message[0];
 };
 
 /*
lib/activate/fs.c +1 -1
index 60ced8fb5..3e0692c9d 100644
@@ -313,7 +313,7 @@ struct fs_op_parms {
 	char *lv_name;
 	char *dev;
 	char *old_lv_name;
-	char names[];
+	char names[0];
 };
 
 static void _store_str(char **pos, char **ptr, const char *str)
lib/device/dev-cache.c +1 -1
index 0d1d4e36f..d454b5b30 100644
@@ -39,7 +39,7 @@ struct dev_iter {
 
 struct dir_list {
 	struct dm_list list;
-	char dir[];
+	char dir[0];
 };
 
 static struct {
lib/label/label.c +1 -1
index 4c243a43d..b5804c738 100644
@@ -44,7 +44,7 @@ struct labeller_i {
 	struct dm_list list;
 
 	struct labeller *l;
-	char name[];
+	char name[0];
 };
 
 static struct dm_list _labellers;
libdm/datastruct/hash.c +1 -1
index 67261f8da..054f5c359 100644
@@ -20,7 +20,7 @@ struct dm_hash_node {
 	void *data;
 	unsigned data_len;
 	unsigned keylen;
-	char key[];
+	char key[0];
 };
 
 struct dm_hash_table {
libdm/libdm-common.c +1 -1
index 56fb436bc..27be1d02f 100644
@@ -1443,7 +1443,7 @@ struct node_op_parms {
 	char *old_name;
 	int warn_if_udev_failed;
 	unsigned rely_on_udev;
-	char names[];
+	char names[0];
 };
 
 static void _store_str(char **pos, char **ptr, const char *str)
libdm/misc/dm-ioctl.h +4 -4
index 55dee2148..52a7a93d1 100644
@@ -183,7 +183,7 @@ struct dm_target_spec {
 struct dm_target_deps {
 	uint32_t count;	/* Array size */
 	uint32_t padding;	/* unused */
-	uint64_t dev[];		/* out */
+	uint64_t dev[0];	/* out */
 };
 
 /*
@@ -193,7 +193,7 @@ struct dm_name_list {
 	uint64_t dev;
 	uint32_t next;		/* offset to the next record from
 				   the _start_ of this */
-	char name[];
+	char name[0];
 };
 
 /*
@@ -203,7 +203,7 @@ struct dm_target_versions {
         uint32_t next;
         uint32_t version[3];
 
-        char name[];
+        char name[0];
 };
 
 /*
@@ -212,7 +212,7 @@ struct dm_target_versions {
 struct dm_target_msg {
 	uint64_t sector;	/* Device sector */
 
-	char message[];
+	char message[0];
 };
 
 /*
libdm/misc/dm-log-userspace.h +1 -1
index b243194d9..f28fa585e 100644
@@ -412,7 +412,7 @@ struct dm_ulog_request {
 	uint32_t request_type;  /* DM_ULOG_* defined above */
 	uint32_t data_size;     /* How much data (not including this struct) */
 
-	char data[];
+	char data[0];
 };
 
 #endif /* __DM_LOG_USERSPACE_H__ */