]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.10/selftests-timers-fix-abs-warning-in-posix_timers-test.patch
6.1-stable patches
[thirdparty/kernel/stable-queue.git] / queue-5.10 / selftests-timers-fix-abs-warning-in-posix_timers-test.patch
1 From ed366de8ec89d4f960d66c85fc37d9de22f7bf6d Mon Sep 17 00:00:00 2001
2 From: John Stultz <jstultz@google.com>
3 Date: Wed, 10 Apr 2024 16:26:30 -0700
4 Subject: selftests: timers: Fix abs() warning in posix_timers test
5
6 From: John Stultz <jstultz@google.com>
7
8 commit ed366de8ec89d4f960d66c85fc37d9de22f7bf6d upstream.
9
10 Building with clang results in the following warning:
11
12 posix_timers.c:69:6: warning: absolute value function 'abs' given an
13 argument of type 'long long' but has parameter of type 'int' which may
14 cause truncation of value [-Wabsolute-value]
15 if (abs(diff - DELAY * USECS_PER_SEC) > USECS_PER_SEC / 2) {
16 ^
17 So switch to using llabs() instead.
18
19 Fixes: 0bc4b0cf1570 ("selftests: add basic posix timers selftests")
20 Signed-off-by: John Stultz <jstultz@google.com>
21 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
22 Cc: stable@vger.kernel.org
23 Link: https://lore.kernel.org/r/20240410232637.4135564-3-jstultz@google.com
24 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25 ---
26 tools/testing/selftests/timers/posix_timers.c | 2 +-
27 1 file changed, 1 insertion(+), 1 deletion(-)
28
29 --- a/tools/testing/selftests/timers/posix_timers.c
30 +++ b/tools/testing/selftests/timers/posix_timers.c
31 @@ -66,7 +66,7 @@ static int check_diff(struct timeval sta
32 diff = end.tv_usec - start.tv_usec;
33 diff += (end.tv_sec - start.tv_sec) * USECS_PER_SEC;
34
35 - if (abs(diff - DELAY * USECS_PER_SEC) > USECS_PER_SEC / 2) {
36 + if (llabs(diff - DELAY * USECS_PER_SEC) > USECS_PER_SEC / 2) {
37 printf("Diff too high: %lld..", diff);
38 return -1;
39 }