]> git.droids-corp.org - dpdk.git/commitdiff
replace zero-length arrays with flexible ones
authorBruce Richardson <bruce.richardson@intel.com>
Fri, 3 Jun 2022 11:16:23 +0000 (12:16 +0100)
committerDavid Marchand <david.marchand@redhat.com>
Tue, 7 Jun 2022 14:44:21 +0000 (16:44 +0200)
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 revert and
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>
36 files changed:
app/test/test_table_tables.c
drivers/bus/dpaa/include/netcfg.h
drivers/bus/vmbus/rte_vmbus_reg.h
drivers/common/cnxk/roc_se.h
drivers/common/dpaax/dpaax_iova_table.h
drivers/common/mlx5/mlx5_prm.h
drivers/crypto/ipsec_mb/ipsec_mb_private.h
drivers/crypto/virtio/virtio_ring.h
drivers/crypto/virtio/virtqueue.h
drivers/net/atlantic/hw_atl/hw_atl_utils.h
drivers/net/cxgbe/clip_tbl.h
drivers/net/cxgbe/l2t.h
drivers/net/cxgbe/mps_tcam.h
drivers/net/cxgbe/smt.h
drivers/net/enic/base/vnic_devcmd.h
drivers/net/hinic/hinic_pmd_tx.h
drivers/net/nfp/nfpcore/nfp_nsp.h
drivers/net/virtio/virtio_ring.h
drivers/net/virtio/virtio_user/vhost_kernel.c
drivers/net/virtio/virtio_user/vhost_vdpa.c
drivers/net/virtio/virtqueue.h
drivers/regex/mlx5/mlx5_rxp.h
examples/ip_reassembly/main.c
examples/ptpclient/ptpclient.c
lib/cryptodev/cryptodev_pmd.h
lib/cryptodev/rte_cryptodev.h
lib/eventdev/rte_event_timer_adapter.h
lib/ip_frag/ip_reassembly.h
lib/ipsec/sa.h
lib/rib/rte_rib.c
lib/rib/rte_rib6.c
lib/table/rte_swx_table_learner.c
lib/table/rte_table_hash_key16.c
lib/table/rte_table_hash_key32.c
lib/table/rte_table_hash_key8.c
lib/vhost/rte_vhost.h

index 010dd5a7945cfbc3cb1bc2db0bf9e3c4853f1703..26908e6112fc973ad5ff96162afbd0a534da67ab 100644 (file)
@@ -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
index bb18a34e3d713b5c9112b2350fb6b6c1eebc3bdd..43c7e1cfe13910b7fdf20fb3720d773c70081e98 100644 (file)
@@ -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.
index 8562672979b0d72462907b6aee10ae0efca6fe68..a17ce40763424b9279710fa63ad8b63b507b0e3a 100644 (file)
@@ -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] */
index 145a1825bd609935efc374602697d60ee6382ada..a1d476a86de7bce33cb7fd0c2b94ba4b6abaac28 100644 (file)
@@ -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 {
index b1f2300c52b317d86d7d374e69b2480a6a90b016..9a18eafca02487b4770d51e8cbe8e10e48eecc6d 100644 (file)
@@ -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
index bc3e70a1d191075d4a92b7011f518e882d9308c0..654e5f44eefdbd2c4cb4303ee04e850b005c8b72 100644 (file)
@@ -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 pas[][0x40];
 };
 
 
@@ -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 pas[][0x40];
 };
 #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 register_data[][0x20];
 };
 
 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 register_data[][0x20];
 };
 #ifdef PEDANTIC
 #pragma GCC diagnostic error "-Wpedantic"
index e53101acf17860488c4226ff6182e209ec924c4d..e2c240dfc05d8690d7a861b41c6c15371aa1c48a 100644 (file)
@@ -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 */
 };
 
index ee306745668837b656f04897fe58c4c692e3d710..55839279fd8923b37b43171a9adf9dcf6abac603 100644 (file)
@@ -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 {
index c96ca629921b0d094d28fc2b0657a2ce8599cb29..cb08bea94f1c142a29b85b340b69100e5a9a2685 100644 (file)
@@ -88,7 +88,7 @@ struct virtqueue {
 
        uint16_t  *notify_addr;
 
-       struct vq_desc_extra vq_descx[0];
+       struct vq_desc_extra vq_descx[];
 };
 
 /**
index d8fab010cf595986974e7cfef2214d7d84d7331a..12ac9b041e23322a0316e844534ff10eec2480cf 100644 (file)
@@ -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 {
index d7689f4b7a3aa902b100a7e8a4dec5e5dab4943b..3b2be6645f2e175d1ffd079603e5ab621e668e7b 100644 (file)
@@ -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,
index 9845c9f9812430545597752b1fe8d601139dba29..e4c0ebedec9e88c4cbe5ab803a6d3d4a31390aaf 100644 (file)
@@ -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
index a359f52442fa9d01c02f3d81d53894818143d6df..363786bd387f976d0ef078181fbf76a6eec005e7 100644 (file)
@@ -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);
index a70e3a208575740cc1d6947ab399f2240ce57af2..531810e695edeead43f29e0ab451773c226a993b 100644 (file)
@@ -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);
index 3157bc8cb5eeebe2f9b965842df805345599046f..253a791c3f65de32cb922554af20863b85abf915 100644 (file)
@@ -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 */
index a3ec6299fbe15a2e9c971d46de13df43a1845efa..152f7abc53f48ad5ddc86ff4a0f3ed338556d324 100644 (file)
@@ -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 {
index e74cdeb191008c5c8723999fb2abe6465f8eb2b7..2184c15b4c0b818ed1e2265726cc438d0654d853 100644 (file)
@@ -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);
index 17a56b0a7341e3916649e953d9e45d24dfc916c7..e848c0b73b3dbb27c930aa5c2ace54ccd6f7e404 100644 (file)
@@ -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
index 986b56a7ca7d0bbcbbfb16fc7e24bb832a0f1f58..1aed08b2bdde0649c4685bff5ca8b0719f1db2ac 100644 (file)
@@ -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 */
index 82f25a8674b036f1ca6f7a85edb77bcdd731e4fd..bd13fe44b4c18749f80af73695e0c5f9a735d86a 100644 (file)
@@ -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 {
index 99c68cf62231541b67b6db46a577feb824352ee5..d100ed8762096352f51004a34bed5bda0e6161c8 100644 (file)
@@ -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. */
index 315e3b4ca3b2c7dfc277fef838cd023233c0b9d6..eddc577d7990be7a570c00e591a3ad23c224a174 100644 (file)
@@ -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. */
index 6e4c11c3c7e09636bedfdabde5eb7cd4a73efa0b..3ebf895aa01d47457a2043424489227f8c309c48 100644 (file)
@@ -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 {
index de799f698ba9a86be2a84feb73b54ba3fe6710a3..1f1c9c9c524fe8e3be622f07b7bc1102766b72d3 100644 (file)
@@ -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 {
index 7a7d3ee3f18544256cc16333e01646ae76c75ed3..3dcc3cb7edf714e7c889f38cc95beb223f6e4908 100644 (file)
@@ -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
index 585cee272781aaeadd7dfc80d73652aa58415fa1..56f459c6a05a3e0dfbff8a9d5c87c99fe9bd689f 100644 (file)
@@ -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 */
 };
 
index 4c91e5516ade02203ad17b755bdc9f4694c4b8e2..eab8e59a571cd51ae8e0e1843dc38d0c1a7463ec 100644 (file)
@@ -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.
         */
index 416fb66dd4858279d2da7f8a4e73e6f9560f7303..ef9d8c0d75ad1ee32495c4cd25fc73121c8cb252 100644 (file)
@@ -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_ */
index 46f9a4df5bb6571c3d5dee062695f4dee9207303..ce4af8ceb2a995f66c2fb70c9f0d00b332f2a968 100644 (file)
@@ -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 */
index f1fdddbbb44f56b90f2de51fc061639b18d53b84..b0794edf66f5a400f3bacd19bc596f7ff8c94a81 100644 (file)
@@ -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 {
index 650bf1b8f681a5e3d8adbfbc8c0d36d2207a07d8..19e4ff97c479c2d2a8add9ec71c08798c3426191 100644 (file)
@@ -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 {
index 222acfc9626a8ed2657c5b2a0a3af7a22d7415db..f7f8e8aea903ffd1fb2c74dd8ff05fe7bd9bcca2 100644 (file)
@@ -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
index ea8195dc17d133eb8b70836f1ced8ce5aa7d408c..04d7fd64bd973b0b4ff85f76fcfba7ab41465c60 100644 (file)
@@ -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
 
index 87f83ce6f5fb510a18dbb61dd4bcfbdff4e35c06..88d8f69c72edcae14efa476ed90b8c6c65819669 100644 (file)
@@ -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
 
index 7779a9d1a39da5f079b66151de043b9e2e694d60..035d2427694622c2c759c3f614df0592b863de41 100644 (file)
@@ -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
 
index 4683a5329961211ebdb4f10f0546d0549df8be35..617425e8d6d74d97060612ba1f5f72c5efee7e76 100644 (file)
@@ -158,7 +158,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 {
@@ -185,7 +185,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 {