From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752169AbbIOBtl (ORCPT ); Mon, 14 Sep 2015 21:49:41 -0400 Received: from mail-qk0-f179.google.com ([209.85.220.179]:33817 "EHLO mail-qk0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751496AbbIOBtj (ORCPT ); Mon, 14 Sep 2015 21:49:39 -0400 Date: Mon, 14 Sep 2015 21:49:36 -0400 From: Tejun Heo To: John Stultz Cc: LKML , Andrew Morton , Ingo Molnar , "Steven Rostedt (Red Hat)" , Peter Zijlstra , Masami Hiramatsu , Michal Nazarewicz , Prarit Bhargava , Richard Cochran , Thomas Gleixner , "Theodore Ts'o" , Andreas Dilger , Dave Chinner , Joe Perches Subject: Re: [RFC][PATCH 0/5] Fixes for abs() usage on 64bit values Message-ID: <20150915014936.GA25658@htj.duckdns.org> References: <1442279124-7309-1-git-send-email-john.stultz@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1442279124-7309-1-git-send-email-john.stultz@linaro.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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