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 590C243AAF; Wed, 7 Feb 2024 23:34:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CF34F402A9; Wed, 7 Feb 2024 23:34:48 +0100 (CET) Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by mails.dpdk.org (Postfix) with ESMTP id BD5534027D for ; Wed, 7 Feb 2024 23:34:46 +0100 (CET) Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6e02597a0afso825650b3a.1 for ; Wed, 07 Feb 2024 14:34:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1707345286; x=1707950086; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=6qfQZma8DlKlacs4/UABbeFWbfNme6QtTOuHrEVzKFc=; b=FMeJ4rSUV0kr2EipYo6GFtjTCk7Ym+XN5Jy3QPD5ddqFzG/Mog9OxuR636HOzUp4+a bt8LZXh7Sk+EynhxW0qRgl9dNPd/APi3djDIz30w0lu/c+QI6/+39Ju/Rm4GG58/TYhQ MQIKcK4HhmOK4bLrrIkzXlzoIrH6nvAbnoqhEwwXCSIRZE3NNKdizG92u40U15AzUnl5 8RVnWB0WnurfoCbQuxwfkjIuUk+9/FRioewwQA7CECu1jo8F23alRSxtci8RiRimmywO x20a5A2dUH+9Szh4AHfkizB1PLezTET8ZwppRv643fvOuuJUxf4UfU+TGfw7+NhHdnAA Y1Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707345286; x=1707950086; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6qfQZma8DlKlacs4/UABbeFWbfNme6QtTOuHrEVzKFc=; b=V74ZsI3QX0xokmt+QpPbFB5ICoWCjzBgV2DtIVMqbYaPEh+arjR3ZN1oCnr/MdwvHH ftXtReHXKhAtlF7nOIzLDKjRDT8mLso/x/7h6UkPpmIRFOzEmhU8yEhNpwdUXkYPXOEx p72xZ0R3+25KjxXAhfqbpg7T66hWTLozKhTFM/xGdjvriBpR+ntKUiez8kUlhKOpQJ46 cFb5jMLm9528AcLJwImb23XJxesw6Pperhu9ptcXAt19fGsJOy2FzscwkUJoO9IVpQvd 8SSE8mVnfynhrJ1k2lmaRcxliNC/lqN232JtjPYdNfnHwxhaBpqkqSiAPQyVPvM/r82m 8dFA== X-Gm-Message-State: AOJu0YzE/veEAZoCF3KaoNWx6otyrWc95yqMWNA89s9TFS4DWkMZ2IsU oAgnSdZ0vCIs5BaD1DU7fxOGzzvfLMQTKQZWJKtiPg99n3TuAiihR83pknFpXp8= X-Google-Smtp-Source: AGHT+IHHj07gBxPpAQcXr/qCf7KglMUBaT2G/mHp2wdQgwDqRT9q0gYifdU9GzRThg1gPJgNEUZwEA== X-Received: by 2002:a05:6a00:2fcc:b0:6e0:42cb:d794 with SMTP id fn12-20020a056a002fcc00b006e042cbd794mr4064564pfb.34.1707345284336; Wed, 07 Feb 2024 14:34:44 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXtmCiPOuJ8WSNaDjE1S3WlmrDx7cfMpuPWL1FLiW5/CpMiGmL3PMLRsFBXxim6ueeyd0A36GIme6goOzFOeeCVkLvAdU2YPZE= Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id r23-20020a638f57000000b005c662e103a1sm2198154pgn.41.2024.02.07.14.34.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 14:34:44 -0800 (PST) Date: Wed, 7 Feb 2024 14:34:42 -0800 From: Stephen Hemminger To: Ferruh Yigit Cc: dev@dpdk.org, Morten =?UTF-8?B?QnLDuHJ1cA==?= Subject: Re: [PATCH v2] common/sfc: replace out of bounds condition with static_assert Message-ID: <20240207143442.0aba4ebe@hermes.local> In-Reply-To: References: <20240118201843.189978-1-stephen@networkplumber.org> <20240119221401.68182-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 On Wed, 7 Feb 2024 19:10:37 +0000 Ferruh Yigit wrote: > On 1/19/2024 10:13 PM, Stephen Hemminger wrote: > > 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 > > Acked-by: Morten Br=C3=B8rup > > --- > > v2 - add assert.h to make sure it works in other environments > >=20 > > drivers/common/sfc_efx/base/efx.h | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > >=20 > > diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx= /base/efx.h > > index 3312c2fa8f81..38f2aed3e336 100644 > > --- a/drivers/common/sfc_efx/base/efx.h > > +++ b/drivers/common/sfc_efx/base/efx.h > > @@ -7,6 +7,8 @@ > > #ifndef _SYS_EFX_H > > #define _SYS_EFX_H > > =20 > > +#include > > + > > #include "efx_annote.h" > > #include "efsys.h" > > #include "efx_types.h" > > @@ -17,8 +19,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) > > =20 > > #define EFX_ARRAY_SIZE(_array) \ > > (sizeof (_array) / sizeof ((_array)[0])) =20 >=20 > Getting following build error with clang: What version of clang? It works for me with clang 16.0.6