All of lore.kernel.org
 help / color / mirror / Atom feed
From: Knut Petersen <Knut_Petersen@t-online.de>
To: "'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.org>
Cc: Vojtech Pavlik <vojtech@suse.cz>, torvalds@osdl.org
Subject: [PATCH] setkeycode ioctl fix
Date: Fri, 24 Oct 2003 11:37:53 +0200	[thread overview]
Message-ID: <3F98F2F1.3000408@t-online.de> (raw)

Hi everybody,

This is a bugfix for setkeycode() in /drivers/char/keyboard.c.

If we change a keycode the corresponding bit should be cleared if  and 
only if
this keycode is not defined any longer. I believe that this also was 
intended
with the original code, but the implementation is faulty.

First off all the first three changed lines are obviously erroneus: 
oldkey == truekey
is false or true, you do not need to inclose this in a for(). I believe 
the author
intended INPUT_KEYCODE(dev,i) == oldkey. But fixing this alone is not 
enough.

If somebody wants to interchange the definition of two keys A and B, the 
normal way
is to use two setkeycode calls:

    setkeycode (scancode A, keycode B);
    setkeycode (scancode B, keycode A);

The old code does a clearbit(oldkey ..) call even in situations where 
two keys have
the same definition, and this situation arises commonly in the situation 
mentioned
above.

Both errors are fixed with this patch.

As this is a pure and obvious bugfix, please include it before releasing 
2.6.0-final.

The patch is against 2.6.0-test8-bk3, but the code of keyboard.c has not 
changed
for a long time.

cu,
 Knut Petersen


--- drivers/char/keyboard.orig  2003-10-17 23:43:03.000000000 +0200
+++ drivers/char/keyboard.c     2003-10-24 12:17:36.000000000 +0200
@@ -204,13 +204,13 @@
        oldkey = INPUT_KEYCODE(dev, scancode);
        INPUT_KEYCODE(dev, scancode) = keycode;

-       for (i = 0; i < dev->keycodemax; i++)
-               if(keycode == oldkey)
-                       break;
-       if (i == dev->keycodemax)
-               clear_bit(oldkey, dev->keybit);
+       clear_bit(oldkey, dev->keybit);
        set_bit(keycode, dev->keybit);
-
+
+       for (i = 0; i < dev->keycodemax; i++)
+               if(INPUT_KEYCODE(dev,i) == oldkey)
+                       set_bit(oldkey, dev->keybit);
+
        return 0;
 }




                 reply	other threads:[~2003-10-24  9:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=3F98F2F1.3000408@t-online.de \
    --to=knut_petersen@t-online.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=vojtech@suse.cz \
    /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 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.