toshiba_acpi.c - fix busted keyboard backlight logic
PATCH 1/1 toshiba_acpi.c - fix busted keyboard backlight logic
Both the original and the first attempted patch managed to get the logic wrong. So we fix it so we only continue if sscanf returns exactly one value, and it has to be either 1 or 2. Apparently, programmers are getting out and hacking code without remembering de Morgan's Laws...
Patch is against the file that results from Ari's revert of the previous patch.
--
platform/x86/toshiba_acpi.c renamed from platform/x86/toshiba_acpi.c.orig +1 -1
@@ -1258,7 +1258,7 @@ static ssize_t toshiba_kbd_bl_mode_storeint 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:
Quoted 14 lines · Valdis Kletnieks
Both the original and the first attempted patch managed to get the logic wrong. So we fix it so we only continue if sscanf returns exactly one value, and it has to be either 1 or 2. Apparently, programmers are getting out and hacking code without remembering de Morgan's Laws...
Patch is against the file that results from Ari's revert of the previous patch.
Signed-off-by Valdis Kletnieks <[email protected]>--
platform/x86/toshiba_acpi.c static ssize_t toshiba_kbd_bl_mode_store · line 1264
Quoted 8 lines
platform/x86/toshiba_acpi.c renamed from platform/x86/toshiba_acpi.c.orig +1
-1@@ -1258,7 +1258,7 @@ static ssize_t toshiba_kbd_bl_mode_storeint 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:
Looks good to me.
It seems Matthew already reverted the bad commit in mainline commit 8039aabb6c9f802bca04cc77ca210060a5b53916, but didn't fix the original logic yet.
Matthew, could you apply Valdis' patch so this gets fixed once and for all?
Best regards,
Ari Sundholm
[email protected]