All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] selftests: timens: use 'llabs()' over 'abs()'
@ 2021-11-05 16:31 Anders Roxell
  2021-11-05 16:31 ` [PATCH 2/2] selftests: timens: exec: use 'labs()' " Anders Roxell
  2021-11-05 20:26 ` [PATCH 1/2] selftests: timens: use 'llabs()' " Nick Desaulniers
  0 siblings, 2 replies; 11+ messages in thread
From: Anders Roxell @ 2021-11-05 16:31 UTC (permalink / raw)
  To: shuah
  Cc: nathan, ndesaulniers, linux-kselftest, linux-kernel, llvm, Anders Roxell

When building selftests/timens with clang, the compiler warn about the
function abs() see below:

timerfd.c:64:7: error: absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value [-Werror,-Wabsolute-value]
                if (abs(elapsed - 3600) > 60) {
                    ^
timerfd.c:64:7: note: use function 'llabs' instead
                if (abs(elapsed - 3600) > 60) {
                    ^~~
                    llabs

The note indicates what to do, Rework to use the function 'llabs()'.

Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
 tools/testing/selftests/timens/timer.c   | 2 +-
 tools/testing/selftests/timens/timerfd.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/timens/timer.c b/tools/testing/selftests/timens/timer.c
index 5e7f0051bd7b..5b939f59dfa4 100644
--- a/tools/testing/selftests/timens/timer.c
+++ b/tools/testing/selftests/timens/timer.c
@@ -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;
diff --git a/tools/testing/selftests/timens/timerfd.c b/tools/testing/selftests/timens/timerfd.c
index 9edd43d6b2c1..a4196bbd6e33 100644
--- a/tools/testing/selftests/timens/timerfd.c
+++ b/tools/testing/selftests/timens/timerfd.c
@@ -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;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-11-20  0:18 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-05 16:31 [PATCH 1/2] selftests: timens: use 'llabs()' over 'abs()' Anders Roxell
2021-11-05 16:31 ` [PATCH 2/2] selftests: timens: exec: use 'labs()' " Anders Roxell
2021-11-05 20:35   ` Nick Desaulniers
2021-11-05 20:45     ` Arnd Bergmann
2021-11-05 20:50       ` Nick Desaulniers
2021-11-10 18:03       ` [PATCHv2] " Anders Roxell
2021-11-10 20:09         ` Nick Desaulniers
2021-11-10 20:11           ` Nick Desaulniers
2021-11-11  8:26             ` Anders Roxell
2021-11-05 20:26 ` [PATCH 1/2] selftests: timens: use 'llabs()' " Nick Desaulniers
2021-11-20  0:18   ` Shuah Khan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.