mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Valdis Kletnieks <Valdis.Kletnieks@vt.edu>
To: Matthew Garrett <matthew.garrett@nebula.com>,
	Ari Sundholm <asundhol@cs.hut.fi>
Cc: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org
Subject: [PATCH] toshiba_acpi.c - fix busted keyboard backlight logic
Date: Wed, 20 Aug 2014 14:56:43 -0400	[thread overview]
Message-ID: <17794.1408561003@turing-police.cc.vt.edu> (raw)

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:


             reply	other threads:[~2014-08-20 18:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-20 18:56 Valdis Kletnieks [this message]
2014-08-21 11:10 ` Ari Sundholm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17794.1408561003@turing-police.cc.vt.edu \
    --to=valdis.kletnieks@vt.edu \
    --cc=asundhol@cs.hut.fi \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew.garrett@nebula.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®