bits_in_bool should be 8
RFC PATCH 1/1 bits_in_bool should be 8
Given that we're working with byte-addressable machines, each type must be at least one byte in size or you'd not be able to take a pointer to it.
Noticed at random when I ran the sample "compile" program in the sparse source tree vs. a test C program that uses bools. It crashes without this patch.
--- target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target.c +1 -1
@@ -14,7 +14,7 @@ int max_alignment = 16;/* * Integer data types */ -int bits_in_bool =1 ; +int bits_in_bool =8 ;int bits_in_char =8 ;int bits_in_short =16 ;int bits_in_int =32 ;
Signature · 1 line
2.7.4
Christopher Li
maintainerQuoted 7 lines · Jeff Layton
Given that we're working with byte-addressable machines, each type must be at least one byte in size or you'd not be able to take a pointer to it.
Noticed at random when I ran the sample "compile" program in the sparse source tree vs. a test C program that uses bools. It crashes without this patch.
Do you have the test program to crash sparse?
Sparse should handle bool size correctly. The bits_in_bool is a internal thing for sparse. From sizeof(bool) point of view, sparse should treat sizeof(bool) as 8 bits. But bool has only one bit usable value.
Chris
Quoted 9 lines · Christopher Li
Quoted 7 lines · Jeff Layton
Given that we're working with byte-addressable machines, each type must be at least one byte in size or you'd not be able to take a pointer to it.
Noticed at random when I ran the sample "compile" program in the sparse source tree vs. a test C program that uses bools. It crashes without this patch.
Quoted 8 lines
Do you have the test program to crash sparse?
Sparse should handle bool size correctly. The
bits_in_boolis a internal thing for sparse. From sizeof(bool) point of view, sparse should treat sizeof(bool) as 8 bits. But bool has only one bit usable value.Chris
Attached. This is also the program I was using to track down the storage_modifiers problem.
To be clear though, sparse doesn't crash here. I happened to run the "compile" example program that's in the sources against it while poking at the other problem and noticed that it crashed.
I don't think we really care much about "compile", but it looked like it might be indicative of a problem in sparse itself.
Signature · 1 line
Jeff Layton <[email protected]>
#include <stdio.h>
#include <stdbool.h>
#define MAX_ERRNO 4095
#define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO) #define __force __attribute__((force))
static inline bool IS_ERR(__force const void *ptr)
{
return IS_ERR_VALUE((unsigned long)ptr);
}intmain(int argc, char **argv)
{
return IS_ERR(NULL);
}