From: Shuah Khan <skhan@linuxfoundation.org>
To: Nick Desaulniers <ndesaulniers@google.com>,
Anders Roxell <anders.roxell@linaro.org>
Cc: shuah@kernel.org, nathan@kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH 1/2] selftests: timens: use 'llabs()' over 'abs()'
Date: Fri, 19 Nov 2021 17:18:40 -0700 [thread overview]
Message-ID: <4de8c09f-df5e-8d7e-a19e-98424e939b81@linuxfoundation.org> (raw)
In-Reply-To: <CAKwvOdnge-hBmoFH-CHZmbh7DTq8bQiyhbfEOWkBt447=e6QGA@mail.gmail.com>
On 11/5/21 2:26 PM, Nick Desaulniers wrote:
> On Fri, Nov 5, 2021 at 9:31 AM Anders Roxell <anders.roxell@linaro.org> wrote:
>>
>> 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>
>
> Thanks for the patch!
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
>
>> ---
>> 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
>>
>
>
Same comment on llabs() define in stdlib.h made earlier in the context
of timer test changes.
thanks,
-- Shuah
prev parent reply other threads:[~2021-11-20 0:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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: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 message]
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=4de8c09f-df5e-8d7e-a19e-98424e939b81@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=anders.roxell@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=shuah@kernel.org \
/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
all inboxes | Powered by JetHome®