Building with clang, I'm seeing:
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.

Cc: Shuah Khan <[email protected]>
Cc: Anna-Maria Behnsen <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Stephen Boyd <[email protected]>
Cc: Nathan Chancellor <[email protected]>
Cc: Nick Desaulniers <[email protected]>
Cc: Bill Wendling <[email protected]>
Cc: Justin Stitt <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Edward Liaw <[email protected]>
Cc: Carlos Llamas <[email protected]>
Cc: [email protected]
Cc: [email protected]
Fixes: 0bc4b0cf1570 ("selftests: add basic posix timers selftests")
Signed-off-by: John Stultz <[email protected]>
---
 tools/testing/selftests/timers/posix_timers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/timers/posix_timers.c 
b/tools/testing/selftests/timers/posix_timers.c
index 348f47176e0a..c001dd79179d 100644
--- a/tools/testing/selftests/timers/posix_timers.c
+++ b/tools/testing/selftests/timers/posix_timers.c
@@ -66,7 +66,7 @@ static int check_diff(struct timeval start, struct timeval 
end)
        diff = end.tv_usec - start.tv_usec;
        diff += (end.tv_sec - start.tv_sec) * USECS_PER_SEC;
 
-       if (abs(diff - DELAY * USECS_PER_SEC) > USECS_PER_SEC / 2) {
+       if (llabs(diff - DELAY * USECS_PER_SEC) > USECS_PER_SEC / 2) {
                printf("Diff too high: %lld..", diff);
                return -1;
        }
-- 
2.44.0.478.gd926399ef9-goog


Reply via email to