Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1370639ybt; Thu, 9 Jul 2020 05:31:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwViF/VXEPqUWPZOWdrVVOodeBrTKxcCRX2T+W28kq6MBZnRDow7q+IS+na+xMkQGgEZBGF X-Received: by 2002:a17:907:a92:: with SMTP id by18mr59272611ejc.116.1594297885789; Thu, 09 Jul 2020 05:31:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594297885; cv=none; d=google.com; s=arc-20160816; b=iZzO11ux1uPDP4m8yYGxEyK4aCMyv+p3yPeZUVOyWq1nM5ztsZWxKnQH+j2EDQ08mC l0G1q9nSzFb7xquZSN/1i6yToZz0sr2fJ+lcclc2jy+uMNW/REZG5PM4cMTUyPkFPNqw PnO6tZ8jW/FV844+wAX8a7bTZ3i8NvL8ARqbMYqpg1DXsmEF0m9eGBrA/uKw74kwDlrv pvN/rf7IC2PtpsTH3DKX88QwDWyQLJoa1/gZywy94lRLQqxnfo1TpFPC0+ebW+1TPdhJ +4HTWMYYmQJ/bA76cL/uikxYoUwb2vnUiLE8bWf41kDuvaN43B7Ahek/gOWKhB0uC7KP /Rwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:message-id:subject:cc:to:from:date; bh=vkeC5x55e6po4PU15muRmOspY1lsqYWrGgeH/0mJ9C4=; b=oKczPav13EIREsFoHEebSkYegUHs62QrTRmbPym+S/jZqDGEXrUT7kyFYwhvrVPqIj TWJLHRPeiZiL/bPYNJ2BT3uIntuzxfunyuJOci3I8ln3/Q66vPJTX9jX+jsJpq0vPda7 SbuWRwsc+AUcsmizea9HYCiY7JyBu9nj0kgx7CTmcddImz/yuZSxVSv6K4SxNeRMW9kz hne2eKAuTqaa5P2du8QtI+XD0vRC+wZbaV+0/N896JCdbRBRdOkrrCrcFrF3REZfFmU2 W0O8b4hre87KDJLxDvtRJW5kgJCgqFUP3gX2fUEUZOGpe1z9S/AZvlNZ6hhi9VLeNvSe fT3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g10si1982714ejf.54.2020.07.09.05.31.01; Thu, 09 Jul 2020 05:31:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726736AbgGIMal (ORCPT + 99 others); Thu, 9 Jul 2020 08:30:41 -0400 Received: from helcar.hmeau.com ([216.24.177.18]:36066 "EHLO fornost.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726327AbgGIMak (ORCPT ); Thu, 9 Jul 2020 08:30:40 -0400 Received: from gwarestrin.arnor.me.apana.org.au ([192.168.0.7]) by fornost.hmeau.com with smtp (Exim 4.92 #5 (Debian)) id 1jtVgp-0003Uz-Kd; Thu, 09 Jul 2020 22:30:12 +1000 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Thu, 09 Jul 2020 22:30:11 +1000 Date: Thu, 9 Jul 2020 22:30:11 +1000 From: Herbert Xu To: Rikard Falkeborn Cc: akpm@linux-foundation.org, andy.shevchenko@gmail.com, arnd@arndb.de, emil.l.velikov@gmail.com, geert@linux-m68k.org, keescook@chromium.org, linus.walleij@linaro.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, lkp@intel.com, rikard.falkeborn@gmail.com, syednwaris@gmail.com, vilhelm.gray@gmail.com, yamada.masahiro@socionext.com, Linus Torvalds Subject: Re: [PATCH v4 1/2] linux/bits.h: fix unsigned less than zero warnings Message-ID: <20200709123011.GA18734@gondor.apana.org.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200621054210.14804-1-rikard.falkeborn@gmail.com> X-Newsgroups: apana.lists.os.linux.kernel User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rikard Falkeborn wrote: > When calling the GENMASK and GENMASK_ULL macros with zero lower bit and > an unsigned unknown high bit, some gcc versions warn due to the > comparisons of the high and low bit in GENMASK_INPUT_CHECK. > > To silence the warnings, only perform the check if both inputs are > known. This does not trigger any warnings, from the Wtype-limits help: > > Warn if a comparison is always true or always false due to the > limited range of the data type, but do not warn for constant > expressions. > > As an example of the warning, kindly reported by the kbuild test robot: > > from drivers/mfd/atmel-smc.c:11: > drivers/mfd/atmel-smc.c: In function 'atmel_smc_cs_encode_ncycles': > include/linux/bits.h:26:28: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] > 26 | __builtin_constant_p((l) > (h)), (l) > (h), 0))) > | ^ > include/linux/build_bug.h:16:62: note: in definition of macro 'BUILD_BUG_ON_ZERO' > 16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); }))) > | ^ > include/linux/bits.h:39:3: note: in expansion of macro 'GENMASK_INPUT_CHECK' > 39 | (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l)) > | ^~~~~~~~~~~~~~~~~~~ >>> drivers/mfd/atmel-smc.c:49:25: note: in expansion of macro 'GENMASK' > 49 | unsigned int lsbmask = GENMASK(msbpos - 1, 0); > | ^~~~~~~ > > Fixes: 295bcca84916 ("linux/bits.h: add compile time sanity check of GENMASK inputs") > Reported-by: kbuild test robot > Reported-by: Emil Velikov > Reported-by: Syed Nayyar Waris > Reviewed-by: Andy Shevchenko > Reviewed-by: Emil Velikov > Signed-off-by: Rikard Falkeborn > --- > v3-v4 > Added Emils Reviewed-by. I'm still getting the same warning even with the patch, for example: CC [M] drivers/crypto/inside-secure/safexcel.o CHECK ../drivers/crypto/inside-secure/safexcel_hash.c In file included from ../include/linux/bits.h:23, from ../include/linux/bitops.h:5, from ../include/linux/kernel.h:12, from ../include/linux/clk.h:13, from ../drivers/crypto/inside-secure/safexcel.c:8: ../drivers/crypto/inside-secure/safexcel.c: In function \u2018safexcel_hw_init\u2019: ../include/linux/bits.h:27:7: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] (l) > (h), 0))) ^ ../include/linux/build_bug.h:16:62: note: in definition of macro \u2018BUILD_BUG_ON_ZERO\u2019 #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); }))) ^ ../include/linux/bits.h:40:3: note: in expansion of macro \u2018GENMASK_INPUT_CHECK\u2019 (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l)) ^~~~~~~~~~~~~~~~~~~ ../drivers/crypto/inside-secure/safexcel.c:649:11: note: in expansion of macro \u2018GENMASK\u2019 GENMASK(priv->config.rings - 1, 0), ^~~~~~~ ../include/linux/bits.h:27:7: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] (l) > (h), 0))) ^ ../include/linux/build_bug.h:16:62: note: in definition of macro \u2018BUILD_BUG_ON_ZERO\u2019 #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); }))) ^ ../include/linux/bits.h:40:3: note: in expansion of macro \u2018GENMASK_INPUT_CHECK\u2019 (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l)) ^~~~~~~~~~~~~~~~~~~ ../drivers/crypto/inside-secure/safexcel.c:757:35: note: in expansion of macro \u2018GENMASK\u2019 writel(EIP197_DxE_THR_CTRL_EN | GENMASK(priv->config.rings - 1, 0), ^~~~~~~ ../include/linux/bits.h:27:7: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] (l) > (h), 0))) ^ ../include/linux/build_bug.h:16:62: note: in definition of macro \u2018BUILD_BUG_ON_ZERO\u2019 #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); }))) ^ ../include/linux/bits.h:40:3: note: in expansion of macro \u2018GENMASK_INPUT_CHECK\u2019 (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l)) ^~~~~~~~~~~~~~~~~~~ ../drivers/crypto/inside-secure/safexcel.c:761:35: note: in expansion of macro \u2018GENMASK\u2019 writel(EIP197_DxE_THR_CTRL_EN | GENMASK(priv->config.rings - 1, 0), ^~~~~~~ This happens when only l is const but h isn't. Can we please just revert the original patch and work this out in the next release? Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt