[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <59bd0880-475e-eb3b-6d2a-25589d5e3a8b@linuxfoundation.org>
Date: Fri, 19 Nov 2021 17:07:23 -0700
From: Shuah Khan <skhan@...uxfoundation.org>
To: Nick Desaulniers <ndesaulniers@...gle.com>,
Anders Roxell <anders.roxell@...aro.org>
Cc: shuah@...nel.org, tglx@...utronix.de, john.stultz@...aro.org,
nathan@...nel.org, linux-kernel@...r.kernel.org,
linux-kselftest@...r.kernel.org, llvm@...ts.linux.dev,
Shuah Khan <skhan@...uxfoundation.org>
Subject: Re: [PATCH] selftests: timers: use 'llabs()' over 'abs()'
On 11/5/21 2:44 PM, Nick Desaulniers wrote:
> On Fri, Nov 5, 2021 at 9:34 AM Anders Roxell <anders.roxell@...aro.org> wrote:
>>
>> When building selftests/timers with clang, the compiler warn about the
>> function abs() see below:
>>
>> posix_timers.c:69:6: warning: absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value]
>> if (abs(diff - DELAY * USECS_PER_SEC) > USECS_PER_SEC / 2) {
>> ^
>> posix_timers.c:69:6: note: use function 'llabs' instead
>> if (abs(diff - DELAY * USECS_PER_SEC) > USECS_PER_SEC / 2) {
>> ^~~
>> llabs
>>
>> The note indicates what to do, Rework to use the function 'llabs()'.
>>
>> Signed-off-by: Anders Roxell <anders.roxell@...aro.org>
>
> Thanks for the patch!
> Reviewed-by: Nick Desaulniers <ndesaulniers@...gle.com>
>
> I wonder why tools/testing/selftests/timers/adjtick.c redefines llabs
> when it already includes stdlib.h, and how that doesn't result in some
> kind of compiler diagnostic.
>
Hmm. The define in /usr/include/stdlib.h is under #ifdef __USE_ISOC99
Maybe be that explains the reason for the definitions in the other two
timers file?
Anders, I would like to understand this before I take this patch. I see
you sent several patches to other tests as well. Would be useful at
least understand why these defines exist.
thanks,
-- Shuah
Powered by blists - more mailing lists