From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1094E438F8; Fri, 19 Jan 2024 00:05:18 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C6AB540274; Fri, 19 Jan 2024 00:05:17 +0100 (CET) Received: from dkmailrelay1.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id 5A8B74026F for ; Fri, 19 Jan 2024 00:05:17 +0100 (CET) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesys.local [192.168.4.10]) by dkmailrelay1.smartsharesystems.com (Postfix) with ESMTP id 357DF2071A; Fri, 19 Jan 2024 00:05:17 +0100 (CET) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [PATCH] common/sfc: replace out of bounds condition with static_assert X-MimeOLE: Produced By Microsoft Exchange V6.5 Date: Fri, 19 Jan 2024 00:05:13 +0100 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9F178@smartserver.smartshare.dk> In-Reply-To: <20240118201843.189978-1-stephen@networkplumber.org> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH] common/sfc: replace out of bounds condition with static_assert Thread-Index: AdpKS5KYZIUQr0QTQ8edf8ht9Jc6FgAFcZCw References: <20240118201843.189978-1-stephen@networkplumber.org> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Stephen Hemminger" , Cc: "Andrew Rybchenko" 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 > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > Sent: Thursday, 18 January 2024 21.18 >=20 > The sfc base code had its own definition of static assertions > using the out of bound array access hack. Replace it with a > static_assert like rte_common.h. >=20 > Fixes: f67e4719147d ("net/sfc/base: fix coding style") > Signed-off-by: Stephen Hemminger > --- > drivers/common/sfc_efx/base/efx.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/common/sfc_efx/base/efx.h > b/drivers/common/sfc_efx/base/efx.h > index 3312c2fa8f81..9ce266c43610 100644 > --- a/drivers/common/sfc_efx/base/efx.h > +++ b/drivers/common/sfc_efx/base/efx.h > @@ -17,8 +17,8 @@ > extern "C" { > #endif >=20 > -#define EFX_STATIC_ASSERT(_cond) \ > - ((void)sizeof (char[(_cond) ? 1 : -1])) > +#define EFX_STATIC_ASSERT(_cond) \ > + do { static_assert((_cond), "assert failed" #_cond); } while (0) This probably works for the DPDK project. For other projects using the same file, it might also need "#include = " (containing the static_assert convenience macro for C), and = possibly your workaround for toolchain issues with missing C11 macro in = FreeBSD. Maybe not in this file, but somewhere. Acked-by: Morten Br=F8rup