[PATCH] reboot: hide unused hw_protection_attr

Arnd Bergmann posted 1 patch 9 months, 3 weeks ago
kernel/reboot.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] reboot: hide unused hw_protection_attr
Posted by Arnd Bergmann 9 months, 3 weeks ago
From: Arnd Bergmann <arnd@arndb.de>

The reference to hw_protection_attr is inside of an #ifdef block,
but the definition is not:

kernel/reboot.c:1092:30: error: unused variable 'hw_protection_attr' [-Werror,-Wunused-variable]
 1092 | static struct kobj_attribute hw_protection_attr = __ATTR_RW(hw_protection);
      |                              ^~~~~~~~~~~~~~~~~~

Add another #ifdef to match the first.

Fixes: 6f0ec17b2d82 ("reboot: add support for configuring emergency hardware protection action")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 kernel/reboot.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/reboot.c b/kernel/reboot.c
index 5299790a2832..2d6a06fe6c66 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -1071,6 +1071,7 @@ static int __init hw_protection_setup(char *str)
 }
 __setup("hw_protection=", hw_protection_setup);
 
+#ifdef CONFIG_SYSFS
 static ssize_t hw_protection_show(struct kobject *kobj,
 				  struct kobj_attribute *attr, char *buf)
 {
@@ -1090,6 +1091,7 @@ static ssize_t hw_protection_store(struct kobject *kobj,
 	return count;
 }
 static struct kobj_attribute hw_protection_attr = __ATTR_RW(hw_protection);
+#endif
 
 static int __init reboot_setup(char *str)
 {
-- 
2.39.5
Re: [PATCH] reboot: hide unused hw_protection_attr
Posted by Tzung-Bi Shih 9 months, 3 weeks ago
On Mon, Feb 24, 2025 at 03:16:09PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The reference to hw_protection_attr is inside of an #ifdef block,
> but the definition is not:
> 
> kernel/reboot.c:1092:30: error: unused variable 'hw_protection_attr' [-Werror,-Wunused-variable]
>  1092 | static struct kobj_attribute hw_protection_attr = __ATTR_RW(hw_protection);
>       |                              ^~~~~~~~~~~~~~~~~~
> 
> Add another #ifdef to match the first.
> 
> Fixes: 6f0ec17b2d82 ("reboot: add support for configuring emergency hardware protection action")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>