]> git.droids-corp.org - dpdk.git/commitdiff
lib: use C99 syntax for zero-size arrays
authorAdrien Mazarguil <adrien.mazarguil@6wind.com>
Thu, 8 Sep 2016 12:25:04 +0000 (14:25 +0200)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 13 Sep 2016 13:35:28 +0000 (15:35 +0200)
Exported header files used by applications should allow the strictest
compiler flags. Language extensions used in many places must be explicitly
marked or removed to avoid warnings and compilation failures.

The extension keyword is used whenever the C99 syntax cannot do it.

This commit prevents the following errors:

 error: ISO C forbids zero-size array `[...]'

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
lib/librte_acl/rte_acl.h
lib/librte_cryptodev/rte_cryptodev.h
lib/librte_cryptodev/rte_cryptodev_pmd.h
lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
lib/librte_hash/rte_fbk_hash.h
lib/librte_ip_frag/rte_ip_frag.h
lib/librte_lpm/rte_lpm.h
lib/librte_mbuf/rte_mbuf.h
lib/librte_pipeline/rte_pipeline.h
lib/librte_ring/rte_ring.h
lib/librte_sched/rte_bitmap.h

index 8d4e2a681775712768e1184cad18dedb448fcefd..caa91f7eabf96e055a3c41405f275b546fcd9eaf 100644 (file)
@@ -144,7 +144,7 @@ struct rte_acl_rule_data {
        struct rte_acl_field field[fld_num];         \
 }
 
-RTE_ACL_RULE_DEF(rte_acl_rule, 0);
+RTE_ACL_RULE_DEF(rte_acl_rule,);
 
 #define        RTE_ACL_RULE_SZ(fld_num)        \
        (sizeof(struct rte_acl_rule) + sizeof(struct rte_acl_field) * (fld_num))
index affbdecc89190807e0c91066cca58ee7dba13c3c..1e30a1978c69e9cf5c7de68452dfbea4cdf358f0 100644 (file)
@@ -759,7 +759,7 @@ struct rte_cryptodev_sym_session {
        } __rte_aligned(8);
        /**< Public symmetric session details */
 
-       char _private[0];
+       char _private[];
        /**< Private session material */
 };
 
index 7d049ea38b8d3a661aae98b7e72f2d30b90f7f99..42e7b799d01f0c5a2e29cfd293eddf63c96a1a64 100644 (file)
@@ -71,7 +71,7 @@ struct rte_cryptodev_session {
                struct rte_mempool *mp;
        } __rte_aligned(8);
 
-       char _private[0];
+       __extension__ char _private[0];
 };
 
 struct rte_cryptodev_driver;
index 2acdfd9bc5be316c9854e52cbc47d4d28e5eb900..7f458a3608649ea4a1341aca098006066f406985 100644 (file)
@@ -102,7 +102,7 @@ struct rte_kni_fifo {
        volatile unsigned read;      /**< Next position to be read */
        unsigned len;                /**< Circular buffer length */
        unsigned elem_size;          /**< Pointer size - for 32/64 bit OS */
-       void * volatile buffer[0];   /**< The buffer contains mbuf pointers */
+       void *volatile buffer[];     /**< The buffer contains mbuf pointers */
 };
 
 /*
index a430961d0e4af7dd8239c092a68685261854ef56..bd46048f9fe3071e6a45bee0dfe4fa3c411aeb60 100644 (file)
@@ -115,7 +115,7 @@ struct rte_fbk_hash_table {
        uint32_t init_val;              /**< For initialising hash function. */
 
        /** A flat table of all buckets. */
-       union rte_fbk_hash_entry t[0];
+       union rte_fbk_hash_entry t[];
 };
 
 /**
index 9ac7081c04ac7ea310c12882922d4c51083b65c6..69596ab48a78fea901d6a37f75ccb018ca59359b 100644 (file)
@@ -124,7 +124,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. */
-       struct ip_frag_pkt pkt[0];        /**< hash table. */
+       struct ip_frag_pkt pkt[];         /**< hash table. */
 };
 
 /** IPv6 fragment extension header */
index dbe5483c20e53912b7545f496d29d3031129c6de..f8727572540822695aa40d8f2b2160c99817225c 100644 (file)
@@ -193,7 +193,7 @@ struct rte_lpm_v20 {
                        __rte_cache_aligned; /**< LPM tbl24 table. */
        struct rte_lpm_tbl_entry_v20 tbl8[RTE_LPM_TBL8_NUM_ENTRIES]
                        __rte_cache_aligned; /**< LPM tbl8 table. */
-       struct rte_lpm_rule_v20 rules_tbl[0] \
+       struct rte_lpm_rule_v20 rules_tbl[]
                        __rte_cache_aligned; /**< LPM rules. */
 };
 
index 7ea66ed9c6b5a2c73ccc89dcba22d768169090b8..7ae65549069b95f192c14ee3b0fa3bd9b90d3612 100644 (file)
@@ -756,8 +756,11 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask);
 
 /* define a set of marker types that can be used to refer to set points in the
  * mbuf */
+__extension__
 typedef void    *MARKER[0];   /**< generic marker for a point in a structure */
+__extension__
 typedef uint8_t  MARKER8[0];  /**< generic marker with 1B alignment */
+__extension__
 typedef uint64_t MARKER64[0]; /**< marker that allows us to overwrite 8 bytes
                                * with a single assignment */
 
index 84d1802518d52536cd9604cf44bb659a22bf98a0..b0b46152e09e35b13dd5e7c3c7bd6a4188e96a9d 100644 (file)
@@ -252,7 +252,7 @@ struct rte_pipeline_table_entry {
                uint32_t table_id;
        };
        /** Start of table entry area for user defined actions and meta-data */
-       uint8_t action_data[0];
+       __extension__ uint8_t action_data[0];
 };
 
 /**
index 0e22e6946fe9b380d40ada2e9ec239883a31ef7e..dfe07a24d2e8812993ba4d8488eebb9cec7fa5e7 100644 (file)
@@ -187,7 +187,7 @@ struct rte_ring {
        struct rte_ring_debug_stats stats[RTE_MAX_LCORE];
 #endif
 
-       void * ring[0] __rte_cache_aligned; /**< Memory space of ring starts here.
+       void *ring[] __rte_cache_aligned;   /**< Memory space of ring starts here.
                                             * not volatile so need to be careful
                                             * about compiler re-ordering */
 };
index ff675c5803f1ce97661c595664522ff73783da81..1b5df0218ec11ef57ad18c4abbac31dd5e663ac8 100644 (file)
@@ -103,7 +103,7 @@ struct rte_bitmap {
        uint32_t go2;     /**< Bitmap scan: Go/stop condition for current array2 cache line */
 
        /* Storage space for array1 and array2 */
-       uint8_t memory[0];
+       uint8_t memory[];
 };
 
 static inline void