mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] clock: implement CLOCKSOURCE_MASK in terms of GENMASK_ULL
@ 2023-04-04 10:19 Ahmad Fatoum
  2023-04-11 13:13 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2023-04-04 10:19 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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(-)

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




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-11 13:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-04 10:19 [PATCH] clock: implement CLOCKSOURCE_MASK in terms of GENMASK_ULL Ahmad Fatoum
2023-04-11 13:13 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox