Skip to contentSkip to conversation

HID: asus: fix build warning wiht CONFIG_ASUS_WMI disabled

PATCH Applied Arnd Bergmann 3 participants 3 messages Nov 2, 2018 – Nov 6, 2018 HID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: asus: fix build warning wiht CONFIG_ASUS_WMI disabled

asus_wmi_evaluate_method() is an empty dummy function when CONFIG_ASUS_WMI is disabled, or not reachable from a built-in device driver. This leads to a theoretical evaluation of an uninitialized variable that the compiler complains about, failing to check that the hardcoded return value makes this an unreachable code path:

In file included from include/linux/printk.h:336,

                 from include/linux/kernel.h:14,
                 from include/linux/list.h:9,
                 from include/linux/dmi.h:5,
                 from drivers/hid/hid-asus.c:29:

drivers/hid/hid-asus.c: In function 'asus_input_configured':
include/linux/dynamic_debug.h:135:3: error: 'value' may be used uninitialized in this function [-Werror=maybe-uninitialized]
__dynamic_dev_dbg(&descriptor, dev, fmt, \
^~~~~~~~~~~~~~~~~
drivers/hid/hid-asus.c:359:6: note: 'value' was declared here

  u32 value;
      ^~~~~

With an extra IS_ENABLED() check, the warning goes away.

Fixes 3b692c55e58d ("HID: asus: only support backlight when it's not driven by WMI")
---
 drivers/hid/hid-asus.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/hid/hid-asus.c +3 -0
index dc6d6477e961..a1fa2fc8c9b5 100644
@@ -359,6 +359,9 @@ static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev)
 	u32 value;
 	int ret;
 
+	if (!IS_ENABLED(CONFIG_ASUS_WMI))
+		return false;
+
 	ret = asus_wmi_evaluate_method(ASUS_WMI_METHODID_DSTS2,
 				       ASUS_WMI_DEVID_KBD_BACKLIGHT, 0, &value);
 	hid_dbg(hdev, "WMI backlight check: rc %d value %x", ret, value);
Signature · 1 line
2.18.0
Acked-by on v1 1/1
#1 lore raw
Quoted 19 lines · Arnd Bergmann

asus_wmi_evaluate_method() is an empty dummy function when CONFIG_ASUS_WMI is disabled, or not reachable from a built-in device driver. This leads to a theoretical evaluation of an uninitialized variable that the compiler complains about, failing to check that the hardcoded return value makes this an unreachable code path:

In file included from include/linux/printk.h:336,

                 from include/linux/kernel.h:14,
                 from include/linux/list.h:9,
                 from include/linux/dmi.h:5,
                 from drivers/hid/hid-asus.c:29:
drivers/hid/hid-asus.c: In function 'asus_input_configured':
include/linux/dynamic_debug.h:135:3: error: 'value' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   __dynamic_dev_dbg(&descriptor, dev, fmt, \
   ^~~~~~~~~~~~~~~~~
drivers/hid/hid-asus.c:359:6: note: 'value' was declared here
  u32 value;
      ^~~~~
Quoted 4 lines

With an extra IS_ENABLED() check, the warning goes away.

Fixes 3b692c55e58d ("HID: asus: only support backlight when it's not driven by WMI")

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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
maintainer Applied
#2 lore raw
In reply to Arnd Bergmann
Quoted 19 lines · Arnd Bergmann

asus_wmi_evaluate_method() is an empty dummy function when CONFIG_ASUS_WMI is disabled, or not reachable from a built-in device driver. This leads to a theoretical evaluation of an uninitialized variable that the compiler complains about, failing to check that the hardcoded return value makes this an unreachable code path:

In file included from include/linux/printk.h:336,

                 from include/linux/kernel.h:14,
                 from include/linux/list.h:9,
                 from include/linux/dmi.h:5,
                 from drivers/hid/hid-asus.c:29:
drivers/hid/hid-asus.c: In function 'asus_input_configured':
include/linux/dynamic_debug.h:135:3: error: 'value' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   __dynamic_dev_dbg(&descriptor, dev, fmt, \
   ^~~~~~~~~~~~~~~~~
drivers/hid/hid-asus.c:359:6: note: 'value' was declared here
  u32 value;
      ^~~~~
Quoted 4 lines

With an extra IS_ENABLED() check, the warning goes away.

Fixes 3b692c55e58d ("HID: asus: only support backlight when it's not driven by WMI")

Applied to for-4.20/upstream-fixes. Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs