diff mbox series

platform/x86/amd/hsmp: mark hsmp_msg_desc_table[] as maybe_unused

Message ID 20241028163553.2452486-1-arnd@kernel.org (mailing list archive)
State New
Headers show
Series platform/x86/amd/hsmp: mark hsmp_msg_desc_table[] as maybe_unused | expand

Commit Message

Arnd Bergmann Oct. 28, 2024, 4:35 p.m. UTC
From: Arnd Bergmann <arnd@arndb.de>

After the file got split, there are now W=1 warnings for users that
include it without referencing hsmp_msg_desc_table:

In file included from arch/x86/include/asm/amd_hsmp.h:6,
                 from drivers/platform/x86/amd/hsmp/plat.c:12:
arch/x86/include/uapi/asm/amd_hsmp.h:91:35: error: 'hsmp_msg_desc_table' defined but not used [-Werror=unused-const-variable=]
   91 | static const struct hsmp_msg_desc hsmp_msg_desc_table[] = {
      |                                   ^~~~~~~~~~~~~~~~~~~

Mark it as __attribute__((maybe_unused)) to shut up the warning but
keep it in the file in case it is used from userland. The __maybe_unused
shorthand unfurtunately isn't available in userspace, so this has to
be the long form.

Fixes: e47c018a0ee6 ("platform/x86/amd/hsmp: Move platform device specific code to plat.c")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
Ideally this array wouldn't be part of the UAPI at all, since it is
not really a interface, but it's hard to know what part  of the header
is actually used outside of the kernel.
---
 arch/x86/include/uapi/asm/amd_hsmp.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Ilpo Järvinen Oct. 29, 2024, 12:55 p.m. UTC | #1
On Mon, 28 Oct 2024, Arnd Bergmann wrote:

+ Hans

> From: Arnd Bergmann <arnd@arndb.de>
>
> After the file got split, there are now W=1 warnings for users that
> include it without referencing hsmp_msg_desc_table:
> 
> In file included from arch/x86/include/asm/amd_hsmp.h:6,
>                  from drivers/platform/x86/amd/hsmp/plat.c:12:
> arch/x86/include/uapi/asm/amd_hsmp.h:91:35: error: 'hsmp_msg_desc_table' defined but not used [-Werror=unused-const-variable=]
>    91 | static const struct hsmp_msg_desc hsmp_msg_desc_table[] = {
>       |                                   ^~~~~~~~~~~~~~~~~~~
> 
> Mark it as __attribute__((maybe_unused)) to shut up the warning but
> keep it in the file in case it is used from userland. The __maybe_unused
> shorthand unfurtunately isn't available in userspace, so this has to

unfortunately

> be the long form.
> 
> Fixes: e47c018a0ee6 ("platform/x86/amd/hsmp: Move platform device specific code to plat.c")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> Ideally this array wouldn't be part of the UAPI at all, since it is
> not really a interface, but it's hard to know what part  of the header
> is actually used outside of the kernel.

Sadly this slipped through during review even if it was brought up by 
somebody back then. The (rather weak) reasoning for having it as a part of 
UAPI was seemingly accepted uncontested :-(.

> ---
>  arch/x86/include/uapi/asm/amd_hsmp.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/include/uapi/asm/amd_hsmp.h b/arch/x86/include/uapi/asm/amd_hsmp.h
> index e5d182c7373c..4a7cace06204 100644
> --- a/arch/x86/include/uapi/asm/amd_hsmp.h
> +++ b/arch/x86/include/uapi/asm/amd_hsmp.h
> @@ -88,7 +88,8 @@ struct hsmp_msg_desc {
>   *
>   * Not supported messages would return -ENOMSG.
>   */
> -static const struct hsmp_msg_desc hsmp_msg_desc_table[] = {
> +static const struct hsmp_msg_desc hsmp_msg_desc_table[]
> +				__attribute__((unused)) = {

It seems that the main goal why it was put into UAPI was "to give the user 
some reference about proper num_args and response_size for each message":

https://lore.kernel.org/all/CAPhsuW5V0BJT+YSwv1U=hRG0k9zBWXeRd=E1n4U5hvcnwEV3mQ@mail.gmail.com/

Are we actually expecting userspace to benefit from this in C form?
Suma? Hans?

>  	/* RESERVED */
>  	{0, 0, HSMP_RSVD},
diff mbox series

Patch

diff --git a/arch/x86/include/uapi/asm/amd_hsmp.h b/arch/x86/include/uapi/asm/amd_hsmp.h
index e5d182c7373c..4a7cace06204 100644
--- a/arch/x86/include/uapi/asm/amd_hsmp.h
+++ b/arch/x86/include/uapi/asm/amd_hsmp.h
@@ -88,7 +88,8 @@  struct hsmp_msg_desc {
  *
  * Not supported messages would return -ENOMSG.
  */
-static const struct hsmp_msg_desc hsmp_msg_desc_table[] = {
+static const struct hsmp_msg_desc hsmp_msg_desc_table[]
+				__attribute__((unused)) = {
 	/* RESERVED */
 	{0, 0, HSMP_RSVD},