2020-07-01 18:51:38

by Pierre-Louis Bossart

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

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 <[email protected]>
Signed-off-by: Pierre-Louis Bossart <[email protected]>
---

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.

arch/riscv/include/asm/gdb_xml.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/riscv/include/asm/gdb_xml.h b/arch/riscv/include/asm/gdb_xml.h
index 041b45f5b997..c28fc1a1d230 100644
--- a/arch/riscv/include/asm/gdb_xml.h
+++ b/arch/riscv/include/asm/gdb_xml.h
@@ -4,23 +4,23 @@
#define __ASM_GDB_XML_H_

#define kgdb_arch_gdb_stub_feature riscv_gdb_stub_feature
-static const char riscv_gdb_stub_feature[64] =
+static __maybe_unused const char riscv_gdb_stub_feature[64] =
"PacketSize=800;qXfer:features:read+;";

-static const char gdb_xfer_read_target[31] = "qXfer:features:read:target.xml:";
+static __maybe_unused const char gdb_xfer_read_target[31] = "qXfer:features:read:target.xml:";

#ifdef CONFIG_64BIT
-static const char gdb_xfer_read_cpuxml[39] =
+static __maybe_unused const char gdb_xfer_read_cpuxml[39] =
"qXfer:features:read:riscv-64bit-cpu.xml";

-static const char riscv_gdb_stub_target_desc[256] =
+static __maybe_unused const char riscv_gdb_stub_target_desc[256] =
"l<?xml version=\"1.0\"?>"
"<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"
"<target>"
"<xi:include href=\"riscv-64bit-cpu.xml\"/>"
"</target>";

-static const char riscv_gdb_stub_cpuxml[2048] =
+static __maybe_unused const char riscv_gdb_stub_cpuxml[2048] =
"l<?xml version=\"1.0\"?>"
"<!DOCTYPE feature SYSTEM \"gdb-target.dtd\">"
"<feature name=\"org.gnu.gdb.riscv.cpu\">"
--
2.25.1


2020-07-02 02:07:41

by Vincent Chen

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

On Thu, Jul 2, 2020 at 2:48 AM Pierre-Louis Bossart
<[email protected]> 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 <[email protected]>
> Signed-off-by: Pierre-Louis Bossart <[email protected]>
> ---
>
> 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


> arch/riscv/include/asm/gdb_xml.h | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/arch/riscv/include/asm/gdb_xml.h b/arch/riscv/include/asm/gdb_xml.h
> index 041b45f5b997..c28fc1a1d230 100644
> --- a/arch/riscv/include/asm/gdb_xml.h
> +++ b/arch/riscv/include/asm/gdb_xml.h
> @@ -4,23 +4,23 @@
> #define __ASM_GDB_XML_H_
>
> #define kgdb_arch_gdb_stub_feature riscv_gdb_stub_feature
> -static const char riscv_gdb_stub_feature[64] =
> +static __maybe_unused const char riscv_gdb_stub_feature[64] =
> "PacketSize=800;qXfer:features:read+;";
>
> -static const char gdb_xfer_read_target[31] = "qXfer:features:read:target.xml:";
> +static __maybe_unused const char gdb_xfer_read_target[31] = "qXfer:features:read:target.xml:";
>
> #ifdef CONFIG_64BIT
> -static const char gdb_xfer_read_cpuxml[39] =
> +static __maybe_unused const char gdb_xfer_read_cpuxml[39] =
> "qXfer:features:read:riscv-64bit-cpu.xml";
>
> -static const char riscv_gdb_stub_target_desc[256] =
> +static __maybe_unused const char riscv_gdb_stub_target_desc[256] =
> "l<?xml version=\"1.0\"?>"
> "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"
> "<target>"
> "<xi:include href=\"riscv-64bit-cpu.xml\"/>"
> "</target>";
>
> -static const char riscv_gdb_stub_cpuxml[2048] =
> +static __maybe_unused const char riscv_gdb_stub_cpuxml[2048] =
> "l<?xml version=\"1.0\"?>"
> "<!DOCTYPE feature SYSTEM \"gdb-target.dtd\">"
> "<feature name=\"org.gnu.gdb.riscv.cpu\">"
> --
> 2.25.1
>

2020-07-02 15:04:25

by Pierre-Louis Bossart

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



On 7/1/20 9:04 PM, Vincent Chen wrote:
> On Thu, Jul 2, 2020 at 2:48 AM Pierre-Louis Bossart
> <[email protected]> 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 <[email protected]>
>> Signed-off-by: Pierre-Louis Bossart <[email protected]>
>> ---
>>
>> 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.