Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Joe Perches
On Thu, 2014-02-27 at 12:55 -0800, Christopher Li wrote: > On Thu, Feb 27, 2014 at 12:39 PM, Joe Perches wrote: > > Maybe the evaluate.c "size = bits_in_char;" assignment > > > > if (size == 1 && is_bool_type(type)) { > > - warning(expr->pos, "expression using sizeof

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Christopher Li
On Thu, Feb 27, 2014 at 1:00 PM, Joe Perches wrote: > Of course > The change has applied and pushed. Chris -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Christopher Li
On Thu, Feb 27, 2014 at 1:00 PM, Joe Perches wrote: > On Thu, 2014-02-27 at 12:44 -0800, Christopher Li wrote: >> On Thu, Feb 27, 2014 at 12:26 PM, H. Peter Anvin wrote: >> > I would. >> Joe, I assume you are OK with this patch, the default is now off. > > Of course Let me know if you are going

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Joe Perches
On Thu, 2014-02-27 at 12:44 -0800, Christopher Li wrote: > On Thu, Feb 27, 2014 at 12:26 PM, H. Peter Anvin wrote: > > I would. > Joe, I assume you are OK with this patch, the default is now off. Of course > diff --git a/lib.c b/lib.c [] > @@ -226,6 +226,7 @@ int Wparen_string = 0; > +int

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Christopher Li
On Thu, Feb 27, 2014 at 12:39 PM, Joe Perches wrote: > Please use V3 as I stuffed up the alphabetic order > of sizeof and shadow. Please send it your V3 then :-) > > I'm not sure it matters much, but the linux-kernel > Makefile wouldn't need to be changed if Wsizeof_bool > is default 0. It

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Christopher Li
On Thu, Feb 27, 2014 at 12:26 PM, H. Peter Anvin wrote: > I would. > Joe, I assume you are OK with this patch, the default is now off. Chris Allow an override to emit or not the sizeof(bool) warning. Add a "-Wsizeof-bool" description to the manpage. Signed-off-by: Joe Perches Reviewed-by:

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Joe Perches
On Thu, 2014-02-27 at 12:26 -0800, H. Peter Anvin wrote: > On February 27, 2014 12:22:45 PM PST, Christopher Li > wrote: > >OK. I get it nobody wants a sizeof(_Bool) warning. > >I am going to apply this patch. Please use V3 as I stuffed up the alphabetic order of sizeof and shadow. > >Should

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread H. Peter Anvin
I would. On February 27, 2014 12:22:45 PM PST, Christopher Li wrote: >On Wed, Feb 26, 2014 at 8:32 PM, H. Peter Anvin wrote: >> >> Quite frankly, this is silly in my opinion, *and* it is not >guaranteed >> by C either (read about "trap representations"). >>> >> Anything that moves data around

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Christopher Li
On Wed, Feb 26, 2014 at 8:32 PM, H. Peter Anvin wrote: > > Quite frankly, this is silly in my opinion, *and* it is not guaranteed > by C either (read about "trap representations"). >> > Anything that moves data around in a generic fashion. It can be as > simple as: > > memcpy(foo, bar,

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread James Hogan
On 27/02/14 16:52, H. Peter Anvin wrote: > On 02/27/2014 08:10 AM, Dan Carpenter wrote: >> >> That last assumption has to change for the Meta architecture. >> >> https://lwn.net/Articles/522188/ >> >> On meta, the structs and unions are padded to 4 bytes unless they are >> explicitly marked as

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread H. Peter Anvin
On 02/27/2014 08:10 AM, Dan Carpenter wrote: > > That last assumption has to change for the Meta architecture. > > https://lwn.net/Articles/522188/ > > On meta, the structs and unions are padded to 4 bytes unless they are > explicitly marked as __packed. > One have to wonder how likely they

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Dan Carpenter
On Thu, Feb 27, 2014 at 07:48:35AM -0800, H. Peter Anvin wrote: > > Do we have a fairly comprehensive list of what these extrastandard > > requirements / assumptions are? It might be a good idea to have one > > that we can point to, so that (a) people who are trying to define a > > new

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Borislav Petkov
On Thu, Feb 27, 2014 at 07:48:35AM -0800, H. Peter Anvin wrote: > No, but I think we can certainly make a list... a lot of it right now > sits in various people's heads. > > Here are a couple: > > - Bytes are 8 bits > - Signed integers will be 2's complement > - sizeof char, short, int, long,

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread H. Peter Anvin
On 02/27/2014 07:24 AM, Theodore Ts'o wrote: > On Thu, Feb 27, 2014 at 07:10:25AM -0800, H. Peter Anvin wrote: >> Keep in mind, too, that for the kernel we don't care about the full >> C standard but a subset. We rely on extrastandard behavior all over >> the place. For all ABIs supported by the

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Theodore Ts'o
On Thu, Feb 27, 2014 at 07:10:25AM -0800, H. Peter Anvin wrote: > Keep in mind, too, that for the kernel we don't care about the full > C standard but a subset. We rely on extrastandard behavior all over > the place. For all ABIs supported by the kernel, sizeof(_Book) == 1 > and so everything is

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread H. Peter Anvin
Keep in mind, too, that for the kernel we don't care about the full C standard but a subset. We rely on extrastandard behavior all over the place. For all ABIs supported by the kernel, sizeof(_Book) == 1 and so everything is sane. On February 27, 2014 12:25:29 AM PST, Borislav Petkov wrote:

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Borislav Petkov
On Wed, Feb 26, 2014 at 07:42:37PM -0800, H. Peter Anvin wrote: > sizeof(_Bool), like for many other types, is ABI-dependent, but that > doesn't mean it is illegitimate. > > I don't think C99 says that it is invalid (which means C99 doesn't > permit is to be a packed bitmap.) Ok, but what can be

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Borislav Petkov
On Wed, Feb 26, 2014 at 07:42:37PM -0800, H. Peter Anvin wrote: sizeof(_Bool), like for many other types, is ABI-dependent, but that doesn't mean it is illegitimate. I don't think C99 says that it is invalid (which means C99 doesn't permit is to be a packed bitmap.) Ok, but what can be said

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread H. Peter Anvin
Keep in mind, too, that for the kernel we don't care about the full C standard but a subset. We rely on extrastandard behavior all over the place. For all ABIs supported by the kernel, sizeof(_Book) == 1 and so everything is sane. On February 27, 2014 12:25:29 AM PST, Borislav Petkov

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Theodore Ts'o
On Thu, Feb 27, 2014 at 07:10:25AM -0800, H. Peter Anvin wrote: Keep in mind, too, that for the kernel we don't care about the full C standard but a subset. We rely on extrastandard behavior all over the place. For all ABIs supported by the kernel, sizeof(_Book) == 1 and so everything is

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread H. Peter Anvin
On 02/27/2014 07:24 AM, Theodore Ts'o wrote: On Thu, Feb 27, 2014 at 07:10:25AM -0800, H. Peter Anvin wrote: Keep in mind, too, that for the kernel we don't care about the full C standard but a subset. We rely on extrastandard behavior all over the place. For all ABIs supported by the

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Borislav Petkov
On Thu, Feb 27, 2014 at 07:48:35AM -0800, H. Peter Anvin wrote: No, but I think we can certainly make a list... a lot of it right now sits in various people's heads. Here are a couple: - Bytes are 8 bits - Signed integers will be 2's complement - sizeof char, short, int, long, and long

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Dan Carpenter
On Thu, Feb 27, 2014 at 07:48:35AM -0800, H. Peter Anvin wrote: Do we have a fairly comprehensive list of what these extrastandard requirements / assumptions are? It might be a good idea to have one that we can point to, so that (a) people who are trying to define a new architecture knows

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread H. Peter Anvin
On 02/27/2014 08:10 AM, Dan Carpenter wrote: That last assumption has to change for the Meta architecture. https://lwn.net/Articles/522188/ On meta, the structs and unions are padded to 4 bytes unless they are explicitly marked as __packed. One have to wonder how likely they are to

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread James Hogan
On 27/02/14 16:52, H. Peter Anvin wrote: On 02/27/2014 08:10 AM, Dan Carpenter wrote: That last assumption has to change for the Meta architecture. https://lwn.net/Articles/522188/ On meta, the structs and unions are padded to 4 bytes unless they are explicitly marked as __packed. One

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Christopher Li
On Wed, Feb 26, 2014 at 8:32 PM, H. Peter Anvin h...@zytor.com wrote: Quite frankly, this is silly in my opinion, *and* it is not guaranteed by C either (read about trap representations). Anything that moves data around in a generic fashion. It can be as simple as: memcpy(foo,

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread H. Peter Anvin
I would. On February 27, 2014 12:22:45 PM PST, Christopher Li spa...@chrisli.org wrote: On Wed, Feb 26, 2014 at 8:32 PM, H. Peter Anvin h...@zytor.com wrote: Quite frankly, this is silly in my opinion, *and* it is not guaranteed by C either (read about trap representations). Anything that

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Joe Perches
On Thu, 2014-02-27 at 12:26 -0800, H. Peter Anvin wrote: On February 27, 2014 12:22:45 PM PST, Christopher Li spa...@chrisli.org wrote: OK. I get it nobody wants a sizeof(_Bool) warning. I am going to apply this patch. Please use V3 as I stuffed up the alphabetic order of sizeof and shadow.

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Christopher Li
On Thu, Feb 27, 2014 at 12:26 PM, H. Peter Anvin h...@zytor.com wrote: I would. Joe, I assume you are OK with this patch, the default is now off. Chris Allow an override to emit or not the sizeof(bool) warning. Add a -Wsizeof-bool description to the manpage. Signed-off-by: Joe Perches

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Christopher Li
On Thu, Feb 27, 2014 at 12:39 PM, Joe Perches j...@perches.com wrote: Please use V3 as I stuffed up the alphabetic order of sizeof and shadow. Please send it your V3 then :-) I'm not sure it matters much, but the linux-kernel Makefile wouldn't need to be changed if Wsizeof_bool is default

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Joe Perches
On Thu, 2014-02-27 at 12:44 -0800, Christopher Li wrote: On Thu, Feb 27, 2014 at 12:26 PM, H. Peter Anvin h...@zytor.com wrote: I would. Joe, I assume you are OK with this patch, the default is now off. Of course diff --git a/lib.c b/lib.c [] @@ -226,6 +226,7 @@ int Wparen_string = 0;

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Christopher Li
On Thu, Feb 27, 2014 at 1:00 PM, Joe Perches j...@perches.com wrote: On Thu, 2014-02-27 at 12:44 -0800, Christopher Li wrote: On Thu, Feb 27, 2014 at 12:26 PM, H. Peter Anvin h...@zytor.com wrote: I would. Joe, I assume you are OK with this patch, the default is now off. Of course Let me

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Christopher Li
On Thu, Feb 27, 2014 at 1:00 PM, Joe Perches j...@perches.com wrote: Of course The change has applied and pushed. Chris -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-27 Thread Joe Perches
On Thu, 2014-02-27 at 12:55 -0800, Christopher Li wrote: On Thu, Feb 27, 2014 at 12:39 PM, Joe Perches j...@perches.com wrote: Maybe the evaluate.c size = bits_in_char; assignment if (size == 1 is_bool_type(type)) { - warning(expr-pos, expression using sizeof

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-26 Thread H. Peter Anvin
On 02/26/2014 08:26 PM, Ben Pfaff wrote: > >> Because sizeof(_Bool) is a little bit special compare to sizeof(long). >> In the case of long, all sizeof(long) * 8 bits are use in the actual value. >> But for the _Bool, only the 1 bit is used in the 8 bits size. In other words, >> the _Bool has a

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-26 Thread Ben Pfaff
On Wed, Feb 26, 2014 at 08:19:57PM -0800, H. Peter Anvin wrote: > On 02/26/2014 08:00 PM, Ben Pfaff wrote: > > > > The commit *relaxed* sparse behavior: because previously sizeof(bool) > > was an error. I'm not in favor of any diagnostic at all for > > sizeof(bool), but my recollection is that a

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-26 Thread H. Peter Anvin
On 02/26/2014 08:00 PM, Ben Pfaff wrote: > > The commit *relaxed* sparse behavior: because previously sizeof(bool) > was an error. I'm not in favor of any diagnostic at all for > sizeof(bool), but my recollection is that a sparse maintainer wanted it > to yield one. > Still not clear as to

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-26 Thread Ben Pfaff
On Wed, Feb 26, 2014 at 07:38:46PM -0800, Joe Perches wrote: > (adding Ben Pfaff and Christopher Li) > > On Wed, 2014-02-26 at 19:29 -0800, H. Peter Anvin wrote: > > On 02/26/2014 06:58 PM, Josh Triplett wrote: > > > On Wed, Feb 26, 2014 at 06:53:14PM -0800, Joe Perches wrote: > > >> Allow an

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-26 Thread H. Peter Anvin
sizeof(_Bool), like for many other types, is ABI-dependent, but that doesn't mean it is illegitimate. I don't think C99 says that it is invalid (which means C99 doesn't permit is to be a packed bitmap.) On February 26, 2014 7:38:46 PM PST, Joe Perches wrote: >(adding Ben Pfaff and Christopher

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-26 Thread Joe Perches
(adding Ben Pfaff and Christopher Li) On Wed, 2014-02-26 at 19:29 -0800, H. Peter Anvin wrote: > On 02/26/2014 06:58 PM, Josh Triplett wrote: > > On Wed, Feb 26, 2014 at 06:53:14PM -0800, Joe Perches wrote: > >> Allow an override to emit or not the sizeof(bool) warning > >> Add a description to

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-26 Thread H. Peter Anvin
On 02/26/2014 06:58 PM, Josh Triplett wrote: > On Wed, Feb 26, 2014 at 06:53:14PM -0800, Joe Perches wrote: >> Allow an override to emit or not the sizeof(bool) warning >> Add a description to the manpage. >> >> Signed-off-by: Joe Perches > > Reviewed-by: Josh Triplett > I have to admit that

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-26 Thread Josh Triplett
On Wed, Feb 26, 2014 at 06:53:14PM -0800, Joe Perches wrote: > Allow an override to emit or not the sizeof(bool) warning > Add a description to the manpage. > > Signed-off-by: Joe Perches Reviewed-by: Josh Triplett > evaluate.c | 3 ++- > lib.c | 2 ++ > lib.h | 1 + > sparse.1 |

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-26 Thread Josh Triplett
On Wed, Feb 26, 2014 at 06:53:14PM -0800, Joe Perches wrote: Allow an override to emit or not the sizeof(bool) warning Add a description to the manpage. Signed-off-by: Joe Perches j...@perches.com Reviewed-by: Josh Triplett j...@joshtriplett.org evaluate.c | 3 ++- lib.c | 2 ++

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-26 Thread H. Peter Anvin
On 02/26/2014 06:58 PM, Josh Triplett wrote: On Wed, Feb 26, 2014 at 06:53:14PM -0800, Joe Perches wrote: Allow an override to emit or not the sizeof(bool) warning Add a description to the manpage. Signed-off-by: Joe Perches j...@perches.com Reviewed-by: Josh Triplett j...@joshtriplett.org

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-26 Thread Joe Perches
(adding Ben Pfaff and Christopher Li) On Wed, 2014-02-26 at 19:29 -0800, H. Peter Anvin wrote: On 02/26/2014 06:58 PM, Josh Triplett wrote: On Wed, Feb 26, 2014 at 06:53:14PM -0800, Joe Perches wrote: Allow an override to emit or not the sizeof(bool) warning Add a description to the

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-26 Thread H. Peter Anvin
sizeof(_Bool), like for many other types, is ABI-dependent, but that doesn't mean it is illegitimate. I don't think C99 says that it is invalid (which means C99 doesn't permit is to be a packed bitmap.) On February 26, 2014 7:38:46 PM PST, Joe Perches j...@perches.com wrote: (adding Ben Pfaff

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-26 Thread Ben Pfaff
On Wed, Feb 26, 2014 at 07:38:46PM -0800, Joe Perches wrote: (adding Ben Pfaff and Christopher Li) On Wed, 2014-02-26 at 19:29 -0800, H. Peter Anvin wrote: On 02/26/2014 06:58 PM, Josh Triplett wrote: On Wed, Feb 26, 2014 at 06:53:14PM -0800, Joe Perches wrote: Allow an override to

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-26 Thread H. Peter Anvin
On 02/26/2014 08:00 PM, Ben Pfaff wrote: The commit *relaxed* sparse behavior: because previously sizeof(bool) was an error. I'm not in favor of any diagnostic at all for sizeof(bool), but my recollection is that a sparse maintainer wanted it to yield one. Still not clear as to why.

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-26 Thread Ben Pfaff
On Wed, Feb 26, 2014 at 08:19:57PM -0800, H. Peter Anvin wrote: On 02/26/2014 08:00 PM, Ben Pfaff wrote: The commit *relaxed* sparse behavior: because previously sizeof(bool) was an error. I'm not in favor of any diagnostic at all for sizeof(bool), but my recollection is that a sparse

Re: [PATCH V2] sparse: Allow override of sizeof(bool) warning

2014-02-26 Thread H. Peter Anvin
On 02/26/2014 08:26 PM, Ben Pfaff wrote: Because sizeof(_Bool) is a little bit special compare to sizeof(long). In the case of long, all sizeof(long) * 8 bits are use in the actual value. But for the _Bool, only the 1 bit is used in the 8 bits size. In other words, the _Bool has a special