From: David Laight <David.Laight@ACULAB.COM>
To: 'Arnd Bergmann' <arnd@kernel.org>, Russell King <linux@armlinux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>,
Nathan Chancellor <nathan@kernel.org>,
"Nick Desaulniers" <ndesaulniers@google.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"clang-built-linux@googlegroups.com"
<clang-built-linux@googlegroups.com>
Subject: RE: [PATCH] ARM: delay: avoid clang -Wtautological-constant warning
Date: Wed, 24 Mar 2021 23:14:40 +0000 [thread overview]
Message-ID: <caf7e56984c347da9e342e89ce530748@AcuMS.aculab.com> (raw)
In-Reply-To: <20210323132031.2858996-1-arnd@kernel.org>
From: Arnd Bergmann
> Sent: 23 March 2021 13:20
> Passing an 8-bit constant into delay() triggers a warning when building
> with 'make W=1' using clang:
>
> drivers/clk/actions/owl-pll.c:182:2: error: result of comparison of constant 2000 with expression of
> type 'u8' (aka 'unsigned char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
> udelay(pll_hw->delay);
> ^~~~~~~~~~~~~~~~~~~~~
> arch/arm/include/asm/delay.h:84:9: note: expanded from macro 'udelay'
> ((n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() : \
> ~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~
> arch/arm/mach-omap2/wd_timer.c:89:3: error: result of comparison of constant 2000 with expression of
> type 'u8' (aka 'unsigned char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
> udelay(oh->class->sysc->srst_udelay);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Shut up the warning by adding a cast to a 64-bit number. A cast to 'int'
> would usually be sufficient, but would fail to cause a link-time error
> for large 64-bit constants.
Adding 0u probably has the desired effect - without any side effects of a cast.
David
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> arch/arm/include/asm/delay.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/include/asm/delay.h b/arch/arm/include/asm/delay.h
> index 4f80b72372b4..1bb6417a3a83 100644
> --- a/arch/arm/include/asm/delay.h
> +++ b/arch/arm/include/asm/delay.h
> @@ -81,7 +81,7 @@ extern void __bad_udelay(void);
>
> #define udelay(n) \
> (__builtin_constant_p(n) ? \
> - ((n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() : \
> + ((u64)(n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() : \
> __const_udelay((n) * UDELAY_MULT)) : \
> __udelay(n))
>
> --
> 2.29.2
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
prev parent reply other threads:[~2021-03-24 23:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-23 13:20 [PATCH] ARM: delay: avoid clang -Wtautological-constant warning Arnd Bergmann
2021-03-23 13:30 ` Russell King - ARM Linux admin
2021-03-24 23:14 ` David Laight [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=caf7e56984c347da9e342e89ce530748@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=clang-built-linux@googlegroups.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox