From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752993AbcBCKyA (ORCPT ); Wed, 3 Feb 2016 05:54:00 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:53012 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751572AbcBCKx5 (ORCPT ); Wed, 3 Feb 2016 05:53:57 -0500 X-AuditID: cbfec7f5-f79b16d000005389-d0-56b1dc43f6f1 Subject: Re: [PATCH v2] err.h: allow IS_ERR_VALUE to handle properly more types To: Andrew Morton References: <201601072342.xanwLeaS%fengguang.wu@intel.com> <1453969648-4036-1-git-send-email-a.hajda@samsung.com> <20160202163350.f7d42f4b97f48756f3900e9a@linux-foundation.org> Cc: open list , Bartlomiej Zolnierkiewicz , Marek Szyprowski From: Andrzej Hajda Message-id: <56B1DC0E.3070901@samsung.com> Date: Wed, 03 Feb 2016 11:53:02 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-version: 1.0 In-reply-to: <20160202163350.f7d42f4b97f48756f3900e9a@linux-foundation.org> Content-type: text/plain; charset=windows-1252 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrILMWRmVeSWpSXmKPExsVy+t/xa7rOdzaGGUzfKWAxZ/0aNouNM9az WlzeNYfNYu2Ru+wOLB4nZvxm8ejbsorR4/MmuQDmKC6blNSczLLUIn27BK6Mp81eBef4K+5/ eMDSwHidp4uRg0NCwETidZdXFyMnkCkmceHeerYuRi4OIYGljBJdDR0sEM5zRok3h46xg1QJ C/hLzF70iBnEFhHQlVj1fBczRNEWRom396+DOcwCkxkl1nfdZwSpYhPQlPi7+SYbiM0roCXx 5vAXFhCbRUBV4mrvQ7CpogIREoc7u9ghagQlfky+B1bDKeAt0dn6nA3kVGYBPYn7F7VAwswC 8hKb17xlnsAoMAtJxyyEqllIqhYwMq9iFE0tTS4oTkrPNdIrTswtLs1L10vOz93ECAnYrzsY lx6zOsQowMGoxMMb8WtDmBBrYllxZe4hRgkOZiUR3swzG8OEeFMSK6tSi/Lji0pzUosPMUpz sCiJ887c9T5ESCA9sSQ1OzW1ILUIJsvEwSnVwHgpqGdP6QXbHblPkg9JL7lb8zxq6V8h40ku 51q2CkzZnl2oEsv05xqTRliKHVeLZcK8mSfUovVue+8scrh7rls8M7nActeBlljnPuFYcQ+f 3pmGGi+qFSMel1WVXxB12Dx3X3i5yHzeWuOHSrvmvswJ6GnN26e3KNN/6iWJb7M6XtrEi56M UmIpzkg01GIuKk4EAIyGnYxUAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/03/2016 01:33 AM, Andrew Morton wrote: > On Thu, 28 Jan 2016 09:27:28 +0100 Andrzej Hajda wrote: > >> - use '<= 0' instead of '< 0' to silence gcc verbose warnings, >> - expand commit message. >> --- >> include/linux/err.h | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/include/linux/err.h b/include/linux/err.h >> index 56762ab..43a6adb 100644 >> --- a/include/linux/err.h >> +++ b/include/linux/err.h >> @@ -18,7 +18,9 @@ >> >> #ifndef __ASSEMBLY__ >> >> -#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO) >> +#define IS_ERR_VALUE(x) ((typeof(x))(-1) <= 0 \ >> + ? unlikely((x) < 0) \ >> + : unlikely((x) >= (typeof(x))-MAX_ERRNO)) > I'm still getting a bunch of > > include/linux/err.h: In function 'IS_ERR': > include/linux/err.h:37: warning: comparison of unsigned expression < 0 is always false > include/linux/err.h: In function 'IS_ERR_OR_NULL': > include/linux/err.h:42: warning: comparison of unsigned expression < 0 is always false > > with gcc-4.4.4. > > These warnings are false positives and gcc up to 4.7 emits them, gcc 4.8(which I use) behaves correctly (at least on x86 and arm64). I have tried to use __builtin_choose_expr instead of ?: operator but it did not help, although documentation says "the built-in function does not evaluate the expression that is not chosen"[1]. The sanest gcc silencer I see for now is to replace: ? unlikely((x) < 0) \ with ? unlikely((x) <= -1) \ On the other side these warnings are caused by -Wtype-limits switch which is disabled by default in kernel build and treated as broken by Linus [2]. Maybe it is good enough reason to disregard them? :) Anyway, I will post another iteration. [1]: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-g_t_005f_005fbuiltin_005fchoose_005fexpr-4184 [2]: http://permalink.gmane.org/gmane.linux.kernel/2053963 Regards Andrzej