sparse warnings in overflow.h
Hi Kees,
sparse (make C=1) gives me this warnings today...
./include/linux/overflow.h:254:13: error: undefined identifier '__builtin_mul_overflow' ./include/linux/overflow.h:254:13: error: incorrect type in conditional./include/linux/overflow.h:254:13: got void./include/linux/overflow.h:256:13: error: undefined identifier '__builtin_add_overflow' ./include/linux/overflow.h:256:13: error: incorrect type in conditional./include/linux/overflow.h:256:13: got void
This hunk obviously fixes it, but I'm really not sure if it is a proper fix.
include/linux/compiler-gcc.h +1 -1
@@ -344,6 +344,6 @@*/ #define uninitialized_var (x) x = x -#if GCC_VERSION >=50100 +#if GCC_VERSION >=50100 && !defined(__CHECKER__)#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1#endif
Any idea?
Regards,
Miroslav
Quoted 28 lines · Miroslav Benes
Hi Kees,
sparse (make C=1) gives me this warnings today...
./include/linux/overflow.h:254:13: error: undefined identifier '__builtin_mul_overflow'./include/linux/overflow.h:254:13: error: incorrect type in conditional./include/linux/overflow.h:254:13: got void./include/linux/overflow.h:256:13: error: undefined identifier '__builtin_add_overflow'./include/linux/overflow.h:256:13: error: incorrect type in conditional./include/linux/overflow.h:256:13: got voidThis hunk obviously fixes it, but I'm really not sure if it is a proper fix.
include/linux/compiler-gcc.h +1
-1@@ -344,6 +344,6 @@*/ #define uninitialized_var (x) x = x -#if GCC_VERSION >=50100 +#if GCC_VERSION >=50100 && !defined(__CHECKER__)#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1#endif
Quoted 1 line
Any idea?
Hi! Yeah, that's probably the correct approach. If the checker doesn't have it, the builtins need to be disabled. :)
Can you send this with a Signed-off-by line, etc, and I'll take it for sending to Linus?
Thanks!
-Kees
Signature · 2 lines
Kees Cook Pixel Security
Quoted 29 lines · Kees Cook
Quoted 28 lines · Miroslav Benes
Hi Kees,
sparse (make C=1) gives me this warnings today...
./include/linux/overflow.h:254:13: error: undefined identifier '__builtin_mul_overflow'./include/linux/overflow.h:254:13: error: incorrect type in conditional./include/linux/overflow.h:254:13: got void./include/linux/overflow.h:256:13: error: undefined identifier '__builtin_add_overflow'./include/linux/overflow.h:256:13: error: incorrect type in conditional./include/linux/overflow.h:256:13: got voidThis hunk obviously fixes it, but I'm really not sure if it is a proper fix.
include/linux/compiler-gcc.h +1
-1@@ -344,6 +344,6 @@*/ #define uninitialized_var (x) x = x -#if GCC_VERSION >=50100 +#if GCC_VERSION >=50100 && !defined(__CHECKER__)#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1#endif
Quoted 4 lines
Quoted 1 line
Any idea?
Hi! Yeah, that's probably the correct approach. If the checker doesn't have it, the builtins need to be disabled. :)
IIRC, the problem is that sparse pretends to be the gcc sparse itself was built with, which is obviously entirely unrelated to the C dialect that that particular sparse version groks. Sigh. Ack to the fix above.
Rasmus
Quoted 4 lines · Rasmus Villemoes
IIRC, the problem is that sparse pretends to be the gcc sparse itself was built with, which is obviously entirely unrelated to the C dialect that that particular sparse version groks. Sigh. Ack to the fix above.
Yes, indeed, and it is sometimes a problem.
Ideal would be that sparse would pretend to be same GCC as the one used to compile the code being checked *and* to have exactly the same features.
Pretending to be an older version of GCC would maybe solve the present problem it's not really a general solution.
One good thing would be to not depend on GCC versions to enable some features (but GCC offers few facilities helping here).
Best regards,
-- Luc Van Oostenryck
PATCH 1/1 compiler-gcc.h: don't set COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW for sparse
In reply to Kees Cooksparse errors out with
./include/linux/overflow.h:254:13: error: undefined identifier '__builtin_mul_overflow' ./include/linux/overflow.h:254:13: error: incorrect type in conditional./include/linux/overflow.h:254:13: got void./include/linux/overflow.h:256:13: error: undefined identifier '__builtin_add_overflow' ./include/linux/overflow.h:256:13: error: incorrect type in conditional./include/linux/overflow.h:256:13: got void
Sparse has not acquired generic overflow builtins yet, so don't set COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW for it.
--- include/linux/compiler-gcc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/compiler-gcc.h +1 -1
@@ -344,6 +344,6 @@*/ #define uninitialized_var (x) x = x -#if GCC_VERSION >=50100 +#if GCC_VERSION >=50100 && !defined(__CHECKER__)#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1#endif
Signature · 1 line
2.17.0