[v4,3/4] lib: replace zero-length arrays with undimensioned ones

Message ID 20220603111625.562070-4-bruce.richardson@intel.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series clean up zero-length arrays |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Bruce Richardson June 3, 2022, 11:16 a.m. UTC
  This patch replaces instances of zero-sized arrays i.e. those at the end
of structures with "[0]" with the more standard syntax of "[]".
Replacement was done using coccinelle script, with some cleanup of
whitespace afterwards.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 lib/cryptodev/cryptodev_pmd.h          | 2 +-
 lib/cryptodev/rte_cryptodev.h          | 2 +-
 lib/eventdev/rte_event_timer_adapter.h | 2 +-
 lib/ip_frag/ip_reassembly.h            | 2 +-
 lib/ipsec/sa.h                         | 2 +-
 lib/rib/rte_rib.c                      | 2 +-
 lib/rib/rte_rib6.c                     | 2 +-
 lib/table/rte_swx_table_learner.c      | 4 ++--
 lib/table/rte_table_hash_key16.c       | 4 ++--
 lib/table/rte_table_hash_key32.c       | 4 ++--
 lib/table/rte_table_hash_key8.c        | 4 ++--
 lib/vhost/rte_vhost.h                  | 4 ++--
 12 files changed, 17 insertions(+), 17 deletions(-)
  

Patch

diff --git a/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.h
index 7a7d3ee3f1..3dcc3cb7ed 100644
--- a/lib/cryptodev/cryptodev_pmd.h
+++ b/lib/cryptodev/cryptodev_pmd.h
@@ -673,7 +673,7 @@  RTE_STD_C11 struct rte_cryptodev_asym_session {
 	uint8_t padding[3];
 	void *event_mdata;
 	/**< Event metadata (aka *union rte_event_crypto_metadata*) */
-	uint8_t sess_private_data[0];
+	uint8_t sess_private_data[];
 };
 
 #ifdef __cplusplus
diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h
index 585cee2727..56f459c6a0 100644
--- a/lib/cryptodev/rte_cryptodev.h
+++ b/lib/cryptodev/rte_cryptodev.h
@@ -918,7 +918,7 @@  struct rte_cryptodev_sym_session {
 	__extension__ struct {
 		void *data;
 		uint16_t refcnt;
-	} sess_data[0];
+	} sess_data[];
 	/**< Driver specific session material, variable size */
 };
 
diff --git a/lib/eventdev/rte_event_timer_adapter.h b/lib/eventdev/rte_event_timer_adapter.h
index 4c91e5516a..eab8e59a57 100644
--- a/lib/eventdev/rte_event_timer_adapter.h
+++ b/lib/eventdev/rte_event_timer_adapter.h
@@ -486,7 +486,7 @@  struct rte_event_timer {
 	 */
 	enum rte_event_timer_state state;
 	/**< State of the event timer. */
-	uint8_t user_meta[0];
+	uint8_t user_meta[];
 	/**< Memory to store user specific metadata.
 	 * The event timer adapter implementation should not modify this area.
 	 */
diff --git a/lib/ip_frag/ip_reassembly.h b/lib/ip_frag/ip_reassembly.h
index 416fb66dd4..ef9d8c0d75 100644
--- a/lib/ip_frag/ip_reassembly.h
+++ b/lib/ip_frag/ip_reassembly.h
@@ -83,7 +83,7 @@  struct rte_ip_frag_tbl {
 	struct ip_frag_pkt *last;     /* last used entry. */
 	struct ip_pkt_list lru;       /* LRU list for table entries. */
 	struct ip_frag_tbl_stat stat; /* statistics counters. */
-	__extension__ struct ip_frag_pkt pkt[0]; /* hash table. */
+	__extension__ struct ip_frag_pkt pkt[]; /* hash table. */
 };
 
 #endif /* _IP_REASSEMBLY_H_ */
diff --git a/lib/ipsec/sa.h b/lib/ipsec/sa.h
index 46f9a4df5b..ce4af8ceb2 100644
--- a/lib/ipsec/sa.h
+++ b/lib/ipsec/sa.h
@@ -59,7 +59,7 @@  union sym_op_data {
 struct replay_sqn {
 	rte_rwlock_t rwl;
 	uint64_t sqn;
-	__extension__ uint64_t window[0];
+	__extension__ uint64_t window[];
 };
 
 /*IPSEC SA supported algorithms */
diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c
index f1fdddbbb4..b0794edf66 100644
--- a/lib/rib/rte_rib.c
+++ b/lib/rib/rte_rib.c
@@ -35,7 +35,7 @@  struct rte_rib_node {
 	uint8_t		depth;
 	uint8_t		flag;
 	uint64_t	nh;
-	__extension__ uint64_t	ext[0];
+	__extension__ uint64_t ext[];
 };
 
 struct rte_rib {
diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c
index 650bf1b8f6..19e4ff97c4 100644
--- a/lib/rib/rte_rib6.c
+++ b/lib/rib/rte_rib6.c
@@ -34,7 +34,7 @@  struct rte_rib6_node {
 	uint8_t			ip[RTE_RIB6_IPV6_ADDR_SIZE];
 	uint8_t			depth;
 	uint8_t			flag;
-	__extension__ uint64_t		ext[0];
+	__extension__ uint64_t ext[];
 };
 
 struct rte_rib6 {
diff --git a/lib/table/rte_swx_table_learner.c b/lib/table/rte_swx_table_learner.c
index 222acfc962..f7f8e8aea9 100644
--- a/lib/table/rte_swx_table_learner.c
+++ b/lib/table/rte_swx_table_learner.c
@@ -252,7 +252,7 @@  struct table_bucket {
 	uint32_t sig[TABLE_KEYS_PER_BUCKET];
 	uint8_t key_timeout_id[TABLE_KEYS_PER_BUCKET];
 	uint8_t pad[TABLE_BUCKET_PAD_SIZE];
-	uint8_t key[0];
+	uint8_t key[];
 };
 
 struct table_params {
@@ -317,7 +317,7 @@  struct table {
 	uint8_t key_mask0[RTE_CACHE_LINE_SIZE];
 
 	/* Table buckets. */
-	uint8_t buckets[0];
+	uint8_t buckets[];
 } __rte_cache_aligned;
 
 /* The timeout (in cycles) is stored in the table as a 32-bit value by truncating its least
diff --git a/lib/table/rte_table_hash_key16.c b/lib/table/rte_table_hash_key16.c
index ea8195dc17..04d7fd64bd 100644
--- a/lib/table/rte_table_hash_key16.c
+++ b/lib/table/rte_table_hash_key16.c
@@ -43,7 +43,7 @@  struct rte_bucket_4_16 {
 	uint64_t key[4][2];
 
 	/* Cache line 2 */
-	uint8_t data[0];
+	uint8_t data[];
 };
 #else
 struct rte_bucket_4_16 {
@@ -58,7 +58,7 @@  struct rte_bucket_4_16 {
 	uint64_t key[4][2];
 
 	/* Cache line 2 */
-	uint8_t data[0];
+	uint8_t data[];
 };
 #endif
 
diff --git a/lib/table/rte_table_hash_key32.c b/lib/table/rte_table_hash_key32.c
index 87f83ce6f5..88d8f69c72 100644
--- a/lib/table/rte_table_hash_key32.c
+++ b/lib/table/rte_table_hash_key32.c
@@ -43,7 +43,7 @@  struct rte_bucket_4_32 {
 	uint64_t key[4][4];
 
 	/* Cache line 3 */
-	uint8_t data[0];
+	uint8_t data[];
 };
 #else
 struct rte_bucket_4_32 {
@@ -58,7 +58,7 @@  struct rte_bucket_4_32 {
 	uint64_t key[4][4];
 
 	/* Cache line 3 */
-	uint8_t data[0];
+	uint8_t data[];
 };
 #endif
 
diff --git a/lib/table/rte_table_hash_key8.c b/lib/table/rte_table_hash_key8.c
index 7779a9d1a3..035d242769 100644
--- a/lib/table/rte_table_hash_key8.c
+++ b/lib/table/rte_table_hash_key8.c
@@ -40,7 +40,7 @@  struct rte_bucket_4_8 {
 	uint64_t key[4];
 
 	/* Cache line 1 */
-	uint8_t data[0];
+	uint8_t data[];
 };
 #else
 struct rte_bucket_4_8 {
@@ -54,7 +54,7 @@  struct rte_bucket_4_8 {
 	uint64_t key[4];
 
 	/* Cache line 1 */
-	uint8_t data[0];
+	uint8_t data[];
 };
 #endif
 
diff --git a/lib/vhost/rte_vhost.h b/lib/vhost/rte_vhost.h
index c733f857c6..99be18ceef 100644
--- a/lib/vhost/rte_vhost.h
+++ b/lib/vhost/rte_vhost.h
@@ -154,7 +154,7 @@  struct rte_vhost_inflight_info_split {
 	uint16_t desc_num;
 	uint16_t last_inflight_io;
 	uint16_t used_idx;
-	struct rte_vhost_inflight_desc_split desc[0];
+	struct rte_vhost_inflight_desc_split desc[];
 };
 
 struct rte_vhost_inflight_desc_packed {
@@ -181,7 +181,7 @@  struct rte_vhost_inflight_info_packed {
 	uint8_t used_wrap_counter;
 	uint8_t old_used_wrap_counter;
 	uint8_t padding[7];
-	struct rte_vhost_inflight_desc_packed desc[0];
+	struct rte_vhost_inflight_desc_packed desc[];
 };
 
 struct rte_vhost_resubmit_desc {