Skip to contentSkip to conversation

Revert "platform/x86/toshiba-apci.c possible bad if test?"

PATCH In review Ari Sundholm 2 participants 3 messages Aug 20, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Revert "platform/x86/toshiba-apci.c possible bad if test?"

From: Ari Sundholm <[email protected]>

This reverts commit bdc3ae7221213963f438faeaa69c8b4a2195f491.

---
 drivers/platform/x86/toshiba_acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/toshiba_acpi.c +1 -1
index e4da61b..b062d3d 100644
@@ -1258,7 +1258,7 @@ static ssize_t toshiba_kbd_bl_mode_store(struct device *dev,
 	int mode = -1;
 	int time = -1;
 
-	if (sscanf(buf, "%i", &mode) != 1  || (mode != 2 || mode != 1))
+	if (sscanf(buf, "%i", &mode) != 1 && (mode != 2 || mode != 1))
 		return -EINVAL;
 
 	/* Set the Keyboard Backlight Mode where:
Signature · 1 line
1.9.1
#1 lore raw

drivers/platform/x86/toshiba_acpi.c static ssize_t toshiba_kbd_bl_mode_store(struct device *dev, · line 1262

Quoted 6 lines · Ari Sundholm

From: Ari Sundholm <[email protected]>

This reverts commit bdc3ae7221213963f438faeaa69c8b4a2195f491.

drivers/platform/x86/toshiba_acpi.c +1 -0
+	if (sscanf(buf, "%i", &mode) != 1 && (mode != 2 || mode != 1))
 		return -EINVAL;

I'm not convinced that's right either. If we come in and mode == 1, then the mode != 2 is true, and yoinks...

I think this wanted to be sscanf() != 1 || ! (mode == 2 || mode == 1)

I'll spin a patch against the reverted version if desired.

#2 lore raw
In reply to Ari Sundholm

drivers/platform/x86/toshiba_acpi.c static ssize_t toshiba_kbd_bl_mode_store(struct device *dev, · line 1262

Quoted 3 lines · Ari Sundholm
drivers/platform/x86/toshiba_acpi.c +1 -1
-	if (sscanf(buf, "%i", &mode) != 1  || (mode != 2 || mode != 1))
+	if (sscanf(buf, "%i", &mode) != 1 && (mode != 2 || mode != 1))
 		return -EINVAL;

Note that the condition still looks wrong even after the revert, as (mode != 2 || mode != 1) is always true. Anybody guess what the actual intent was?

Best regards,
Ari Sundholm
[email protected]