Re: [PATCH v2] err.h: allow IS_ERR_VALUE to handle properly more types

From: Andrew Morton
Date: Tue Feb 02 2016 - 19:33:56 EST


On Thu, 28 Jan 2016 09:27:28 +0100 Andrzej Hajda <a.hajda@xxxxxxxxxxx> 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.