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 671CC43AF1; Tue, 13 Feb 2024 08:48:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3B79D402AD; Tue, 13 Feb 2024 08:48:04 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id ABB844027B for ; Tue, 13 Feb 2024 08:48:02 +0100 (CET) Received: from [192.168.149.214] (unknown [85.26.189.205]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 9A90D50; Tue, 13 Feb 2024 10:48:01 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 9A90D50 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1707810482; bh=+cx7G2CYIYBwplFPULYOV+RqbuimnqJYwAZ9TVLrwJg=; h=Date:Subject:To:References:From:In-Reply-To:From; b=L2RwNIOywwqSq3LU+daiITZtqOohBjm+cYq3x0/FOAFc18I/sFBgteUlSrogAW/i7 FHc5Y2cfGVIO2UU1DJ4m/wihb6aa1MuiP44l8QnlRerGlj0Edt94h6KEp0zJTLjhsI R4FuDgUnRMyWWfy1iz7bJYz1+lXMFdHoJK+BQ2ck= Message-ID: <2171e7ad-824f-490d-a917-e46bb1fa8ffb@oktetlabs.ru> Date: Tue, 13 Feb 2024 10:47:46 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] common/sfc: replace out of bounds condition with static_assert Content-Language: en-US To: =?UTF-8?Q?Morten_Br=C3=B8rup?= , Stephen Hemminger , dev@dpdk.org References: <20240118201843.189978-1-stephen@networkplumber.org> <98CBD80474FA8B44BF855DF32C47DC35E9F178@smartserver.smartshare.dk> From: Andrew Rybchenko In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F178@smartserver.smartshare.dk> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 1/19/24 02:05, Morten Brørup wrote: >> From: Stephen Hemminger [mailto:stephen@networkplumber.org] >> Sent: Thursday, 18 January 2024 21.18 >> >> 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. >> >> 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(-) >> >> 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 >> >> -#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ørup > Acked-by: Andrew Rybchenko