Skip to content

Commit ed366de

Browse files
johnstultz-workKAGA-KOKO
authored andcommitted
selftests: timers: Fix abs() warning in posix_timers test
Building with clang results in the following warning: posix_timers.c:69:6: warning: absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value] if (abs(diff - DELAY * USECS_PER_SEC) > USECS_PER_SEC / 2) { ^ So switch to using llabs() instead. Fixes: 0bc4b0c ("selftests: add basic posix timers selftests") Signed-off-by: John Stultz <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent f7d5bcd commit ed366de

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/testing/selftests/timers/posix_timers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static int check_diff(struct timeval start, struct timeval end)
6666
diff = end.tv_usec - start.tv_usec;
6767
diff += (end.tv_sec - start.tv_sec) * USECS_PER_SEC;
6868

69-
if (abs(diff - DELAY * USECS_PER_SEC) > USECS_PER_SEC / 2) {
69+
if (llabs(diff - DELAY * USECS_PER_SEC) > USECS_PER_SEC / 2) {
7070
printf("Diff too high: %lld..", diff);
7171
return -1;
7272
}

0 commit comments

Comments
 (0)