From patchwork Thu Jun 2 16:13:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 112278 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B63CEA0548; Thu, 2 Jun 2022 18:13:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A3C1040DF7; Thu, 2 Jun 2022 18:13:43 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id ADF0B40DDE for ; Thu, 2 Jun 2022 18:13:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654186422; x=1685722422; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8vM6zCWXWvM6jCv4ceAwu+gaWLu7yZur8gZYmDzRxYw=; b=DqH0Et7ZStWSjsETjfFt5/Wk/i58BMrpZhWkE9XI88KHox6c8asLmRY3 Z2XOHNBv7x+IcYSUUG24cUKyDcm4JRnyeZH+BI4qAn9a0nUIXboSrqs1K GGpSmv1R9Fbj/KH0Ah4xBb+8slZRmhVPfKvdk4SoAyUUMUKq2A2fHmyTl J4zwv0ZjkClEnAXBkEtkE9Q+rlNVBnnsQCNpSqDY2JQwt0i72WpS4YLE7 s9WnH+DvV2jtQaU3yfl2ChyqMZlBImTNvs8tR46ai3zqknGri7dUUyHaY UPZZfQ3S0xejHkIeVbv9s495w+e3G+VOPEJdO85PSl+XNuaybdC+fqCmb g==; X-IronPort-AV: E=McAfee;i="6400,9594,10366"; a="276005628" X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="276005628" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2022 09:13:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="577575009" Received: from silpixa00401385.ir.intel.com (HELO silpixa00401385.ger.corp.intel.com.) ([10.237.222.171]) by orsmga007.jf.intel.com with ESMTP; 02 Jun 2022 09:13:39 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson , =?utf-8?q?Morten_Br=C3=B8rup?= , Stephen Hemminger Subject: [PATCH v2 1/4] cocci: add script for zero-length arrays in structs Date: Thu, 2 Jun 2022 17:13:21 +0100 Message-Id: <20220602161324.1123926-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220602161324.1123926-1-bruce.richardson@intel.com> References: <20220602150834.643745-1-bruce.richardson@intel.com> <20220602161324.1123926-1-bruce.richardson@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add script to replace [0] with [] when used at the end of a struct. The script also includes an additional struct member to match against so as to avoid issues with arrays with only a single zero-length element. Signed-off-by: Bruce Richardson Acked-by: Morten Brørup Acked-by: Stephen Hemminger --- devtools/cocci/zero_length_array.cocci | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 devtools/cocci/zero_length_array.cocci diff --git a/devtools/cocci/zero_length_array.cocci b/devtools/cocci/zero_length_array.cocci new file mode 100644 index 0000000000..de8783bc7a --- /dev/null +++ b/devtools/cocci/zero_length_array.cocci @@ -0,0 +1,21 @@ +// Replace zero-length array members with [] +@@ +identifier st, member, arr; +type T1, T2; +@@ +struct st { + ... + T1 member; +- T2 arr[0]; ++ T2 arr[]; +}; +@@ +identifier st, member, arr, id; +type T1, T2; +@@ +struct st { + ... + T1 member; +- T2 arr[0]; ++ T2 arr[]; +} id; From patchwork Thu Jun 2 16:13:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 112279 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A431BA0548; Thu, 2 Jun 2022 18:13:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 970CF42802; Thu, 2 Jun 2022 18:13:51 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id CF92E4021E for ; Thu, 2 Jun 2022 18:13:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654186429; x=1685722429; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iy2ZseybSRy8C4a5HqLFn8eQ0Wcg6y/iO1V5b/qWQUM=; b=VrHiVTfERM+CPoS6AwQq+FpjK2tRDfHryxbDxUCgMItR65faIlCRGK3F /KJ+knFvngcPPoKbAga70S0ia88YxKTr6MKG/ugG7cCj26iA6nu6vuN+v 0ZsP88Swz8l5YXtanhsEzF71vYoRXzUbNyGEB/SOB14H/ANWPee8gHw1a 9RkX0XEF7sHVvYRB6lT1TH6l7x0LBcxF/ehJ2nGS7OxgiJc6oHlHf83cC 11Y1NJvs2IeC6Fd5DMARxajtBbV6WK/kN1v/tlcFzHbHox7QCwiR79MZv b5CdTIQjRb/wczWgjmaod3WUt3pIhR0UNbT2XL8dJgcdMxL97Q+at3Spp A==; X-IronPort-AV: E=McAfee;i="6400,9594,10366"; a="339040516" X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="339040516" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2022 09:13:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="577575037" Received: from silpixa00401385.ir.intel.com (HELO silpixa00401385.ger.corp.intel.com.) ([10.237.222.171]) by orsmga007.jf.intel.com with ESMTP; 02 Jun 2022 09:13:42 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson , =?utf-8?q?Morten_Br=C3=B8rup?= , Stephen Hemminger Subject: [PATCH v2 2/4] drivers: replace zero-length arrays with undimensioned ones Date: Thu, 2 Jun 2022 17:13:22 +0100 Message-Id: <20220602161324.1123926-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220602161324.1123926-1-bruce.richardson@intel.com> References: <20220602150834.643745-1-bruce.richardson@intel.com> <20220602161324.1123926-1-bruce.richardson@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Acked-by: Morten Brørup Acked-by: Stephen Hemminger --- drivers/bus/dpaa/include/netcfg.h | 4 ++-- drivers/bus/vmbus/rte_vmbus_reg.h | 4 ++-- drivers/common/cnxk/roc_se.h | 2 +- drivers/common/dpaax/caamflib/desc/ipsec.h | 2 +- drivers/common/dpaax/dpaax_iova_table.h | 2 +- drivers/common/mlx5/mlx5_prm.h | 10 +++++----- drivers/crypto/ipsec_mb/ipsec_mb_private.h | 4 ++-- drivers/crypto/virtio/virtio_ring.h | 4 ++-- drivers/crypto/virtio/virtqueue.h | 2 +- drivers/net/atlantic/hw_atl/hw_atl_utils.h | 2 +- drivers/net/cxgbe/clip_tbl.h | 2 +- drivers/net/cxgbe/l2t.h | 2 +- drivers/net/cxgbe/mps_tcam.h | 2 +- drivers/net/cxgbe/smt.h | 2 +- drivers/net/enic/base/vnic_devcmd.h | 2 +- drivers/net/hinic/hinic_pmd_tx.h | 2 +- drivers/net/mlx5/mlx5_tx.h | 2 +- drivers/net/nfp/nfpcore/nfp_nsp.h | 2 +- drivers/net/virtio/virtio_ring.h | 4 ++-- drivers/net/virtio/virtio_user/vhost_kernel.c | 2 +- drivers/net/virtio/virtio_user/vhost_vdpa.c | 2 +- drivers/net/virtio/virtqueue.h | 2 +- drivers/regex/mlx5/mlx5_rxp.h | 4 ++-- 23 files changed, 33 insertions(+), 33 deletions(-) diff --git a/drivers/bus/dpaa/include/netcfg.h b/drivers/bus/dpaa/include/netcfg.h index bb18a34e3d..43c7e1cfe1 100644 --- a/drivers/bus/dpaa/include/netcfg.h +++ b/drivers/bus/dpaa/include/netcfg.h @@ -23,7 +23,7 @@ struct fm_eth_port_cfg { struct netcfg_info { uint8_t num_ethports; /**< Number of ports */ - struct fm_eth_port_cfg port_cfg[0]; + struct fm_eth_port_cfg port_cfg[]; /**< Variable structure array of size num_ethports */ }; @@ -38,7 +38,7 @@ struct interface_info { struct netcfg_interface { uint8_t numof_netcfg_interface; uint8_t numof_fman_enabled_macless; - struct interface_info interface_info[0]; + struct interface_info interface_info[]; }; /* pcd_file: FMC netpcd XML ("policy") file, that contains PCD information. diff --git a/drivers/bus/vmbus/rte_vmbus_reg.h b/drivers/bus/vmbus/rte_vmbus_reg.h index 8562672979..a17ce40763 100644 --- a/drivers/bus/vmbus/rte_vmbus_reg.h +++ b/drivers/bus/vmbus/rte_vmbus_reg.h @@ -107,7 +107,7 @@ struct vmbus_bufring { * Ring data starts here + RingDataStartOffset * !!! DO NOT place any fields below this !!! */ - uint8_t data[0]; + uint8_t data[]; } __rte_packed; /* @@ -140,7 +140,7 @@ vmbus_chanpkt_getlen(uint16_t pktlen) struct vmbus_gpa_range { uint32_t len; uint32_t ofs; - uint64_t page[0]; + uint64_t page[]; } __rte_packed; /* This is actually vmbus_gpa_range.gpa_page[1] */ diff --git a/drivers/common/cnxk/roc_se.h b/drivers/common/cnxk/roc_se.h index 145a1825bd..a1d476a86d 100644 --- a/drivers/common/cnxk/roc_se.h +++ b/drivers/common/cnxk/roc_se.h @@ -246,7 +246,7 @@ struct roc_se_buf_ptr { /* IOV Pointer */ struct roc_se_iov_ptr { int buf_cnt; - struct roc_se_buf_ptr bufs[0]; + struct roc_se_buf_ptr bufs[]; }; struct roc_se_fc_params { diff --git a/drivers/common/dpaax/caamflib/desc/ipsec.h b/drivers/common/dpaax/caamflib/desc/ipsec.h index 8ec6aac915..2c9080a1b5 100644 --- a/drivers/common/dpaax/caamflib/desc/ipsec.h +++ b/drivers/common/dpaax/caamflib/desc/ipsec.h @@ -350,7 +350,7 @@ struct ipsec_encap_pdb { }; uint32_t spi; uint32_t ip_hdr_len; - uint8_t ip_hdr[0]; + uint8_t ip_hdr[]; }; static inline unsigned int diff --git a/drivers/common/dpaax/dpaax_iova_table.h b/drivers/common/dpaax/dpaax_iova_table.h index b1f2300c52..9a18eafca0 100644 --- a/drivers/common/dpaax/dpaax_iova_table.h +++ b/drivers/common/dpaax/dpaax_iova_table.h @@ -32,7 +32,7 @@ struct dpaax_iovat_element { struct dpaax_iova_table { unsigned int count; /**< No. of blocks of contiguous physical pages */ - struct dpaax_iovat_element entries[0]; + struct dpaax_iovat_element entries[]; }; /* Pointer to the table, which is common for DPAA/DPAA2 and only a single diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h index bc3e70a1d1..ed0781a560 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -560,7 +560,7 @@ struct mlx5_umr_wqe { struct mlx5_rdma_write_wqe { struct mlx5_wqe_cseg ctr; struct mlx5_wqe_rseg rseg; - struct mlx5_wqe_dseg dseg[0]; + struct mlx5_wqe_dseg dseg[]; } __rte_packed; #ifdef PEDANTIC @@ -3479,7 +3479,7 @@ struct mlx5_ifc_qpc_pas_list_bits { #endif struct mlx5_ifc_qpc_extension_and_pas_list_bits { struct mlx5_ifc_qpc_extension_bits qpc_data_extension; - u8 pas[0][0x40]; + u8[0x40] pas[]; }; @@ -3703,7 +3703,7 @@ struct mlx5_ifc_query_qp_out_bits { u8 reserved_at_a0[0x20]; struct mlx5_ifc_qpc_bits qpc; u8 reserved_at_800[0x80]; - u8 pas[0][0x40]; + u8[0x40] pas[]; }; #ifdef PEDANTIC #pragma GCC diagnostic error "-Wpedantic" @@ -3743,7 +3743,7 @@ struct mlx5_ifc_access_register_out_bits { u8 reserved_at_8[0x18]; u8 syndrome[0x20]; u8 reserved_at_40[0x40]; - u8 register_data[0][0x20]; + u8[0x20] register_data[]; }; struct mlx5_ifc_access_register_in_bits { @@ -3754,7 +3754,7 @@ struct mlx5_ifc_access_register_in_bits { u8 reserved_at_40[0x10]; u8 register_id[0x10]; u8 argument[0x20]; - u8 register_data[0][0x20]; + u8[0x20] register_data[]; }; #ifdef PEDANTIC #pragma GCC diagnostic error "-Wpedantic" diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_private.h b/drivers/crypto/ipsec_mb/ipsec_mb_private.h index e53101acf1..e2c240dfc0 100644 --- a/drivers/crypto/ipsec_mb/ipsec_mb_private.h +++ b/drivers/crypto/ipsec_mb/ipsec_mb_private.h @@ -120,7 +120,7 @@ struct ipsec_mb_dev_private { /**< PMD type */ uint32_t max_nb_queue_pairs; /**< Max number of queue pairs supported by device */ - __extension__ uint8_t priv[0]; + __extension__ uint8_t priv[]; }; /** IPSEC Multi buffer queue pair common queue pair data for all PMDs */ @@ -147,7 +147,7 @@ struct ipsec_mb_qp { /* Multi buffer manager */ const struct rte_memzone *mb_mgr_mz; /* Shared memzone for storing mb_mgr */ - __extension__ uint8_t additional_data[0]; + __extension__ uint8_t additional_data[]; /**< Storing PMD specific additional data */ }; diff --git a/drivers/crypto/virtio/virtio_ring.h b/drivers/crypto/virtio/virtio_ring.h index ee30674566..55839279fd 100644 --- a/drivers/crypto/virtio/virtio_ring.h +++ b/drivers/crypto/virtio/virtio_ring.h @@ -40,7 +40,7 @@ struct vring_desc { struct vring_avail { uint16_t flags; uint16_t idx; - uint16_t ring[0]; + uint16_t ring[]; }; /* id is a 16bit index. uint32_t is used here for ids for padding reasons. */ @@ -54,7 +54,7 @@ struct vring_used_elem { struct vring_used { uint16_t flags; volatile uint16_t idx; - struct vring_used_elem ring[0]; + struct vring_used_elem ring[]; }; struct vring { diff --git a/drivers/crypto/virtio/virtqueue.h b/drivers/crypto/virtio/virtqueue.h index c96ca62992..cb08bea94f 100644 --- a/drivers/crypto/virtio/virtqueue.h +++ b/drivers/crypto/virtio/virtqueue.h @@ -88,7 +88,7 @@ struct virtqueue { uint16_t *notify_addr; - struct vq_desc_extra vq_descx[0]; + struct vq_desc_extra vq_descx[]; }; /** diff --git a/drivers/net/atlantic/hw_atl/hw_atl_utils.h b/drivers/net/atlantic/hw_atl/hw_atl_utils.h index d8fab010cf..12ac9b041e 100644 --- a/drivers/net/atlantic/hw_atl/hw_atl_utils.h +++ b/drivers/net/atlantic/hw_atl/hw_atl_utils.h @@ -334,7 +334,7 @@ struct offload_info { struct offload_port_info ports; struct offload_ka_info kas; struct offload_rr_info rrs; - u8 buf[0]; + u8 buf[]; } __rte_packed; struct smbus_request { diff --git a/drivers/net/cxgbe/clip_tbl.h b/drivers/net/cxgbe/clip_tbl.h index d7689f4b7a..3b2be6645f 100644 --- a/drivers/net/cxgbe/clip_tbl.h +++ b/drivers/net/cxgbe/clip_tbl.h @@ -20,7 +20,7 @@ struct clip_tbl { unsigned int clipt_start; /* start index of CLIP table */ unsigned int clipt_size; /* size of CLIP table */ rte_rwlock_t lock; /* table rw lock */ - struct clip_entry cl_list[0]; /* MUST BE LAST */ + struct clip_entry cl_list[]; /* MUST BE LAST */ }; struct clip_tbl *t4_init_clip_tbl(unsigned int clipt_start, diff --git a/drivers/net/cxgbe/l2t.h b/drivers/net/cxgbe/l2t.h index 9845c9f981..e4c0ebedec 100644 --- a/drivers/net/cxgbe/l2t.h +++ b/drivers/net/cxgbe/l2t.h @@ -37,7 +37,7 @@ struct l2t_data { unsigned int l2t_start; /* start index of our piece of the L2T */ unsigned int l2t_size; /* number of entries in l2tab */ rte_rwlock_t lock; /* table rw lock */ - struct l2t_entry l2tab[0]; /* MUST BE LAST */ + struct l2t_entry l2tab[]; /* MUST BE LAST */ }; #define L2T_LPBK true diff --git a/drivers/net/cxgbe/mps_tcam.h b/drivers/net/cxgbe/mps_tcam.h index a359f52442..363786bd38 100644 --- a/drivers/net/cxgbe/mps_tcam.h +++ b/drivers/net/cxgbe/mps_tcam.h @@ -41,7 +41,7 @@ struct mpstcam_table { * free_idx cannot alone determine * if the table is full */ - struct mps_tcam_entry entry[0]; + struct mps_tcam_entry entry[]; }; struct mpstcam_table *t4_init_mpstcam(struct adapter *adap); diff --git a/drivers/net/cxgbe/smt.h b/drivers/net/cxgbe/smt.h index a70e3a2085..531810e695 100644 --- a/drivers/net/cxgbe/smt.h +++ b/drivers/net/cxgbe/smt.h @@ -31,7 +31,7 @@ struct smt_data { unsigned int smt_size; unsigned int smt_start; rte_rwlock_t lock; - struct smt_entry smtab[0]; + struct smt_entry smtab[]; }; struct smt_data *t4_init_smt(u32 smt_start_idx, u32 smt_size); diff --git a/drivers/net/enic/base/vnic_devcmd.h b/drivers/net/enic/base/vnic_devcmd.h index 3157bc8cb5..253a791c3f 100644 --- a/drivers/net/enic/base/vnic_devcmd.h +++ b/drivers/net/enic/base/vnic_devcmd.h @@ -997,7 +997,7 @@ enum { struct filter_tlv { uint32_t type; uint32_t length; - uint32_t val[0]; + uint32_t val[]; }; /* Data for CMD_ADD_FILTER is 2 TLV and filter + action structs */ diff --git a/drivers/net/hinic/hinic_pmd_tx.h b/drivers/net/hinic/hinic_pmd_tx.h index a3ec6299fb..152f7abc53 100644 --- a/drivers/net/hinic/hinic_pmd_tx.h +++ b/drivers/net/hinic/hinic_pmd_tx.h @@ -81,7 +81,7 @@ struct hinic_sq_wqe { struct hinic_sq_task task; /* sq sge section start address, 1~127 sges */ - struct hinic_sq_bufdesc buf_descs[0]; + struct hinic_sq_bufdesc buf_descs[]; }; struct hinic_txq_stats { diff --git a/drivers/net/mlx5/mlx5_tx.h b/drivers/net/mlx5/mlx5_tx.h index 20776919c2..defb745906 100644 --- a/drivers/net/mlx5/mlx5_tx.h +++ b/drivers/net/mlx5/mlx5_tx.h @@ -166,7 +166,7 @@ struct mlx5_txq_data { struct mlx5_txq_stats stats; /* TX queue counters. */ struct mlx5_txq_stats stats_reset; /* stats on last reset. */ struct mlx5_uar_data uar_data; - struct rte_mbuf *elts[0]; + struct rte_mbuf *elts[]; /* Storage for queued packets, must be the last field. */ } __rte_cache_aligned; diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.h b/drivers/net/nfp/nfpcore/nfp_nsp.h index e74cdeb191..2184c15b4c 100644 --- a/drivers/net/nfp/nfpcore/nfp_nsp.h +++ b/drivers/net/nfp/nfpcore/nfp_nsp.h @@ -224,7 +224,7 @@ struct nfp_eth_table { int is_split; unsigned int fec_modes_supported; - } ports[0]; + } ports[]; }; struct nfp_eth_table *nfp_eth_read_ports(struct nfp_cpp *cpp); diff --git a/drivers/net/virtio/virtio_ring.h b/drivers/net/virtio/virtio_ring.h index 17a56b0a73..e848c0b73b 100644 --- a/drivers/net/virtio/virtio_ring.h +++ b/drivers/net/virtio/virtio_ring.h @@ -46,7 +46,7 @@ struct vring_desc { struct vring_avail { uint16_t flags; uint16_t idx; - uint16_t ring[0]; + uint16_t ring[]; }; /* id is a 16bit index. uint32_t is used here for ids for padding reasons. */ @@ -60,7 +60,7 @@ struct vring_used_elem { struct vring_used { uint16_t flags; uint16_t idx; - struct vring_used_elem ring[0]; + struct vring_used_elem ring[]; }; /* For support of packed virtqueues in Virtio 1.1 the format of descriptors diff --git a/drivers/net/virtio/virtio_user/vhost_kernel.c b/drivers/net/virtio/virtio_user/vhost_kernel.c index 986b56a7ca..1aed08b2bd 100644 --- a/drivers/net/virtio/virtio_user/vhost_kernel.c +++ b/drivers/net/virtio/virtio_user/vhost_kernel.c @@ -22,7 +22,7 @@ struct vhost_kernel_data { struct vhost_memory_kernel { uint32_t nregions; uint32_t padding; - struct vhost_memory_region regions[0]; + struct vhost_memory_region regions[]; }; /* vhost kernel ioctls */ diff --git a/drivers/net/virtio/virtio_user/vhost_vdpa.c b/drivers/net/virtio/virtio_user/vhost_vdpa.c index 82f25a8674..bd13fe44b4 100644 --- a/drivers/net/virtio/virtio_user/vhost_vdpa.c +++ b/drivers/net/virtio/virtio_user/vhost_vdpa.c @@ -70,7 +70,7 @@ struct vhost_iotlb_msg { struct vhost_vdpa_config { uint32_t off; uint32_t len; - uint8_t buf[0]; + uint8_t buf[]; }; struct vhost_msg { diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h index 99c68cf622..d100ed8762 100644 --- a/drivers/net/virtio/virtqueue.h +++ b/drivers/net/virtio/virtqueue.h @@ -309,7 +309,7 @@ struct virtqueue { uint16_t *notify_addr; struct rte_mbuf **sw_ring; /**< RX software ring. */ - struct vq_desc_extra vq_descx[0]; + struct vq_desc_extra vq_descx[]; }; /* If multiqueue is provided by host, then we support it. */ diff --git a/drivers/regex/mlx5/mlx5_rxp.h b/drivers/regex/mlx5/mlx5_rxp.h index 315e3b4ca3..eddc577d79 100644 --- a/drivers/regex/mlx5/mlx5_rxp.h +++ b/drivers/regex/mlx5/mlx5_rxp.h @@ -64,7 +64,7 @@ struct mlx5_rxp_match_tuple { struct mlx5_rxp_response { struct mlx5_rxp_response_desc header; - struct mlx5_rxp_match_tuple matches[0]; + struct mlx5_rxp_match_tuple matches[]; }; #define MLX5_RXP_MAX_MATCHES 254 @@ -114,7 +114,7 @@ struct mlx5_rxp_rof { struct mlx5_rxp_ctl_rules_pgm { struct mlx5_rxp_ctl_hdr hdr; uint32_t count; - struct mlx5_rxp_rof_entry rules[0]; + struct mlx5_rxp_rof_entry rules[]; } __rte_packed; /* RXP programming mode setting. */ From patchwork Thu Jun 2 16:13:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 112280 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B2F5BA0548; Thu, 2 Jun 2022 18:14:00 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BA69242B6C; Thu, 2 Jun 2022 18:13:52 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id D96814021E for ; Thu, 2 Jun 2022 18:13:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654186431; x=1685722431; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pHX2fCSVLsgKnl9oO5oNknUG5ujZMyfAMAe8TCVVxeA=; b=J0EHtwhU5VjWW2NiLmjINLKY9qylClhT/b673QJ9MgiZRDuPKOW9e/ww cfSu7TQ6HaNlof4bIGkucJkGuCDsedtguhCzUxsRydIThanAwejrJ16LG /RDlGWV5N9Z3qssQw6JqGJFO0IaOk7rdJSfUDNmfMlMlCJXDGOAO5Hclf yGo+ZznCvAvBcmH1XPdsVvITBy6nzrQbb7AhPFF6jSWft6yp0uNVRxG6k Ing13VJvx/zQ5L7pnRaSri4xAOmg3jD1s65zoXcIVAQzgPyjTZ+xiNBvA DV6nsmQ6Xdn4bT3xzICvLXOYZN9lxf9n9Vhdor0IgIXDzRKyCMtXcEHiL w==; X-IronPort-AV: E=McAfee;i="6400,9594,10366"; a="339040523" X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="339040523" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2022 09:13:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="577575059" Received: from silpixa00401385.ir.intel.com (HELO silpixa00401385.ger.corp.intel.com.) ([10.237.222.171]) by orsmga007.jf.intel.com with ESMTP; 02 Jun 2022 09:13:48 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson , =?utf-8?q?Morten_Br=C3=B8rup?= , Stephen Hemminger Subject: [PATCH v2 3/4] lib: replace zero-length arrays with undimensioned ones Date: Thu, 2 Jun 2022 17:13:23 +0100 Message-Id: <20220602161324.1123926-4-bruce.richardson@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220602161324.1123926-1-bruce.richardson@intel.com> References: <20220602150834.643745-1-bruce.richardson@intel.com> <20220602161324.1123926-1-bruce.richardson@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Acked-by: Morten Brørup Acked-by: Stephen Hemminger --- 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(-) 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 { From patchwork Thu Jun 2 16:13:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 112281 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3C2B8A0548; Thu, 2 Jun 2022 18:14:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9A4514281A; Thu, 2 Jun 2022 18:13:55 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 41F7842B70 for ; Thu, 2 Jun 2022 18:13:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654186433; x=1685722433; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vWxmTozyS8qyWx/rBk1jZizBuhxiM/XVssBzuxbc1tA=; b=MobZxvpdZvVMiJ85OCZzWX4aWdf+Tz8pUfiVVvc7nwc3i61csMikgWO/ NC8q9zzVrdkQOW1a0Jd/Ft3Fcth00eZmZQ94zXxA4C1ktgG7qNxTCD6JL har6ULawGg1PpKVo6JcScf0QMJ+csPPvLDmEjS4gJTphYfUIJIAxJeS5o w8meRTAQM73L3IH8W28pZHn9TMuqNbEAgFc+mBwXpB37Bi5zDztASRAtS 9/kd/+QKWhBMHV3reXL7cERhxXLWUlI97j53cTLNa/NqPNFH35B2T8Ixc ocpE26mKAV5ljhK/jf1Ad+xXhxnA5Uln3XyzpBdZrw64nDWvazqNa8l6D g==; X-IronPort-AV: E=McAfee;i="6400,9594,10366"; a="339040530" X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="339040530" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2022 09:13:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="577575069" Received: from silpixa00401385.ir.intel.com (HELO silpixa00401385.ger.corp.intel.com.) ([10.237.222.171]) by orsmga007.jf.intel.com with ESMTP; 02 Jun 2022 09:13:51 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson , =?utf-8?q?Morten_Br=C3=B8rup?= , Stephen Hemminger Subject: [PATCH v2 4/4] app: examples: replace zero-length arrays with undimensioned ones Date: Thu, 2 Jun 2022 17:13:24 +0100 Message-Id: <20220602161324.1123926-5-bruce.richardson@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220602161324.1123926-1-bruce.richardson@intel.com> References: <20220602150834.643745-1-bruce.richardson@intel.com> <20220602161324.1123926-1-bruce.richardson@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Acked-by: Morten Brørup Acked-by: Stephen Hemminger --- app/test/test_table_tables.c | 2 +- examples/ip_reassembly/main.c | 2 +- examples/ptpclient/ptpclient.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/test/test_table_tables.c b/app/test/test_table_tables.c index 010dd5a794..26908e6112 100644 --- a/app/test/test_table_tables.c +++ b/app/test/test_table_tables.c @@ -53,7 +53,7 @@ struct rte_bucket_4_8 { uint64_t next_valid; uint64_t key[4]; /* Cache line 1 */ - uint8_t data[0]; + uint8_t data[]; }; #if RTE_TABLE_HASH_LRU_STRATEGY == 3 diff --git a/examples/ip_reassembly/main.c b/examples/ip_reassembly/main.c index 6e4c11c3c7..3ebf895aa0 100644 --- a/examples/ip_reassembly/main.c +++ b/examples/ip_reassembly/main.c @@ -126,7 +126,7 @@ struct mbuf_table { uint32_t len; uint32_t head; uint32_t tail; - struct rte_mbuf *m_table[0]; + struct rte_mbuf *m_table[]; }; struct rx_queue { diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c index de799f698b..1f1c9c9c52 100644 --- a/examples/ptpclient/ptpclient.c +++ b/examples/ptpclient/ptpclient.c @@ -90,7 +90,7 @@ struct sync_msg { struct follow_up_msg { struct ptp_header hdr; struct tstamp precise_origin_tstamp; - uint8_t suffix[0]; + uint8_t suffix[]; } __rte_packed; struct delay_req_msg { @@ -102,7 +102,7 @@ struct delay_resp_msg { struct ptp_header hdr; struct tstamp rx_tstamp; struct port_id req_port_id; - uint8_t suffix[0]; + uint8_t suffix[]; } __rte_packed; struct ptp_message {