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 3CD85A0573 for ; Wed, 4 Mar 2020 13:33:21 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 25AD31BFCD; Wed, 4 Mar 2020 13:33:21 +0100 (CET) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by dpdk.org (Postfix) with ESMTP id 4FD401BFB5 for ; Wed, 4 Mar 2020 13:33:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583325199; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=IQjCFW/K339wa91UawF4GPi2AWav+J5GvREhqrXLIXw=; b=Hm5H1/lDnD0jdtE2074RQgsFiTf5BKZx0qiJ9+I91DB4tfr+eMjqzKzOzfXZYZvGvaExyM 6xRLJU9jt9xRnZ2YaanD+6zbrwl/+TXdEmWD5rM6ePT42kfBjbfB2ohSFqMmz+BrnMlFHp k5Rgg3JeWjl1OzmzN8oWE1yA3vn6AfQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-269-tunTgxr9PnyXM0qaOSKHqQ-1; Wed, 04 Mar 2020 07:33:11 -0500 X-MC-Unique: tunTgxr9PnyXM0qaOSKHqQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B7B78107ACC7; Wed, 4 Mar 2020 12:33:09 +0000 (UTC) Received: from [10.33.36.63] (unknown [10.33.36.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5987A5C219; Wed, 4 Mar 2020 12:32:55 +0000 (UTC) To: Gavin Hu , dev@dpdk.org Cc: nd@arm.com, thomas@monjalon.net, david.marchand@redhat.com, jerinj@marvell.com, Honnappa.Nagarahalli@arm.com, ruifeng.wang@arm.com, phil.yang@arm.com, stable@dpdk.org References: <20200303162728.93744-1-gavin.hu@arm.com> From: Kevin Traynor Autocrypt: addr=ktraynor@redhat.com; keydata= mQINBF2J2awBEADUEPNhgNI+nJNgiTAUcw4YIgVXEoHlsNPyyzG1BEXkWXALy0Y3fNTiw6+r ltWDkF9jzL9kfkecgQ67itGfk1OaBXgSGKuw1PUpxAwX2Bi76LAR6M5OsyGM9TSVVQwARalz hMwRBIZPzPc7or6Pw7jAOJ8SQGJ1Zlp1YJCjrvpe87V1tH/LY8Wnxn/EuoseFmWILAQZAtYS tGjcrAgYn3SPMLR1B0BP5bTBY06vWQjiufH8drenfDnMJAzuBdG1mqjnTqCjULZ3Hunv4xqZ aMnkvL/K5Tj1c12Oe4930EE53LrXIBUltRg5mBudSWHnC7twjH0082HH9f963Z/2UI63SFIT iUvRvAzJYytgy7XnWLQ0+goZBADKYfolOuC0H8VgCaux8u8KFF28Dy+N6TV2KI58jTlyg1Zu l7QwykZpnOkJFiy37Gfbu3YEOzO72cP/S7/A+zvuqkxi63jyEkd+FY99vLt/HN2MUZwRmKDw UPbLkmrs8WU01/POVsqDcfvz7vu2St8hqqTiSIdQGS2zyTKB2/DvPSM3jws3udkIYSuhn+X4 QBiV6lkVZ7DSE6a065gnAauAql+b32Eymy+xnG5jCt1tR+0Cp2VZYCR9OU2gmomUKBDoX/He pSgED01CqYPNjN+TddirwmQX7ep4DtXc8FWvv2g/pq9WZFQk2QARAQABtCNLZXZpbiBUcmF5 bm9yIDxrdHJheW5vckByZWRoYXQuY29tPokCTgQTAQgAOBYhBAoiOaH51tHF7VYtEI9CINER a+yJBQJdidmsAhsD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K2laDaoIjTJk9YYv3iwCsqPd5feU= Message-ID: Date: Wed, 4 Mar 2020 12:32:54 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200303162728.93744-1-gavin.hu@arm.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH v1] mbuf: replace zero-length marker with unnamed union X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" On 03/03/2020 16:27, Gavin Hu wrote: > gcc 10.0.1 reports: error: array subscript 0 is outside the bounds of an > interior zero-length array 'RTE_MARKER64' {aka 'long unsigned int[0]'} > [-Werror=3Dzero-length-bounds] 310 | *(uint64_t *)(&mbuf->rearm_data) = =3D > val; >=20 > 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] >=20 > Fix by using unnamed union and struct. >=20 > https://bugs.dpdk.org/show_bug.cgi?id=3D396 >=20 > Bugzilla ID: 396 >=20 > [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html >=20 > Fixes: 3e6181b07038 ("mbuf: use structure marker from EAL") > Cc: stable@dpdk.org >=20 > Signed-off-by: Gavin Hu > --- > lib/librte_mbuf/rte_mbuf_core.h | 54 +++++++++++++++++++-------------- > 1 file changed, 32 insertions(+), 22 deletions(-) >=20 > diff --git a/lib/librte_mbuf/rte_mbuf_core.h b/lib/librte_mbuf/rte_mbuf_c= ore.h > index b9a59c879..5390ddcfa 100644 > --- a/lib/librte_mbuf/rte_mbuf_core.h > +++ b/lib/librte_mbuf/rte_mbuf_core.h > @@ -480,31 +480,41 @@ struct rte_mbuf { > =09=09rte_iova_t buf_physaddr; /**< deprecated */ > =09} __rte_aligned(sizeof(rte_iova_t)); > =20 > -=09/* next 8 bytes are initialised on RX descriptor rearm */ > -=09RTE_MARKER64 rearm_data; > -=09uint16_t data_off; > - > -=09/** > -=09 * Reference counter. Its size should at least equal to the size > -=09 * of port field (16 bits), to support zero-copy broadcast. > -=09 * It should only be accessed using the following functions: > -=09 * rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and > -=09 * rte_mbuf_refcnt_set(). The functionality of these functions (atomi= c, > -=09 * or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC > -=09 * config option. > -=09 */ > =09RTE_STD_C11 > =09union { > -=09=09rte_atomic16_t refcnt_atomic; /**< Atomically accessed refcnt */ > -=09=09/** Non-atomically accessed refcnt */ > -=09=09uint16_t refcnt; > -=09}; > -=09uint16_t nb_segs; /**< Number of segments. */ > +=09=09/* next 8 bytes are initialised on RX descriptor rearm */ > +=09=09uint64_t rearm_data; > +=09=09RTE_STD_C11 > +=09=09struct { > +=09=09=09uint16_t data_off; > + > +=09=09=09/** > +=09=09=09 * Reference counter. Its size should at least equal to > +=09=09=09 * the size of port field (16 bits), to support > +=09=09=09 * zero-copy broadcast. It should only be accessed > +=09=09=09 * using the following functions: > +=09=09=09 * rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), > +=09=09=09 * and rte_mbuf_refcnt_set(). The functionality of > +=09=09=09 * these functions (atomic, or non-atomic) is > +=09=09=09 * controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC > +=09=09=09 * config option. > +=09=09=09 */ > +=09=09=09RTE_STD_C11 > +=09=09=09=09union { > +=09=09=09=09=09/**< Atomically accessed refcnt */ > +=09=09=09=09=09rte_atomic16_t refcnt_atomic; > +=09=09=09=09=09/** Non-atomically accessed refcnt */ > +=09=09=09=09=09uint16_t refcnt; > +=09=09=09=09}; > +=09=09=09uint16_t nb_segs; /**< Number of segments. */ > =20 > -=09/** Input port (16 bits to support more than 256 virtual ports). > -=09 * The event eth Tx adapter uses this field to specify the output por= t. > -=09 */ > -=09uint16_t port; > +=09=09=09/** Input port (16 bits to support more than 256 > +=09=09=09 * virtual ports). The event eth Tx adapter uses this > +=09=09=09 * field to specify the output port. > +=09=09=09 */ > +=09=09=09uint16_t port; > +=09=09}; > +=09}; > =20 > =09uint64_t ol_flags; /**< Offload features. */ > =20 >=20 Hi Gavin, this causes some errors on x86: # gcc --version | head -1 gcc (GCC) 10.0.1 20200216 (Red Hat 10.0.1-0.8) In file included from ../lib/librte_eal/common/include/arch/x86/rte_byteorder.h:13, from ../drivers/net/sfc/sfc_ef10_rx.c:14: ../drivers/net/sfc/sfc_ef10_rx.c: In function =91sfc_ef10_rx_process_event= =92: ../drivers/net/sfc/sfc_ef10_rx.c:309:39: error: subscripted value is neither array nor pointer nor vector 309 | RTE_BUILD_BUG_ON(sizeof(m->rearm_data[0]) !=3D sizeof(rxq->rearm_data)); | ^ ../lib/librte_eal/common/include/rte_common.h:292:65: note: in definition of macro =91RTE_BUILD_BUG_ON=92 292 | #define RTE_BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) | ^~~~~~~~~ ../drivers/net/sfc/sfc_ef10_rx.c:310:15: error: subscripted value is neither array nor pointer nor vector 310 | m->rearm_data[0] =3D rxq->rearm_data; |