Re: [PATCH] netlink: fix gcc -Wconversion compilation warning

From: Kirill A. Shutemov
Date: Tue Dec 14 2010 - 06:28:07 EST


On Mon, Dec 13, 2010 at 01:35:25PM -0800, Eric W. Biederman wrote:
> "Kirill A. Shutsemov" <kirill@xxxxxxxxxxxxx> writes:
>
> > From: Dmitry V. Levin <ldv@xxxxxxxxxxxx>
> >
> > $ cat << EOF | gcc -Wconversion -xc -S -o/dev/null -
> > unsigned f(void) {return NLMSG_HDRLEN;}
> > EOF
> > <stdin>: In function 'f':
> > <stdin>:3:26: warning: negative integer implicitly converted to unsigned type
> >
> This doesn't look like a bad fix, but I believe things will fail if
> we give NLMSG_ALIGN an unsigned long like size_t. Say like sizeof.
>
> Admittedly it has to be a huge size but still if we are going
> to go fixing things...
>
> And then there is the silliness that NLMSG_HDRLEN forces itself
> to be an int, when it start out as a size_t.
>
> So I think NLMSG_ALIGN either needs to operation exclusively
> on unsigned longs aka size_t, or it needs to be type preserving.
>
> Do you have time to look at this a bit more?

Something like this? Untested.
---