[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK8P3a1O4kxMNH00+ox44RMs_pdoQv6+tTvnJOe21eXezs-y_A@mail.gmail.com>
Date: Thu, 22 Jun 2017 09:41:49 +0200
From: Arnd Bergmann <arnd@...db.de>
To: Ingo Molnar <mingo@...nel.org>
Cc: "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
Thomas Gleixner <tglx@...utronix.de>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Anna-Maria Gleixner <anna-maria@...utronix.de>,
Boris Ostrovsky <boris.ostrovsky@...cle.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] rcu: remove unused variable in boot_cpu_state_init
On Thu, Jun 22, 2017 at 9:26 AM, Ingo Molnar <mingo@...nel.org> wrote:
>
> * Paul E. McKenney <paulmck@...ux.vnet.ibm.com> wrote:
>
>> On Wed, Jun 21, 2017 at 11:57:28PM +0200, Arnd Bergmann wrote:
>> > Without CONFIG_SMP, we get a harmless warning about
>> > an unused variable:
>> >
>> > kernel/cpu.c: In function 'boot_cpu_state_init':
>> > kernel/cpu.c:1778:6: error: unused variable 'cpu' [-Werror=unused-variable]
>> >
>> > This reworks the function to have the declaration inside
>> > of the #ifdef.
>> >
>> > Fixes: faeb334286b7 ("rcu: Migrate callbacks earlier in the CPU-offline timeline")
>> > Signed-off-by: Arnd Bergmann <arnd@...db.de>
>>
>> I simply added a __maybe_unused in 6441c656acde ("rcu: Migrate callbacks
>> earlier in the CPU-offline timeline") in my -rcu tree. However, your
>> approach does have the advantage of complaining if the code using that
>> variable is removed.
>>
>> So, would you be OK with my folding your approach into my commit with
>> attribution?
>
> Also, note that __maybe_unused can be dangerous: it can hide a build warning where
> there's a _real_ unused variable bug now or due to future changes, causing a real
> runtime bug.
>
> So I think we should consider it a syntactic construct to avoid.
Unused variables are relatively harmless compared to used-uninitialized
variables that are always bugs (though they are provably impossible to
detect correctly in some cases).
For unused variables, we might want to enable "-Wunused-but-set" again.
This was introduced in gcc-5 or gcc-6 and moved to "make W=1" because
of too many new warnings getting introduced, but I already fixed a lot of
those. I'll give that a spin on my randconfig build test to see how many of
them we have remaining these days, if any.
Arnd
Powered by blists - more mailing lists