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 8229343903; Fri, 19 Jan 2024 23:14:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 00187402AD; Fri, 19 Jan 2024 23:14:13 +0100 (CET) Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) by mails.dpdk.org (Postfix) with ESMTP id B996E4029F for ; Fri, 19 Jan 2024 23:14:12 +0100 (CET) Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-5cfb81124ecso657784a12.2 for ; Fri, 19 Jan 2024 14:14:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1705702451; x=1706307251; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LBmlsGfyrgpfJGuiMNQADEJ2akGS3AwSEfb53X5ke4Q=; b=CGWs/WxnrlwVLWXA3ay2jqB/RGufajsBtFkNvc6U5vqwNHcxjWitN2iiYEk5Aetegk /2nrGCvsph0phd/wtJs5Gdhuw4zofQJzButvNCMon75EOI9/jo4ar9W0J6ZBneoYwXjB emxjPNyS5F7pW8XhLBXy+cOd4UBz188lXQ6afri5819aXQomcuIm96JmBQQtb7SsXrox DYK5xoExgHV14zHSLfhVWgkRv12DhKyFyG7iFwXlfVentBOZExiBC7otLgIWV54BrDUj TwU2ouYvTf6taI910onb2KevPJDWDIGIL5GJWxnBlcJjRp0Igm3L9rfdF+W8oJSH3JZ2 5RAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705702451; x=1706307251; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LBmlsGfyrgpfJGuiMNQADEJ2akGS3AwSEfb53X5ke4Q=; b=RJVeFk295JE5heqwan2MaFzK3tuEu2x666+/vennvazKNSOJ1T5Dx/i/iHUo3YNYNr 96oCstSt4Oo8WMl27L4t6AdpnNsKu0MtxpOWp7I/Eu//WuXDsHNDhbN4X9XP47+BN31q kaVmFJwodis2wGfDoGCL91uGBoISwwz1UpC1/nxLTOyFtkTzqnok06gz4G2LpYjT5iVx ZSY5XJU4Weik5+6UAmLrGw/aRSXXalFkYA//vQsyqV1NIg7bO9+FGKxsFhkp83AmCa5c h7vNpwPYBxtDd/TsLY85mP51T1n7sEAOi+pcyqDbZltH0lQ3FCfAIFamqa9d10oKceOJ DUjQ== X-Gm-Message-State: AOJu0YxSsLnhN/DX7t9a66AVBVNKfMOIABSdvLB5tCr9JR8j8LXKuFWl YPahyGI2jehBTkt/t9lDV5RkNsaurabfowNwBa+TREEFHm9BDqtpG4UCmoaP/3lZaK1ybDlg3PE WgdU= X-Google-Smtp-Source: AGHT+IFqjNE0T9sbNtoqBGIu3BD2eo1PEWAv1CZpDonVYshfSxU5K9q9D1eHoR6qyBqrGZtjG5cXjw== X-Received: by 2002:a17:903:5c5:b0:1d7:2047:80bb with SMTP id kf5-20020a17090305c500b001d7204780bbmr534053plb.105.1705702451689; Fri, 19 Jan 2024 14:14:11 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id nd4-20020a17090b4cc400b002905ef2c4b8sm919371pjb.47.2024.01.19.14.14.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 14:14:11 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , =?UTF-8?q?Morten=20Br=C3=B8rup?= Subject: [PATCH v2] common/sfc: replace out of bounds condition with static_assert Date: Fri, 19 Jan 2024 14:13:32 -0800 Message-ID: <20240119221401.68182-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118201843.189978-1-stephen@networkplumber.org> References: <20240118201843.189978-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 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 Acked-by: Morten Brørup --- v2 - add assert.h to make sure it works in other environments drivers/common/sfc_efx/base/efx.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 +#include + #include "efx_annote.h" #include "efsys.h" #include "efx_types.h" @@ -17,8 +19,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) #define EFX_ARRAY_SIZE(_array) \ (sizeof (_array) / sizeof ((_array)[0])) -- 2.43.0