From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D139AA0563; Sat, 7 Mar 2020 16:57:24 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DBE111BF90; Sat, 7 Mar 2020 16:57:23 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id B533FFEB; Sat, 7 Mar 2020 16:57:21 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F2C7930E; Sat, 7 Mar 2020 07:57:20 -0800 (PST) Received: from d874074c7da7.shanghai.arm.com (net-arm-thunderx2-04.shanghai.arm.com [10.169.40.184]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 330753F6C4; Sat, 7 Mar 2020 07:57:17 -0800 (PST) From: Gavin Hu To: dev@dpdk.org Cc: nd@arm.com, david.marchand@redhat.com, thomas@monjalon.net, ktraynor@redhat.com, jerinj@marvell.com, honnappa.nagarahalli@arm.com, ruifeng.wang@arm.com, phil.yang@arm.com, joyce.kong@arm.com, stable@dpdk.org Date: Sat, 7 Mar 2020 15:56:29 +0000 Message-Id: <20200307155629.45021-1-gavin.hu@arm.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200303162728.93744-1-gavin.hu@arm.com> References: <20200303162728.93744-1-gavin.hu@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2] mbuf: replace zero-length marker with unnamed union X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Declaring zero-length arrays in other contexts, including as interior members of structure objects or as non-member objects, is discouraged. Accessing elements of zero-length arrays declared in such contexts is undefined and may be diagnosed.[1] Fix by using unnamed union and struct. https://bugs.dpdk.org/show_bug.cgi?id=396 Bugzilla ID: 396 [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html Fixes: 3e6181b07038 ("mbuf: use structure marker from EAL") Cc: stable@dpdk.org Signed-off-by: Gavin Hu --- v2: * change 'uint64_t rearm_data' to 'uint_64_t rearm_data[1]' to fix the SFC PMD compiling error on x86. --- lib/librte_mbuf/rte_mbuf_core.h | 54 +++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf_core.h b/lib/librte_mbuf/rte_mbuf_core.h index b9a59c879..34cb152e2 100644 --- a/lib/librte_mbuf/rte_mbuf_core.h +++ b/lib/librte_mbuf/rte_mbuf_core.h @@ -480,31 +480,41 @@ struct rte_mbuf { rte_iova_t buf_physaddr; /**< deprecated */ } __rte_aligned(sizeof(rte_iova_t)); - /* next 8 bytes are initialised on RX descriptor rearm */ - RTE_MARKER64 rearm_data; - uint16_t data_off; - - /** - * Reference counter. Its size should at least equal to the size - * of port field (16 bits), to support zero-copy broadcast. - * It should only be accessed using the following functions: - * rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and - * rte_mbuf_refcnt_set(). The functionality of these functions (atomic, - * or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC - * config option. - */ RTE_STD_C11 union { - rte_atomic16_t refcnt_atomic; /**< Atomically accessed refcnt */ - /** Non-atomically accessed refcnt */ - uint16_t refcnt; - }; - uint16_t nb_segs; /**< Number of segments. */ + /* next 8 bytes are initialised on RX descriptor rearm */ + uint64_t rearm_data[1]; + RTE_STD_C11 + struct { + uint16_t data_off; + + /** + * Reference counter. Its size should at least equal to + * the size of port field (16 bits), to support + * zero-copy broadcast. It should only be accessed + * using the following functions: + * rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), + * and rte_mbuf_refcnt_set(). The functionality of + * these functions (atomic, or non-atomic) is + * controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC + * config option. + */ + RTE_STD_C11 + union { + /**< Atomically accessed refcnt */ + rte_atomic16_t refcnt_atomic; + /** Non-atomically accessed refcnt */ + uint16_t refcnt; + }; + uint16_t nb_segs; /**< Number of segments. */ - /** Input port (16 bits to support more than 256 virtual ports). - * The event eth Tx adapter uses this field to specify the output port. - */ - uint16_t port; + /** Input port (16 bits to support more than 256 + * virtual ports). The event eth Tx adapter uses this + * field to specify the output port. + */ + uint16_t port; + }; + }; uint64_t ol_flags; /**< Offload features. */ -- 2.25.0