mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] clock: implement CLOCKSOURCE_MASK in terms of GENMASK_ULL
Date: Tue, 11 Apr 2023 15:13:31 +0200	[thread overview]
Message-ID: <20230411131331.GO19113@pengutronix.de> (raw)
In-Reply-To: <20230404101914.2244083-1-a.fatoum@pengutronix.de>

On Tue, Apr 04, 2023 at 12:19:14PM +0200, Ahmad Fatoum wrote:
> Clang doesn't like our implementation of CLOCKSOURCE_MASK:
> 
>   common/clock.c:33:10: warning: shift count >= width of type [-Wshift-count-overflow]
> 	.mask = CLOCKSOURCE_MASK(64),
>                 ^~~~~~~~~~~~~~~~~~~~
>   include/clock.h:8:63: note: expanded from macro 'CLOCKSOURCE_MASK'
> 	 #define CLOCKSOURCE_MASK(bits) (uint64_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1)
> 
> So the bits < 64 check we have is apparently not enough to suppress the
> warning when built with clang.
> 
> Let's do what the kernel does and use GENMASK_ULL instead to get rid of
> the last remaining warning when building ARCH=sandbox targettools_defconfig
> with clang version 16.0.1.
> 
> Not functional change intended.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  include/clock.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Applied, thanks

Sascha

> 
> diff --git a/include/clock.h b/include/clock.h
> index 8e07c35d374e..03a38911a7a7 100644
> --- a/include/clock.h
> +++ b/include/clock.h
> @@ -4,8 +4,9 @@
>  
>  #include <types.h>
>  #include <linux/time.h>
> +#include <linux/bitops.h>
>  
> -#define CLOCKSOURCE_MASK(bits) (uint64_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1)
> +#define CLOCKSOURCE_MASK(bits) GENMASK_ULL((bits) - 1, 0)
>  
>  struct clocksource {
>  	uint32_t	shift;
> -- 
> 2.39.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



      reply	other threads:[~2023-04-11 13:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-04 10:19 Ahmad Fatoum
2023-04-11 13:13 ` Sascha Hauer [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=20230411131331.GO19113@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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