Re: [PATCH] bitops: fix signedness of compile-time hweightimplementations

From: Peter Zijlstra
Date: Wed Jan 22 2014 - 12:48:21 EST


On Wed, Jan 22, 2014 at 05:19:58PM +0000, Paul Walmsley wrote:
> Hi Peter, hpa, Arnd,
>
> On Wed, 18 Dec 2013, Paul Walmsley wrote:
>
> >
> > Enabling '-Wsign-compare' compiler warnings on code that includes
> > include/linux/bitops.h can generate the following warning:
> >
> > In file included from include/linux/kernel.h:10:0,
> > from <random filename>:48:
> > include/linux/bitops.h: In function âhweight_longâ:
> > include/linux/bitops.h:77:26: error: signed and unsigned type in conditional
> > expression [-Werror=sign-compare]
> >
> > (converted to an error with -Werror)
> >
> > This is due to the use of the logical negation operator '!' in the
> > __const_hweight8 macro in include/asm-generic/bitops/const_hweight.h.
> > The use of that operator here results in a signed value.
> >
> > Fix by explicitly casting the __const_hweight8 macro expansion to
> > 'unsigned int'. While here, clean up several checkpatch.pl warnings.
> >
> > Signed-off-by: Paul Walmsley <pwalmsley@xxxxxxxxxx>
> > Cc: H. Peter Anvin <hpa@xxxxxxxxx>
> > Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
> > Cc: Arnd Bergmann <arnd@xxxxxxxx>
> > ---
> > Intended for v3.14.
>
> Ping. Just checking to see if you have any comments on this one, or if
> you're planning to send it upstream for v3.14.

I'm not sure through which tree to send it, but just I've queued it so
it doesn't get lost again.

Also, it didn't apply as is for some reason, hit it on the head with a
hammer though.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/