From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A7D38C433F5 for ; Thu, 13 Jan 2022 13:42:16 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8339D83571; Thu, 13 Jan 2022 14:42:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="VgifONKO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0123F83518; Thu, 13 Jan 2022 14:41:59 +0100 (CET) Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C25CC834E0 for ; Thu, 13 Jan 2022 14:41:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qv1-xf35.google.com with SMTP id hu2so6563402qvb.8 for ; Thu, 13 Jan 2022 05:41:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2TToClotdF7Se5m8LDINff8DXCnJkhrCHUIudVwshrE=; b=VgifONKOMmzdw3Vy05B7+1c2F11nVpNoTKl55QDIUKaMHk0VGI2ikYbvOEVS2nB/NH qFTrz/a65p34KYkepsGbrYfniclWs/lVgyAjA29waCMF/06Mjpw1X0njcCzpoc4RncaT IdE6qKFd/iYPuZbvx9Y0TE3EXdMEckmuiD+Ng= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2TToClotdF7Se5m8LDINff8DXCnJkhrCHUIudVwshrE=; b=7rt6FbTk1QezFe3dWmTBwE9YDFE5Iit36+J2eVSQDR7chZpO8CxRVCU+3yw6KJ7ArQ 8mzxZJNcW3CV6PAQx399LXy3N1ILqQ2RqO6GC+ttP0Bqq6bOBerUm4iUTVPkF1kztTyU JDCb1R6UEtsSkV/n5rBrsX+FIADOIdK5z2MJr4NbAwMPHlGteK/CoHTJCea4dSQkSwCm WRl31fxHr026CbkoOus47z8FHUIZ3MZsoA03ChhGVhUS54x5kO9XdEYQyaWzvHBO67e3 0yiEM8uqsOAoujGtY3Gn6O81mDiozTypcblQe6HeypRz0dTcLpSqmtmBqUf0Belqrrl2 /QQw== X-Gm-Message-State: AOAM530XYd5zsy+7kKMAp/nSOPMHh/GjBPa4mMFWLu7H2R8DWXLXxPqe ynHl0CIBmrXDWOGj/PRfmmeIyQ== X-Google-Smtp-Source: ABdhPJwwVcvW7ZlM4Dfx+vy3iufhxUuRZqLK4XwEUaUcpsUTmEKwkQcwWQKxf8Faka8DFjuesMpjRw== X-Received: by 2002:a05:6214:2aac:: with SMTP id js12mr3888421qvb.48.1642081314530; Thu, 13 Jan 2022 05:41:54 -0800 (PST) Received: from bill-the-cat (2603-6081-7b01-cbda-2440-966a-5ce3-c6d0.res6.spectrum.com. [2603:6081:7b01:cbda:2440:966a:5ce3:c6d0]) by smtp.gmail.com with ESMTPSA id m13sm1722810qkk.122.2022.01.13.05.41.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jan 2022 05:41:54 -0800 (PST) Date: Thu, 13 Jan 2022 08:41:52 -0500 From: Tom Rini To: Simon Glass Cc: Rasmus Villemoes , U-Boot Mailing List , Bin Meng , Ilias Apalodimas , Bill Mills , Heinrich Schuchardt , =?iso-8859-1?Q?Fran=E7ois?= Ozog Subject: Re: [PATCH 04/31] stddef: Avoid warning with clang with offsetof() Message-ID: <20220113134152.GL9207@bill-the-cat> References: <20211101011734.1614781-1-sjg@chromium.org> <20211101011734.1614781-5-sjg@chromium.org> <20220113130734.GJ9207@bill-the-cat> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="FDHWeTQvEq+9/CPf" Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean --FDHWeTQvEq+9/CPf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jan 13, 2022 at 06:37:27AM -0700, Simon Glass wrote: > Hi Tom, Rasmus, >=20 > On Thu, 13 Jan 2022 at 06:07, Tom Rini wrote: > > > > On Thu, Jan 13, 2022 at 09:08:13AM +0100, Rasmus Villemoes wrote: > > > On 01/11/2021 02.17, Simon Glass wrote: > > > > Some bright sparks have decided that a cast on a constant cannot be= a > > > > constant, so offsetof() produces this warning on clang-10: > > > > > > > > include/intel_gnvs.h:113:1: error: static_assert expression is not = an > > > > integral constant expression > > > > check_member(acpi_global_nvs, unused2, GNVS_CHROMEOS_ACPI_OFFSET); > > > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > include/linux/kernel.h:284:2: note: expanded from macro 'check_memb= er' > > > > offsetof(struct structure, member) =3D=3D (offset), \ > > > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > include/linux/stddef.h:20:32: note: expanded from macro 'offsetof' > > > > ^ > > > > include/intel_gnvs.h:113:1: note: cast that performs the conversion= s of > > > > a reinterpret_cast is ot allowed in a constant expression > > > > include/linux/stddef.h:20:33: note: expanded from macro 'offsetof' > > > > > > > > Fix it by using the compiler built-in version, if available. > > > > > > > > Signed-off-by: Simon Glass > > > > --- > > > > > > > > include/linux/stddef.h | 8 +++++++- > > > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/include/linux/stddef.h b/include/linux/stddef.h > > > > index c540f6100d4..a7f546fdfe5 100644 > > > > --- a/include/linux/stddef.h > > > > +++ b/include/linux/stddef.h > > > > @@ -1,6 +1,8 @@ > > > > #ifndef _LINUX_STDDEF_H > > > > #define _LINUX_STDDEF_H > > > > > > > > +#include > > > > + > > > > #undef NULL > > > > #if defined(__cplusplus) > > > > #define NULL 0 > > > > @@ -14,7 +16,11 @@ > > > > > > > > #ifndef __CHECKER__ > > > > #undef offsetof > > > > -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) > > > > +#ifdef __compiler_offsetof > > > > +#define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBE= R) > > > > +#else > > > > +#define offsetof(TYPE, MEMBER) ((size_t)&((TYPE *)0)->MEMBER) > > > > +#endif > > > > #endif > > > > > > > > > Can we please just drop the useless indirections? Any compiler we care > > > about provides __builtin_offsetof(), so just make the whole thing > > > > > > #undef offsetof > > > #define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER) > > > > > > And by "compilers we care about", that includes sparse - it has had > > > __builtin_offsetof ever since 2007. > > > > > > And we can nuke the __compiler_offsetof definition in compiler_types.= h, > > > and if any users exist, just mechanically convert them to offsetof(). > > > > We should re-sync this with upstream, but that will keep the indirection > > you're objecting to here, I think. >=20 > Yes, with this patch, this part of the file is the same as Linux (e.g. v5= =2E16). >=20 > So I'd like to apply it as is and deal with improvements later. > Perhaps in lockstep with Linux? Please re-word to be clear this is a functional re-sync with v5.16, thanks! --=20 Tom --FDHWeTQvEq+9/CPf Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmHgLCAACgkQFHw5/5Y0 tyxKBwwAuVGTo69D8xB0F1LOp5EEO0Mor0Lnw58PjbetTXKh5ZKgiVDXDj76/oQ0 CuSYX06UID/qhrZWfGsV1StsNgobyTqfWxdubT0cMgc40S7xBk2LLYrM6+SVT1HE H/SHZR8/of6s+bofnYGurYxri2iph/D0rWpFBI+Az2EqVrPobpa4iNVSLr1Ux8e5 5oQP4uVHgzd4UF6kpLin4PCAMLjtkVijwsYpdfgfSx4uM2QOS88WBAwY4wO1V+Jb Oir/bYnp0cMMnIZvE5AjDoG/KbQaefIogulW15OZJM6DtOKYs6avsp98lYfEZNwl ElxeR0uGdFDrrriXKHqI3+U5+v5iOjL47p7HFZRnWkMsz/TXMFw6/JHu7sKzWqrn YMysfFJHKd1cMypAKn5XDX57OxCtyHhvCSIUHOmNJKnc4BiDYcDQk8TxuQeFtWFM ehBZmzPWfJc8DGwb0oF3+V4laA+UADnhe1MBPy9x5LA0wcWn/BtPw7ZFsNWwYB06 TIllxyvm =ZDw+ -----END PGP SIGNATURE----- --FDHWeTQvEq+9/CPf--