[PATCH] clock: implement CLOCKSOURCE_MASK in terms of GENMASK_ULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux