All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] toshiba_acpi.c - fix busted keyboard backlight logic
@ 2014-08-20 18:56 Valdis Kletnieks
  2014-08-21 11:10 ` Ari Sundholm
  0 siblings, 1 reply; 2+ messages in thread
From: Valdis Kletnieks @ 2014-08-20 18:56 UTC (permalink / raw)
  To: Matthew Garrett, Ari Sundholm; +Cc: linux-kernel, platform-driver-x86

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 <valdis.kletnieks@vt.edu>

--
--- drivers/platform/x86/toshiba_acpi.c.orig	2014-08-20 14:45:52.159898938 -0400
+++ drivers/platform/x86/toshiba_acpi.c	2014-08-20 14:47:55.102444985 -0400
@@ -1258,7 +1258,7 @@ static ssize_t toshiba_kbd_bl_mode_store
 	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:


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] toshiba_acpi.c - fix busted keyboard backlight logic
  2014-08-20 18:56 [PATCH] toshiba_acpi.c - fix busted keyboard backlight logic Valdis Kletnieks
@ 2014-08-21 11:10 ` Ari Sundholm
  0 siblings, 0 replies; 2+ messages in thread
From: Ari Sundholm @ 2014-08-21 11:10 UTC (permalink / raw)
  To: Valdis Kletnieks; +Cc: Matthew Garrett, linux-kernel, platform-driver-x86


On Wed, 20 Aug 2014, Valdis Kletnieks wrote:

> 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 <valdis.kletnieks@vt.edu>
> 
> --
> --- drivers/platform/x86/toshiba_acpi.c.orig	2014-08-20 14:45:52.159898938 -0400
> +++ drivers/platform/x86/toshiba_acpi.c	2014-08-20 14:47:55.102444985 -0400
> @@ -1258,7 +1258,7 @@ static ssize_t toshiba_kbd_bl_mode_store
>  	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:

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
asundhol@cs.hut.fi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-08-21 11:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-20 18:56 [PATCH] toshiba_acpi.c - fix busted keyboard backlight logic Valdis Kletnieks
2014-08-21 11:10 ` Ari Sundholm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.