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 895A34331D; Mon, 13 Nov 2023 18:12:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 58E1640A7D; Mon, 13 Nov 2023 18:12:59 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 76A064067E for ; Mon, 13 Nov 2023 18:12:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699895577; x=1731431577; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=lON20/f22h9oLsALTN1A4w1BDNxYVWMId9o3X4rGx8k=; b=QDrLM/Zdmz0LeRn/nxEw2h8NhTkCCyK54jrKG6ytC8OGQmYyKOyRtnrb xYcbD8CXnUOnGH7nD4+VRALyBg07tZvCs3zHfgF6skFCy5CjbCDmzEN1U tsxUFdyBR5xG0RCDx831+LL+SEOE2yG7+LqgjD4CyivMejDxwtCKwGutN aCHlC7XkHk3spBqokYMiGG+T74VJ/SC/nMg4+kjNayeOQnPlzTMRS7QrS n3aCdvPHqkjc1yrXvmNUqsd2J3cnki8KShTOdHTIINgLpm78hjD2azJ29 GVGRTiBGsIfFFFiGWCl1/JJrAAajW6jmOX3ZOT7SSVGc6Y6PRSB7NWR38 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10893"; a="389336368" X-IronPort-AV: E=Sophos;i="6.03,299,1694761200"; d="scan'208";a="389336368" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2023 09:12:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10893"; a="887973027" X-IronPort-AV: E=Sophos;i="6.03,299,1694761200"; d="scan'208";a="887973027" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga004.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 13 Nov 2023 09:12:56 -0800 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Mon, 13 Nov 2023 09:12:55 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34 via Frontend Transport; Mon, 13 Nov 2023 09:12:55 -0800 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (104.47.56.40) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.34; Mon, 13 Nov 2023 09:12:55 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=biPvVgdNqQsKkpVrX3Hh7v0J97cMwUPLMFqgQoSTwQvAwYP61cV4H2iEjaWJ4E68XPgNeOjYsIvB7SYCYjvIz9UbCUZhL5hEdeH321liccVEAPKK2KPkG4H5FDn0GqLA10vjdmFqoS10WcU3RDQ3Ke4mibK+/IghRajSN5n+EBMZYY+gBUIHNXgG9Cd7GcWDYByZ9GqeGDrOHI1pGl3mlKV+DqZwg53/whOcK/yACq5rlvU6zpM+y9kGmP+Qjwvmqh1Q/59rTEXiKK4PItJhp4RLJkorfxJiwLxpCGW+HYM5cATakcLo1XvOiZzK3cwXahi9VCmrbQB7QGAHkCngNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wUWD7RxZe9bjXYFU6tvJe7ZvZXifVpI4/Vlyt/FSYhY=; b=FX9GH9D/eVfI0IHZeeogZ9V+wOrEEED1WRP4idRNNNr4q0g0mJtlDodERwtt6gHofHm6pGwtEV39fRimNHg6hWweYvMOOanj0U9mO+rXnSs5kfRzpqzzISV4WgRcreFBvWyQCZ8mPHvsBsFezL8zDLumK316Y2MuKPF3BCUJH4zfpEGbYRtTBAW4aFcU+VcRXRyAtgyv1Ph+vnkJXSnML1mK9kjjdY42vPlcOgIpm46+CJt6818yoVaJw17qIA9b355m8V4/KwstlP+JAi/flbVXDXeR0R/opQjMPUXevm7SQbxOEAbcTmtN5i7HLgPQVNLX8QFtMsVa84+Ri17b8A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) by CY8PR11MB7779.namprd11.prod.outlook.com (2603:10b6:930:77::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.29; Mon, 13 Nov 2023 17:12:53 +0000 Received: from DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::8645:d921:ce8a:12ba]) by DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::8645:d921:ce8a:12ba%5]) with mapi id 15.20.6977.029; Mon, 13 Nov 2023 17:12:53 +0000 Date: Mon, 13 Nov 2023 17:12:48 +0000 From: Bruce Richardson To: Stephen Hemminger CC: , Morten =?iso-8859-1?Q?Br=F8rup?= , Tyler Retzlaff Subject: Re: [PATCH v2 3/3] eal: replace out of bounds VLA with static_assert Message-ID: References: <20231111172153.57461-1-stephen@networkplumber.org> <20231113170605.408281-1-stephen@networkplumber.org> <20231113170605.408281-4-stephen@networkplumber.org> Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231113170605.408281-4-stephen@networkplumber.org> X-ClientProxiedBy: DB9PR02CA0018.eurprd02.prod.outlook.com (2603:10a6:10:1d9::23) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|CY8PR11MB7779:EE_ X-MS-Office365-Filtering-Correlation-Id: b211770e-8488-4878-db30-08dbe46bc5b1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oT9At96PyJWiTo7bds7r3hjQ8kkWzzxJCRn8RIUMz0E7TTI1UgohVPq9LqED6dfNv62ErduDv41CfFvbnlBY3eit4huZwxXcGj0PGYOXOh2ZUGpu9mjwCi5XpGobR4V0BghA/9qAZ+YUrjKZWjurgqlQNadG6wk4a0OvEhHH4GrejEiPnST/OuzhiA/xXVwaWfB0U1bgwDkh33bFp8xRLYcYh7AL1t7CPt2rUKtoDz2AWK564koMR8sQNd61/cYDdUq0lP2AZZsy042Tkv9v8V7tuIqCXUvEWV0AQK53YmnPxXmB8t66+nBw485rT9a+Bhhhg2wA7bJz51MvdXucWiu084AtAyiMQHm5Plf0z787aWU7VKpdhndbd1vZ4GJuz6yZ82H8gBWvNquyaPktFE+N6AMP4+ZaiZNXKChe/4kAt8ZdzLAbn91meJfVv+AWq6Ed2VgVR11KOeqON6xgwRGdSDUxAm9b1L2Gqt+G6JEbBf9RQ2jGcaKm6ev8ZVpdsKYK7p9dtHpASuEpzx5S0PgCVjfzUieSmIqPXMKvHSu3uhsA8XicuKecTrhdgErh X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR11MB7309.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(396003)(376002)(136003)(39860400002)(366004)(346002)(230922051799003)(1800799009)(451199024)(64100799003)(186009)(26005)(66946007)(66556008)(66476007)(6916009)(54906003)(38100700002)(86362001)(82960400001)(83380400001)(6512007)(66574015)(6506007)(6666004)(2906002)(316002)(478600001)(6486002)(5660300002)(8936002)(8676002)(4326008)(44832011)(41300700001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?Bwct+ePkPkFykRn5KThjSjXkbGVSAyHlxcXGnLTRBxRLERaeP5cajLfBH2?= =?iso-8859-1?Q?uw/KUwBlw5S5epzXlJF8H7mrcosoafwhe/eIGBS4JvyZGdA//2BJ+5HUWX?= =?iso-8859-1?Q?N6nhZz8kyOSf8FFDaX4z6Tn/Xt6OAgnWWqvNNxlVOIbYGnO988BOgGFkwa?= =?iso-8859-1?Q?hJGGfxs5cTqqikBCP7DDHlhbTFhcwRE2qnUJyS+/+5ayNfNYibusor9wpS?= =?iso-8859-1?Q?O+oszg4fSWTOfCqHXsZgnFlJwNxOvhNZ6ulnTmS9CQd5TIHKxyhSzHrSYY?= =?iso-8859-1?Q?aa7CTgo5i7Lhk/Vh/l0Sjuapb61NuljQPXDBwYVZRH1YAA1VClEGCB5Up0?= =?iso-8859-1?Q?qBn0jImsF4bWxW5ygLuNjSIyrP/qTUHKNpXFiPJyMVS4ET3CMQY32zPpBx?= =?iso-8859-1?Q?Gf49E82jZ46Dyb5mehAQSJgvRwvi87i7p9T1t4nNJYwU3VWJW9dSZdpial?= =?iso-8859-1?Q?Xe01En52YMny4HIFMfrPGHm8DZADnryqEY0A6uimcQ9rGlRdxD9a6Yg/W7?= =?iso-8859-1?Q?aaOSLDEc3QbLCDSk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=?iso-8859-1?Q?FKIR1i8gBbPG9ap5dbjMgIj2hKpSxItPx8CVWSVDK4X0THoECaA9wHVM1F?= =?iso-8859-1?Q?Xwy6CRXnGNk9CeeYeGe/apFY7TXEMuyYA0h2D/1zSLjDMa9+MuipZ7eQkr?= =?iso-8859-1?Q?WAy+KBz1CJ/6uHaG91+1sCfVaMsJs5fw9cJBUTTrSlWFoCZa1lZ4DD2wV7?= =?iso-8859-1?Q?z4+M/wvznvrgElRH8n1+Mh1q0BALJh/qmurMLh/m1tCZwYrx9GJaqU9g?= =?iso-8859-1?Q?=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: b211770e-8488-4878-db30-08dbe46bc5b1 X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2023 17:12:53.4566 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QQamXCl720fEP9o/6MOr7mubqluSra2pgUTTnaoKN7cFlLpDziX4j3GfgN9ocsPVw9uQORQZuDHmQTGioM8vf+YfKdg4bSz9xGi2L+nQJo8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR11MB7779 X-OriginatorOrg: intel.com 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 Mon, Nov 13, 2023 at 09:06:05AM -0800, Stephen Hemminger wrote: > Both Gcc, clang and MSVC have better way to do compile time > assertions rather than using out of bounds array access. > The old method would fail if -Wvla is enabled because compiler > can't determine size in that code. Also, the use of new > _Static_assert will catch broken code that is passing non-constant > expression to RTE_BUILD_BUG_ON(). > > Signed-off-by: Stephen Hemminger > Acked-by: Morten Brørup > Acked-by: Tyler Retzlaff > --- > lib/eal/include/rte_common.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h > index c1ba32d00e47..bea7c0e57d5e 100644 > --- a/lib/eal/include/rte_common.h > +++ b/lib/eal/include/rte_common.h > @@ -16,6 +16,7 @@ > extern "C" { > #endif > > +#include > #include > #include > > @@ -495,7 +496,7 @@ rte_is_aligned(const void * const __rte_restrict ptr, const unsigned int align) > /** > * Triggers an error at compilation time if the condition is true. > */ > -#define RTE_BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) > +#define RTE_BUILD_BUG_ON(condition) static_assert(!(condition), #condition) > Acked-by: Bruce Richardson And as for the static_assert vs BUILD_BUG_ON debate, I think I'd go with using static_assert explicitly and only keeping BUILD_BUG_ON for backward compatbility. Reason being that you can give a reasonable error message with the assert.