All of lore.kernel.org
 help / color / mirror / Atom feed
* sparse build breakage with 903c0c7cdc21f2ccb7562a7bbc70289c0c2b16ad
@ 2011-05-29  0:38 Dr. David Alan Gilbert
  2011-05-30  1:58 ` KOSAKI Motohiro
  0 siblings, 1 reply; 3+ messages in thread
From: Dr. David Alan Gilbert @ 2011-05-29  0:38 UTC (permalink / raw)
  To: kosaki.motohiro; +Cc: linux-kernel

Hi Kosaki,
  I'm getting a problem when running the current (5dbe0af47f8a8f968bac2991c3ec974c6e3eaabc)
kernel tree through sparse, and I think it's down to an
interaction between your commit

903c0c7cdc21f2ccb7562a7bbc70289c0c2b16ad sparse: define dummy BUILD_BUG_ON definition for sparse

and the __module_param_call code in moduleparam.h

The error is:
init/main.c:643:1: error: Syntax error in unary expression

core_param(initcall_debug, initcall_debug, bool, 0644);

this calls __module_param_call which is defined as:


#define __module_param_call(prefix, name, ops, arg, isbool, perm)       \
        /* Default value instead of permissions? */                     \
        static int __param_perm_check_##name __attribute__((unused)) =  \
        BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2))  \
        + BUILD_BUG_ON_ZERO(sizeof(""prefix) > MAX_PARAM_PREFIX_LEN);   \
        static const char __param_str_##name[] = prefix #name;          \
        static struct kernel_param __moduleparam_const __param_##name   \
        __used                                                          \
    __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \
        = { __param_str_##name, ops, perm, isbool ? KPARAM_ISBOOL : 0,  \
            { arg } }

which ends up with a postprocessed line of:

static inline void __check_initcall_debug(void) {; }; static int __param_perm_check_initcall_debug __attribute__((unused)) = +; static const char __param_str_initcall_debug[] = "" "initcall_debug"; static struct kernel_param const __param_initcall_debug __attribute__((__used__)) __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) = { __param_str_initcall_debug, &param_ops_bool, 0644, __builtin_types_compatible_p(typeof(initcall_debug), typeof(bool)) ? 2 : 0, { &initcall_debug } };

Note the '+;' being assigned to __param_perm_check_initcall_debug

So I think your dummy BUILD_BUG_ON_ZERO's needs to have a value:

The following diff seems to fix it, but I've not let
a fuller sparse run complete yet:

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index fb0e732..953352a 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -671,8 +671,8 @@ struct sysinfo {
 
 #ifdef __CHECKER__
 #define BUILD_BUG_ON_NOT_POWER_OF_2(n)
-#define BUILD_BUG_ON_ZERO(e)
-#define BUILD_BUG_ON_NULL(e)
+#define BUILD_BUG_ON_ZERO(e) (0)
+#define BUILD_BUG_ON_NULL(e) ((void*)0)
 #define BUILD_BUG_ON(condition)
 #else /* __CHECKER__ */
 




-- 
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\ gro.gilbert @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: sparse build breakage with 903c0c7cdc21f2ccb7562a7bbc70289c0c2b16ad
  2011-05-29  0:38 sparse build breakage with 903c0c7cdc21f2ccb7562a7bbc70289c0c2b16ad Dr. David Alan Gilbert
@ 2011-05-30  1:58 ` KOSAKI Motohiro
  2011-05-30 16:03   ` [PATCH] Fix BUILD_BUG_ON_ZERO sparse breakage Dr. David Alan Gilbert
  0 siblings, 1 reply; 3+ messages in thread
From: KOSAKI Motohiro @ 2011-05-30  1:58 UTC (permalink / raw)
  To: linux; +Cc: linux-kernel

(2011/05/29 9:38), Dr. David Alan Gilbert wrote:
> Hi Kosaki,
>   I'm getting a problem when running the current (5dbe0af47f8a8f968bac2991c3ec974c6e3eaabc)
> kernel tree through sparse, and I think it's down to an
> interaction between your commit
> 
> 903c0c7cdc21f2ccb7562a7bbc70289c0c2b16ad sparse: define dummy BUILD_BUG_ON definition for sparse
> 
> and the __module_param_call code in moduleparam.h
> 
> The error is:
> init/main.c:643:1: error: Syntax error in unary expression
> 
> core_param(initcall_debug, initcall_debug, bool, 0644);
> 
> this calls __module_param_call which is defined as:
> 
> 
> #define __module_param_call(prefix, name, ops, arg, isbool, perm)       \
>         /* Default value instead of permissions? */                     \
>         static int __param_perm_check_##name __attribute__((unused)) =  \
>         BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2))  \
>         + BUILD_BUG_ON_ZERO(sizeof(""prefix) > MAX_PARAM_PREFIX_LEN);   \
>         static const char __param_str_##name[] = prefix #name;          \
>         static struct kernel_param __moduleparam_const __param_##name   \
>         __used                                                          \
>     __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \
>         = { __param_str_##name, ops, perm, isbool ? KPARAM_ISBOOL : 0,  \
>             { arg } }
> 
> which ends up with a postprocessed line of:
> 
> static inline void __check_initcall_debug(void) {; }; static int __param_perm_check_initcall_debug __attribute__((unused)) = +; static const char __param_str_initcall_debug[] = "" "initcall_debug"; static struct kernel_param const __param_initcall_debug __attribute__((__used__)) __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) = { __param_str_initcall_debug, &param_ops_bool, 0644, __builtin_types_compatible_p(typeof(initcall_debug), typeof(bool)) ? 2 : 0, { &initcall_debug } };
> 
> Note the '+;' being assigned to __param_perm_check_initcall_debug
> 
> So I think your dummy BUILD_BUG_ON_ZERO's needs to have a value:
> 
> The following diff seems to fix it, but I've not let
> a fuller sparse run complete yet:
> 
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index fb0e732..953352a 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -671,8 +671,8 @@ struct sysinfo {
>  
>  #ifdef __CHECKER__
>  #define BUILD_BUG_ON_NOT_POWER_OF_2(n)
> -#define BUILD_BUG_ON_ZERO(e)
> -#define BUILD_BUG_ON_NULL(e)
> +#define BUILD_BUG_ON_ZERO(e) (0)
> +#define BUILD_BUG_ON_NULL(e) ((void*)0)
>  #define BUILD_BUG_ON(condition)
>  #else /* __CHECKER__ */
>  

Hi David,

Right you are. Can you please send a formal patch and append following line?
	Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>

Thanks.








^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] Fix BUILD_BUG_ON_ZERO sparse breakage
  2011-05-30  1:58 ` KOSAKI Motohiro
@ 2011-05-30 16:03   ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 3+ messages in thread
From: Dr. David Alan Gilbert @ 2011-05-30 16:03 UTC (permalink / raw)
  To: linux-kernel; +Cc: KOSAKI Motohiro, akpm

BUILD_BUG_ON_ZERO and BUILD_BUG_ON_NULL must return values, even in the CHECKER
case otherwise various users of it become syntactically invalid.

Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index fb0e732..953352a 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -671,8 +671,8 @@ struct sysinfo {
 
 #ifdef __CHECKER__
 #define BUILD_BUG_ON_NOT_POWER_OF_2(n)
-#define BUILD_BUG_ON_ZERO(e)
-#define BUILD_BUG_ON_NULL(e)
+#define BUILD_BUG_ON_ZERO(e) (0)
+#define BUILD_BUG_ON_NULL(e) ((void*)0)
 #define BUILD_BUG_ON(condition)
 #else /* __CHECKER__ */
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-30 16:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-29  0:38 sparse build breakage with 903c0c7cdc21f2ccb7562a7bbc70289c0c2b16ad Dr. David Alan Gilbert
2011-05-30  1:58 ` KOSAKI Motohiro
2011-05-30 16:03   ` [PATCH] Fix BUILD_BUG_ON_ZERO sparse breakage Dr. David Alan Gilbert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.