Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Edward Liaw <edliaw@google.com>
To: linux-kernel@vger.kernel.org, John Stultz <jstultz@google.com>,
	 Thomas Gleixner <tglx@linutronix.de>,
	Stephen Boyd <sboyd@kernel.org>, Shuah Khan <shuah@kernel.org>,
	 Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	 Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>
Cc: linux-kselftest@vger.kernel.org, kernel-team@android.com,
	 Edward Liaw <edliaw@google.com>,
	llvm@lists.linux.dev
Subject: [PATCH v1 3/3] selftests/timers/posix_timers: Use llabs for long long
Date: Mon,  4 Mar 2024 18:11:34 +0000	[thread overview]
Message-ID: <20240304181140.644212-4-edliaw@google.com> (raw)
In-Reply-To: <20240304181140.644212-1-edliaw@google.com>

Fixes clang warning: absolute value function 'abs' given an argument of
type 'long long' but has parameter of type 'int' which may cause
truncation of value.

Signed-off-by: Edward Liaw <edliaw@google.com>
---
 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 0f550fc9e879..78b4b2d3dc44 100644
--- a/tools/testing/selftests/timers/posix_timers.c
+++ b/tools/testing/selftests/timers/posix_timers.c
@@ -82,7 +82,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)
 		return -1;
 
 	return 0;
-- 
2.44.0.rc1.240.g4c46232300-goog


  parent reply	other threads:[~2024-03-04 18:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-04 18:11 [PATCH v1 0/3] selftests/timers/posix_timers: various cleanups Edward Liaw
2024-03-04 18:11 ` [PATCH v1 1/3] selftests/timers/posix_timers: Make signal distribution test less fragile Edward Liaw
2024-03-04 18:11 ` [PATCH v1 2/3] selftests/timers/posix_timers: Use TAP reporting format Edward Liaw
2024-03-04 18:11 ` Edward Liaw [this message]
2024-03-07 21:04 ` [PATCH v1 0/3] selftests/timers/posix_timers: various cleanups Thomas Gleixner
     [not found]   ` <CAG4es9XXYzzrt3-eybtXZ2Cy9fTtEPiCbggDxPcaRY=fiKM78A@mail.gmail.com>
2024-03-07 21:41     ` Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240304181140.644212-4-edliaw@google.com \
    --to=edliaw@google.com \
    --cc=jstultz@google.com \
    --cc=justinstitt@google.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=sboyd@kernel.org \
    --cc=shuah@kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox