lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190625135238.GA3419@hirez.programming.kicks-ass.net>
Date:   Tue, 25 Jun 2019 15:52:38 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Qian Cai <cai@....pw>
Cc:     mingo@...hat.com, valentin.schneider@....com,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] sched/core: silence a warning in sched_init()

On Tue, Jun 25, 2019 at 08:44:22AM -0400, Qian Cai wrote:
> Compiling a kernel with both FAIR_GROUP_SCHED=n and RT_GROUP_SCHED=n
> will generate a warning using W=1,
> 
> kernel/sched/core.c: In function 'sched_init':
> kernel/sched/core.c:5906:32: warning: variable 'ptr' set but not used
> [-Wunused-but-set-variable]
>   unsigned long alloc_size = 0, ptr;
>                                 ^~~
> 
> It apparently the maintainers don't like the previous fix [1] which
> contains ugly idefs, so silence it by appending the __maybe_unused
> attribute for it instead.
> 
> Reviewed-by: Valentin Schneider <valentin.schneider@....com>
> Signed-off-by: Qian Cai <cai@....pw>
> ---
> 
> v2: Incorporate the feedback from Valentin.
> 
>  kernel/sched/core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 874c427742a9..12b9b69c8a66 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -5903,7 +5903,8 @@ int in_sched_functions(unsigned long addr)
>  void __init sched_init(void)
>  {
>  	int i, j;
> -	unsigned long alloc_size = 0, ptr;
> +	unsigned long alloc_size = 0;
> +	unsigned long __maybe_unused ptr;
>  

That still isn't particularly pretty.

Why do we care about W=1 build noise? Some of that seems rather silly,
like that -Wmissing-prototype nonsense.

As to this one, ideally the compiler would not be stupid, and understand
the below, but alas.

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index fa43ce3962e7..cb652e165570 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6369,7 +6369,7 @@ DECLARE_PER_CPU(cpumask_var_t, select_idle_mask);
 
 void __init sched_init(void)
 {
-	unsigned long alloc_size = 0, ptr;
+	unsigned long alloc_size = 0;
 	int i;
 
 	wait_bit_init();
@@ -6381,7 +6381,7 @@ void __init sched_init(void)
 	alloc_size += 2 * nr_cpu_ids * sizeof(void **);
 #endif
 	if (alloc_size) {
-		ptr = (unsigned long)kzalloc(alloc_size, GFP_NOWAIT);
+		unsigned long ptr = (unsigned long)kzalloc(alloc_size, GFP_NOWAIT);
 
 #ifdef CONFIG_FAIR_GROUP_SCHED
 		root_task_group.se = (struct sched_entity **)ptr;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ