]> www.infradead.org Git - users/hch/xfs.git/commitdiff
selftest/timerns: fix clang build failures for abs() calls
authorJohn Hubbard <jhubbard@nvidia.com>
Thu, 4 Jul 2024 02:52:47 +0000 (19:52 -0700)
committerShuah Khan <skhan@linuxfoundation.org>
Fri, 5 Jul 2024 19:21:48 +0000 (13:21 -0600)
When building with clang, via:

    make LLVM=1 -C tools/testing/selftests

...clang warns about mismatches between the expected and required
integer length being supplied to abs(3).

Fix this by using the correct variant of abs(3): labs(3) or llabs(3), in
these cases.

Reviewed-by: Dmitry Safonov <dima@arista.com>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Acked-by: Andrei Vagin <avagin@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/timens/exec.c
tools/testing/selftests/timens/timer.c
tools/testing/selftests/timens/timerfd.c
tools/testing/selftests/timens/vfork_exec.c

index e40dc5be2f66847f1fae50632484d744d77dcfe2..d12ff955de0d8f6665fa957e81438e373af9f92c 100644 (file)
@@ -30,7 +30,7 @@ int main(int argc, char *argv[])
 
                for (i = 0; i < 2; i++) {
                        _gettime(CLOCK_MONOTONIC, &tst, i);
-                       if (abs(tst.tv_sec - now.tv_sec) > 5)
+                       if (labs(tst.tv_sec - now.tv_sec) > 5)
                                return pr_fail("%ld %ld\n", now.tv_sec, tst.tv_sec);
                }
                return 0;
@@ -50,7 +50,7 @@ int main(int argc, char *argv[])
 
        for (i = 0; i < 2; i++) {
                _gettime(CLOCK_MONOTONIC, &tst, i);
-               if (abs(tst.tv_sec - now.tv_sec) > 5)
+               if (labs(tst.tv_sec - now.tv_sec) > 5)
                        return pr_fail("%ld %ld\n",
                                        now.tv_sec, tst.tv_sec);
        }
@@ -70,7 +70,7 @@ int main(int argc, char *argv[])
                /* Check that a child process is in the new timens. */
                for (i = 0; i < 2; i++) {
                        _gettime(CLOCK_MONOTONIC, &tst, i);
-                       if (abs(tst.tv_sec - now.tv_sec - OFFSET) > 5)
+                       if (labs(tst.tv_sec - now.tv_sec - OFFSET) > 5)
                                return pr_fail("%ld %ld\n",
                                                now.tv_sec + OFFSET, tst.tv_sec);
                }
index 5e7f0051bd7be1896ddf8ee181b8225138c6c6c2..5b939f59dfa4d64e4c2e4dc8eb6a644d44211f13 100644 (file)
@@ -56,7 +56,7 @@ int run_test(int clockid, struct timespec now)
                        return pr_perror("timerfd_gettime");
 
                elapsed = new_value.it_value.tv_sec;
-               if (abs(elapsed - 3600) > 60) {
+               if (llabs(elapsed - 3600) > 60) {
                        ksft_test_result_fail("clockid: %d elapsed: %lld\n",
                                              clockid, elapsed);
                        return 1;
index 9edd43d6b2c1334eb9638180755d321f1ac3c94b..a4196bbd6e33f41b6a3ae346070037aff1cf4087 100644 (file)
@@ -61,7 +61,7 @@ int run_test(int clockid, struct timespec now)
                        return pr_perror("timerfd_gettime(%d)", clockid);
 
                elapsed = new_value.it_value.tv_sec;
-               if (abs(elapsed - 3600) > 60) {
+               if (llabs(elapsed - 3600) > 60) {
                        ksft_test_result_fail("clockid: %d elapsed: %lld\n",
                                              clockid, elapsed);
                        return 1;
index beb7614941fb1fb66c5cf5463599f1e2be610090..5b8907bf451dde3f3e2699f87797c155b9115aab 100644 (file)
@@ -32,7 +32,7 @@ static void *tcheck(void *_args)
 
        for (i = 0; i < 2; i++) {
                _gettime(CLOCK_MONOTONIC, &tst, i);
-               if (abs(tst.tv_sec - now->tv_sec) > 5) {
+               if (labs(tst.tv_sec - now->tv_sec) > 5) {
                        pr_fail("%s: in-thread: unexpected value: %ld (%ld)\n",
                                args->tst_name, tst.tv_sec, now->tv_sec);
                        return (void *)1UL;
@@ -64,7 +64,7 @@ static int check(char *tst_name, struct timespec *now)
 
        for (i = 0; i < 2; i++) {
                _gettime(CLOCK_MONOTONIC, &tst, i);
-               if (abs(tst.tv_sec - now->tv_sec) > 5)
+               if (labs(tst.tv_sec - now->tv_sec) > 5)
                        return pr_fail("%s: unexpected value: %ld (%ld)\n",
                                        tst_name, tst.tv_sec, now->tv_sec);
        }