[PATCH 15/52] m68k: emu: Mark version[] __maybe_unused

Geert Uytterhoeven posted 52 patches 2 years, 3 months ago
There is a newer version of this series
[PATCH 15/52] m68k: emu: Mark version[] __maybe_unused
Posted by Geert Uytterhoeven 2 years, 3 months ago
When building with W=1:

    m68k/arch/m68k/emu/nfeth.c:42:19: warning: ‘version’ defined but not used [-Wunused-const-variable=]
       42 | static const char version[] =
	  |                   ^~~~~~~

Fix this while obeying the wishes of the original copyright holders by
marking version[] with __maybe_unused.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 arch/m68k/emu/nfeth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/m68k/emu/nfeth.c b/arch/m68k/emu/nfeth.c
index 1a5d1e8eb4c80839..26e68813f35144f8 100644
--- a/arch/m68k/emu/nfeth.c
+++ b/arch/m68k/emu/nfeth.c
@@ -39,7 +39,7 @@ enum {
 #define MAX_UNIT	8
 
 /* These identify the driver base version and may not be removed. */
-static const char version[] =
+static const char version[] __maybe_unused =
 	KERN_INFO KBUILD_MODNAME ".c:v" DRV_VERSION " " DRV_RELDATE
 	" S.Opichal, M.Jurik, P.Stehlik\n"
 	KERN_INFO " http://aranym.org/\n";
-- 
2.34.1

Re: [PATCH 15/52] m68k: emu: Mark version[] __maybe_unused
Posted by Arnd Bergmann 2 years, 3 months ago
On Thu, Sep 7, 2023, at 15:41, Geert Uytterhoeven wrote:
> When building with W=1:
>
>     m68k/arch/m68k/emu/nfeth.c:42:19: warning: ‘version’ defined but 
> not used [-Wunused-const-variable=]
>        42 | static const char version[] =
> 	  |                   ^~~~~~~
>
> Fix this while obeying the wishes of the original copyright holders by
> marking version[] with __maybe_unused.
>
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

That will just drop it from the object file, maybe it should
instead be marked "__used" ?

      Arnd
Re: [PATCH 15/52] m68k: emu: Mark version[] __maybe_unused
Posted by Geert Uytterhoeven 2 years, 3 months ago
Hi Arnd,

On Sat, Sep 9, 2023 at 10:28 AM Arnd Bergmann <arnd@arndb.de> wrote:
> On Thu, Sep 7, 2023, at 15:41, Geert Uytterhoeven wrote:
> > When building with W=1:
> >
> >     m68k/arch/m68k/emu/nfeth.c:42:19: warning: ‘version’ defined but
> > not used [-Wunused-const-variable=]
> >        42 | static const char version[] =
> >         |                   ^~~~~~~
> >
> > Fix this while obeying the wishes of the original copyright holders by
> > marking version[] with __maybe_unused.
> >
> > Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
>
> That will just drop it from the object file, maybe it should
> instead be marked "__used" ?

Given it's been like this since the beginning, I guess it never showed
up in the object file anyway...

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Re: [PATCH 15/52] m68k: emu: Mark version[] __maybe_unused
Posted by Arnd Bergmann 2 years, 3 months ago
On Sat, Sep 9, 2023, at 14:12, Geert Uytterhoeven wrote:
> Hi Arnd,
>
> On Sat, Sep 9, 2023 at 10:28 AM Arnd Bergmann <arnd@arndb.de> wrote:
>> On Thu, Sep 7, 2023, at 15:41, Geert Uytterhoeven wrote:
>> > When building with W=1:
>> >
>> >     m68k/arch/m68k/emu/nfeth.c:42:19: warning: ‘version’ defined but
>> > not used [-Wunused-const-variable=]
>> >        42 | static const char version[] =
>> >         |                   ^~~~~~~
>> >
>> > Fix this while obeying the wishes of the original copyright holders by
>> > marking version[] with __maybe_unused.
>> >
>> > Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
>>
>> That will just drop it from the object file, maybe it should
>> instead be marked "__used" ?
>
> Given it's been like this since the beginning, I guess it never showed
> up in the object file anyway...

Older compilers used to keep unused variables, and all versions
still do when building with -O0 instead of the usual -O2.

I can see on godbolt.org that gcc-1.27 did not have that optimization
yet, while gcc-4.1 had it, but I haven't found any versions between
those. I vaguely remember us throwing out the version strings from
most kernel files a long time ago, possibly that was triggered by
gcc no longer putting them into the object any more, but I can't
find a reference for that.

What I can see is that a lot of old network drivers have version
strings like this one, but they are actually printed from the
probe function, and lost their __devinitdata annotation in the past.

      Arnd
Re: [PATCH 15/52] m68k: emu: Mark version[] __maybe_unused
Posted by Geert Uytterhoeven 2 years, 3 months ago
Hi Arnd,

On Sat, Sep 9, 2023 at 4:07 PM Arnd Bergmann <arnd@arndb.de> wrote:
> On Sat, Sep 9, 2023, at 14:12, Geert Uytterhoeven wrote:
> > On Sat, Sep 9, 2023 at 10:28 AM Arnd Bergmann <arnd@arndb.de> wrote:
> >> On Thu, Sep 7, 2023, at 15:41, Geert Uytterhoeven wrote:
> >> > When building with W=1:
> >> >
> >> >     m68k/arch/m68k/emu/nfeth.c:42:19: warning: ‘version’ defined but
> >> > not used [-Wunused-const-variable=]
> >> >        42 | static const char version[] =
> >> >         |                   ^~~~~~~
> >> >
> >> > Fix this while obeying the wishes of the original copyright holders by
> >> > marking version[] with __maybe_unused.
> >> >
> >> > Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> >>
> >> That will just drop it from the object file, maybe it should
> >> instead be marked "__used" ?
> >
> > Given it's been like this since the beginning, I guess it never showed
> > up in the object file anyway...
>
> Older compilers used to keep unused variables, and all versions
> still do when building with -O0 instead of the usual -O2.
>
> I can see on godbolt.org that gcc-1.27 did not have that optimization
> yet, while gcc-4.1 had it, but I haven't found any versions between
> those. I vaguely remember us throwing out the version strings from
> most kernel files a long time ago, possibly that was triggered by
> gcc no longer putting them into the object any more, but I can't
> find a reference for that.
>
> What I can see is that a lot of old network drivers have version
> strings like this one, but they are actually printed from the
> probe function, and lost their __devinitdata annotation in the past.

The version string in arch/m68k/emu/nfeth.c used to be __devinitdata,
too, but it was never printed.  So I'm just gonna silence the warning,
as this patch does.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds