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 9492D438F1; Wed, 17 Jan 2024 18:11:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 577AE4025E; Wed, 17 Jan 2024 18:11:40 +0100 (CET) Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by mails.dpdk.org (Postfix) with ESMTP id 5902C4014F for ; Wed, 17 Jan 2024 18:11:39 +0100 (CET) Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6d9b37f4804so7335019b3a.1 for ; Wed, 17 Jan 2024 09:11:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1705511498; x=1706116298; 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=b/fEl78LtJqNOSL3SpSB3DhkgBWpC/gN14EE7sFYcEo=; b=SH6PtMT9HxvmuL+yNoxb+VwD2M78H/+qPBINXiIm16tKzot9+onSOwp+og454cWz1N /V4sehNh5RpA+PGBKaSjUXOip6RWvkNPjDMDn5PS5zbsStfF34eS65My2xjE5WgIUyo5 o/IftWh8RNHu6qQh6hhQrmOj2BJRDC283XwrmnFNZLy8Uy8ZdwFo9+5zU/W5c7hhK2ZJ pYyPGVTGCNwRqs57vEIcBqh8745sNwG93m2izuZrrVTHMAtP6XhNMT7SBguI9dmjTt6S hS7kbHb/m+JDhiV3+MMnTdwuXsJBZWQ9rSaMOr9pvVw9jsitMMC6hMY3hcIw/Ip5smin Y1JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705511498; x=1706116298; 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=b/fEl78LtJqNOSL3SpSB3DhkgBWpC/gN14EE7sFYcEo=; b=ihiy1o+Vxi6VwokHfnx20qN3txDtr3MGP9zlP4em/+SUvRrnPvJo5UeKfddsgcndG3 Ze8NH1OXEA0uPwHsvP0r21HFm1bw/dwGn63mLNZqpQuAIC/3EA63jhMel5w4zXSbT3Xc V7ggorvnQRPfjFJTvQN9nkSzDNZzQ0p1wdt8V4x+S57JfgVkVgf+wH529BQ7JcQET61O 4Rn3a2WzcJtPN3y5HQJ0MybPA50S0mhin47D5ua2zOaiU9U3zfjrAdmIzUU/ZaY0RwgY YsWzXyVBcWIEL72oGUkiUtIFaUahLmbDJ7xbOHwO9a3ILMAbY1rWZF3G8LbghLsGC7Hp tSSA== X-Gm-Message-State: AOJu0YwoeBA1lTmZziIP2ui/7K1wG17FNym83QFWrO1sXRA1IAZq5x9/ +Gf0ZhTEMbxdx8bEJxKbgikAzXofYXHea3SWJxEEqvz3UGyMR0EF5OUJNa2WWLg= X-Google-Smtp-Source: AGHT+IEQxC694Wta6lscr4DG4ORHx7K/zHb+cCKM3SZi7vQ6aj4U88r8zktTykAMphnHK2ItgbA4KQ== X-Received: by 2002:a05:6a21:3390:b0:19a:ecc2:f308 with SMTP id yy16-20020a056a21339000b0019aecc2f308mr1759995pzb.35.1705511498282; Wed, 17 Jan 2024 09:11:38 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id ei29-20020a056a0080dd00b006d9ae6fe867sm1689417pfb.110.2024.01.17.09.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 09:11:38 -0800 (PST) Date: Wed, 17 Jan 2024 09:11:36 -0800 From: Stephen Hemminger To: Mattias =?UTF-8?B?UsO2bm5ibG9t?= Cc: dev@dpdk.org, Morten =?UTF-8?B?QnLDuHJ1cA==?= , Tyler Retzlaff Subject: Re: [PATCH v3 5/5] eal: replace out of bounds VLA with static_assert Message-ID: <20240117091136.6bdb72ec@hermes.local> In-Reply-To: <2e1c560d-f19c-4a3c-a066-2e80a9c71f86@lysator.liu.se> References: <20231111172153.57461-1-stephen@networkplumber.org> <20240116184307.162882-1-stephen@networkplumber.org> <20240116184307.162882-6-stephen@networkplumber.org> <2e1c560d-f19c-4a3c-a066-2e80a9c71f86@lysator.liu.se> 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, 17 Jan 2024 08:53:44 +0100 Mattias R=C3=B6nnblom wrote: > > * Triggers an error at compilation time if the condition is true. > > */ > > -#define RTE_BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condit= ion)])) > > +#define RTE_BUILD_BUG_ON(condition) { static_assert(!(condition), #con= dition); } > > =20 > > /*********** Cache line related macros ********/ > > =20 >=20 > Should one use RTE_BUILD_BUG_ON() or static_assert() in new DPDK code? >=20 > If static_assert() occasionally needs a work-around, it sounds like=20 > keeping using RTE_BUILD_BUG_ON() everywhere is the better choice. Either choice is the same. Keeping the macro instead of directly using static_assert will reduce the effort to change when the next C standard introduces something different. But using static_assert() can allow for a better warning message.