Re: [patch -next] x86: dubious one-bit signed bitfields

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 06, 2011 at 11:39:31PM -0800, H. Peter Anvin wrote:
> On 12/06/2011 10:38 PM, Dan Carpenter wrote:
> > It doesn't cause any runtime problems in this case, but bitfields should
> > be unsigned.  This file gets included a lot so it generates thousands of
> > Sparse warnings about dubious one-bit signed bitfields.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> > 
> > diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
> > index 0ecd1a9..114dca1 100644
> > --- a/arch/x86/include/asm/thread_info.h
> > +++ b/arch/x86/include/asm/thread_info.h
> > @@ -40,8 +40,8 @@ struct thread_info {
> >  						*/
> >  	__u8			supervisor_stack[0];
> >  #endif
> > -	int			sig_on_uaccess_error:1;
> > -	int			uaccess_err:1;	/* uaccess failed */
> > +	unsigned int		sig_on_uaccess_error:1;
> > +	unsigned int		uaccess_err:1;	/* uaccess failed */
> >  };
> >  
> 
> Can bitfields legally be declared "bool"?  If so it's probably the right
> thing, really...

Sure.  Bool takes one byte, so it would be:
	bool			sig_on_uaccess_error:1;
	bool			uaccess_err:1;  /* uaccess failed */

The __u8 types mean that we're trying to not polute the posix
namespace?  Does that affect bool?  I'm not sure the rules with that.

regards,
dan carpenter

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux