From: Andrzej Hajda <a.hajda@samsung.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: open list <linux-kernel@vger.kernel.org>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
Marek Szyprowski <m.szyprowski@samsung.com>
Subject: Re: [PATCH v2] err.h: allow IS_ERR_VALUE to handle properly more types
Date: Wed, 03 Feb 2016 11:53:02 +0100 [thread overview]
Message-ID: <56B1DC0E.3070901@samsung.com> (raw)
In-Reply-To: <20160202163350.f7d42f4b97f48756f3900e9a@linux-foundation.org>
On 02/03/2016 01:33 AM, Andrew Morton wrote:
> On Thu, 28 Jan 2016 09:27:28 +0100 Andrzej Hajda <a.hajda@samsung.com> 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
next prev parent reply other threads:[~2016-02-03 10:54 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-07 14:58 [PATCH] err.h: allow IS_ERR_VALUE to handle properly more types Andrzej Hajda
2016-01-07 15:48 ` kbuild test robot
2016-01-28 8:27 ` [PATCH v2] " Andrzej Hajda
2016-02-02 6:23 ` Andrew Morton
2016-02-02 8:22 ` Andrzej Hajda
2016-02-03 0:33 ` Andrew Morton
2016-02-03 10:53 ` Andrzej Hajda [this message]
2016-02-03 13:15 ` [PATCH v3] " Andrzej Hajda
2016-02-04 12:40 ` Arnd Bergmann
2016-02-04 14:44 ` Andrzej Hajda
2016-02-04 15:00 ` Arnd Bergmann
2016-02-04 15:10 ` Arnd Bergmann
2016-02-04 18:59 ` Andrew Morton
2016-02-05 10:52 ` Arnd Bergmann
2016-02-08 8:45 ` Andrzej Hajda
2016-02-08 12:01 ` Arnd Bergmann
2016-02-09 1:44 ` Al Viro
2016-02-09 8:42 ` Andrzej Hajda
2016-02-10 21:01 ` Arnd Bergmann
2016-02-11 7:00 ` Andrzej Hajda
2016-02-11 16:39 ` Arnd Bergmann
2016-02-12 14:45 ` Andrzej Hajda
2016-02-11 21:14 ` Al Viro
2016-02-04 23:37 ` Rasmus Villemoes
2016-02-10 15:16 ` Guenter Roeck
2016-01-15 13:45 ` [PATCH] " Andrzej Hajda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56B1DC0E.3070901@samsung.com \
--to=a.hajda@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=b.zolnierkie@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).