Skip to content

Commit cb49b7b

Browse files
sean-jcMarc Zyngier
authored andcommitted
KVM: arm64: selftests: Track width of timer counter as "int", not "uint64_t"
Store the width of arm64's timer counter as an "int", not a "uint64_t". ilog2() returns an "int", and more importantly using what is an "unsigned long" under the hood makes clang unhappy due to a type mismatch when clamping the width to a sane value. arm64/arch_timer_edge_cases.c:1032:10: error: comparison of distinct pointer types ('typeof (width) *' (aka 'unsigned long *') and 'typeof (56) *' (aka 'int *')) [-Werror,-Wcompare-distinct-pointer-types] 1032 | width = clamp(width, 56, 64); | ^~~~~~~~~~~~~~~~~~~~ tools/include/linux/kernel.h:47:45: note: expanded from macro 'clamp' 47 | #define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi) | ^~~~~~~~~~~~ tools/include/linux/kernel.h:33:17: note: expanded from macro 'max' 33 | (void) (&_max1 == &_max2); \ | ~~~~~~ ^ ~~~~~~ tools/include/linux/kernel.h:39:9: note: expanded from macro 'min' 39 | typeof(x) _min1 = (x); \ | ^ Fixes: fad4cf9 ("KVM: arm64: selftests: Determine effective counter width in arch_timer_edge_cases") Cc: Sebastian Ott <[email protected]> Signed-off-by: Sean Christopherson <[email protected]> Reviewed-by: Oliver Upton <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
1 parent 890c608 commit cb49b7b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/testing/selftests/kvm/arm64/arch_timer_edge_cases.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ static void set_counter_defaults(void)
10201020
{
10211021
const uint64_t MIN_ROLLOVER_SECS = 40ULL * 365 * 24 * 3600;
10221022
uint64_t freq = read_sysreg(CNTFRQ_EL0);
1023-
uint64_t width = ilog2(MIN_ROLLOVER_SECS * freq);
1023+
int width = ilog2(MIN_ROLLOVER_SECS * freq);
10241024

10251025
width = clamp(width, 56, 64);
10261026
CVAL_MAX = GENMASK_ULL(width - 1, 0);

0 commit comments

Comments
 (0)