lkml.org 
[lkml]   [2015]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [RFC][PATCH 0/5] Fixes for abs() usage on 64bit values
From
On Mon, Sep 14, 2015 at 6:49 PM, Tejun Heo <tj@kernel.org> wrote:
> Hello,
>
> On Mon, Sep 14, 2015 at 06:05:19PM -0700, John Stultz wrote:
>> As noted in include/linux/kernel.h:
>> "abs() should not be used for 64-bit types (s64, u64, long long)
>> - use abs64() for those."
>>
>> Unfortunately, there are quite a number of places where abs()
>> was used w/ 64bit values in the kernel, and the results are
>> then silently capped to 32-bit values on 32-bit systems.
>
> I don't get it. Why can't we just do the following?
>
> #define abs(x) \
> ({ \
> typeof(x) __x = (x); \
> __x < 0 ? -__x : __x; \
> })
>

Yea. The above make sense to me, but I suspect there's some very
subtle reason for the existing separated logic.
But I'd have to defer to akpm for hints on that.

thanks
-john


\
 
 \ /
  Last update: 2015-09-15 05:41    [W:0.108 / U:0.308 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site