[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150915014936.GA25658@htj.duckdns.org>
Date: Mon, 14 Sep 2015 21:49:36 -0400
From: Tejun Heo <tj@...nel.org>
To: John Stultz <john.stultz@...aro.org>
Cc: LKML <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Ingo Molnar <mingo@...nel.org>,
"Steven Rostedt (Red Hat)" <rostedt@...dmis.org>,
Peter Zijlstra <peterz@...radead.org>,
Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>,
Michal Nazarewicz <mina86@...a86.com>,
Prarit Bhargava <prarit@...hat.com>,
Richard Cochran <richardcochran@...il.com>,
Thomas Gleixner <tglx@...utronix.de>,
Theodore Ts'o <tytso@....edu>,
Andreas Dilger <adilger.kernel@...ger.ca>,
Dave Chinner <dchinner@...hat.com>,
Joe Perches <joe@...ches.com>
Subject: Re: [RFC][PATCH 0/5] Fixes for abs() usage on 64bit values
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; \
})
The current macros are kinda broken because they'd end up converting
u32 or u64 values which are over the max values of signed counterparts
to their complements.
Thanks.
--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists