[PATCH] build_bug.h: Also define static_assert() when __CHECKER__ is defined

Christophe Leroy christophe.leroy at csgroup.eu
Thu Jan 26 19:17:48 CET 2023


When doing a build with C=2, the following failure is encountered on
several files:

	  CHECK   arch/powerpc/cpu/mpc8xxx/fsl_lbc.c
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c: note: in included file (through arch/powerpc/include/asm/global_data.h, include/init.h):
	include/asm-generic/global_data.h:494:21: error: Expected ) in function declarator
	include/asm-generic/global_data.h:494:21: error: got (

And because of the error, the interesting part which are the
warnings don't appear. This is because static_assert() is defined
only when __CHECKER__ is not defined.

Add a stub when __CHECKER__ is defined. With that fix, the expected
warnings are now seen:

	  CHECK   arch/powerpc/cpu/mpc8xxx/fsl_lbc.c
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:32:27: warning: incorrect type in argument 1 (different address spaces)
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:32:27:    expected unsigned int const volatile [noderef] <asn:2> *addr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:32:27:    got unsigned int *
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:32:45: warning: incorrect type in argument 1 (different address spaces)
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:32:45:    expected unsigned int const volatile [noderef] <asn:2> *addr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:32:45:    got unsigned int *
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:35:24: warning: incorrect type in argument 1 (different address spaces)
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:35:24:    expected unsigned int const volatile [noderef] <asn:2> *addr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:35:24:    got unsigned int *
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:35:40: warning: incorrect type in argument 1 (different address spaces)
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:35:40:    expected unsigned int const volatile [noderef] <asn:2> *addr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:35:40:    got unsigned int *
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:67:17: warning: incorrect type in argument 1 (different address spaces)
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:67:17:    expected unsigned int volatile [noderef] <asn:2> *addr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:67:17:    got unsigned int *
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:68:17: warning: incorrect type in argument 1 (different address spaces)
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:68:17:    expected unsigned int volatile [noderef] <asn:2> *addr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:68:17:    got unsigned int *
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:72:17: warning: incorrect type in argument 1 (different address spaces)
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:72:17:    expected unsigned int volatile [noderef] <asn:2> *addr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:72:17:    got unsigned int *
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:73:17: warning: incorrect type in argument 1 (different address spaces)
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:73:17:    expected unsigned int volatile [noderef] <asn:2> *addr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:73:17:    got unsigned int *
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:78:9: warning: incorrect type in argument 1 (different address spaces)
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:78:9:    expected unsigned int volatile [noderef] <asn:2> *addr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:78:9:    got unsigned int *
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:79:9: warning: incorrect type in argument 1 (different address spaces)
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:79:9:    expected unsigned int volatile [noderef] <asn:2> *addr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:79:9:    got unsigned int *
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:131:22: warning: incorrect type in argument 1 (different address spaces)
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:131:22:    expected unsigned int const volatile [noderef] <asn:2> *addr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:131:22:    got unsigned int *
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:132:49: warning: incorrect type in argument 1 (different address spaces)
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:132:49:    expected unsigned int const volatile [noderef] <asn:2> *addr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:132:49:    got unsigned int *
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:144:26: warning: incorrect type in argument 1 (different address spaces)
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:144:26:    expected unsigned int volatile [noderef] <asn:2> *addr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:144:26:    got unsigned int [usertype] *mxmr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:144:41: warning: incorrect type in argument 1 (different address spaces)
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:144:41:    expected unsigned int const volatile [noderef] <asn:2> *addr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:144:41:    got unsigned int [usertype] *mxmr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:145:27: warning: incorrect type in argument 1 (different address spaces)
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:145:27:    expected unsigned int volatile [noderef] <asn:2> *addr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:145:27:    got unsigned int *
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:146:32: warning: incorrect type in argument 1 (different address spaces)
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:146:32:    expected unsigned int const volatile [noderef] <asn:2> *addr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:146:32:    got unsigned int *
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:149:39: warning: incorrect type in argument 1 (different address spaces)
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:149:39:    expected unsigned int const volatile [noderef] <asn:2> *addr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:149:39:    got unsigned int [usertype] *mxmr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:155:18: warning: incorrect type in argument 1 (different address spaces)
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:155:18:    expected unsigned int volatile [noderef] <asn:2> *addr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:155:18:    got unsigned int [usertype] *mxmr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:155:33: warning: incorrect type in argument 1 (different address spaces)
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:155:33:    expected unsigned int const volatile [noderef] <asn:2> *addr
	arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:155:33:    got unsigned int [usertype] *mxmr

Signed-off-by: Christophe Leroy <christophe.leroy at csgroup.eu>
---
CC: Masahiro Yamada <masahiroy at kernel.org>
---
 include/linux/build_bug.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/build_bug.h b/include/linux/build_bug.h
index 9c7088bafa4..5a819961f15 100644
--- a/include/linux/build_bug.h
+++ b/include/linux/build_bug.h
@@ -12,6 +12,7 @@
 #define BUILD_BUG_ON_MSG(cond, msg) (0)
 #define BUILD_BUG_ON(condition) (0)
 #define BUILD_BUG() (0)
+#define static_assert(expr, ...)
 #else /* __CHECKER__ */
 
 /* Force a compilation error if a constant expression is not a power of 2 */
-- 
2.38.1



More information about the U-Boot mailing list