Re: [PATCH] riscv: asm/gdb_xml.h: use __maybe_used to make W=1 warnings go away

From: Pierre-Louis Bossart
Date: Thu Jul 02 2020 - 11:02:55 EST




On 7/1/20 9:04 PM, Vincent Chen wrote:
On Thu, Jul 2, 2020 at 2:48 AM Pierre-Louis Bossart
<pierre-louis.bossart@xxxxxxxxxxxxxxx> wrote:

0day/kbuild reports warnings with the ASoC codecs compiled with W=1.

In file included from arch/riscv/include/asm/kgdb.h:109,
from include/linux/kgdb.h:20,
from include/linux/fb.h:5,
from include/drm/drm_crtc.h:31,
from sound/soc/codecs/hdmi-codec.c:19:

arch/riscv/include/asm/gdb_xml.h:23:19: warning:
'riscv_gdb_stub_cpuxml' defined but not used [-Wunused-const-variable=]
23 | static const char riscv_gdb_stub_cpuxml[2048] =
| ^~~~~~~~~~~~~~~~~~~~~
arch/riscv/include/asm/gdb_xml.h:16:19: warning:
'riscv_gdb_stub_target_desc' defined but not used [-Wunused-const-variable=]
16 | static const char riscv_gdb_stub_target_desc[256] =
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
arch/riscv/include/asm/gdb_xml.h:13:19: warning:
'gdb_xfer_read_cpuxml' defined but not used [-Wunused-const-variable=]
13 | static const char gdb_xfer_read_cpuxml[39] =
| ^~~~~~~~~~~~~~~~~~~~
arch/riscv/include/asm/gdb_xml.h:10:19: warning:
'gdb_xfer_read_target' defined but not used [-Wunused-const-variable=]
10 | static const char gdb_xfer_read_target[31] = "qXfer:features:read:target.xml:";
| ^~~~~~~~~~~~~~~~~~~~
arch/riscv/include/asm/gdb_xml.h:7:19: warning:
'riscv_gdb_stub_feature' defined but not used [-Wunused-const-variable=]
7 | static const char riscv_gdb_stub_feature[64] =
| ^~~~~~~~~~~~~~~~~~~~~~

Reported-by: kernel test robot <lkp@xxxxxxxxx>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@xxxxxxxxxxxxxxx>
---

I don't know if this is the right way of solving this issue but this
error is now consistently thrown in kbuild compile-test reports w/
W=1.


Dear Pierre-Louis Bossart:
Thanks for your modifications. I have fixed the warnings in my latest
KGDB patchset and sent it out, but the merged KGDB patchset is not my
latest version.
I have sent a patch set to complement the missing ports, and I think
these warnings would disappear after this patch has been accepted and
merged.

Here is the patch to fix this warning:
http://lists.infradead.org/pipermail/linux-riscv/2020-June/000660.html

Thank you Vincent, let's drop my hacky patch then.