Hi,
Sorry about the possibly irrelevant CC list, but I couldn't find a
maintainer for drivers/char/keyboard.c listed anywhere, so I ended up
sending to lkml and CC'ing a few people who has worked on the file, and
akpm as a fallback person due to his 2.6 maintainer role.
Here's a patch that removes a few pointless comparisons; "scancode" is
unsigned so it can never be <0 which makes the test pointless.
Also, there are a few instances where signed and unsigned variables are
comared, and as far as I can tell they really should just all be unsigned.
Comments welcome (I must confess that I've only compile tested this so
far).
Signed-off-by: Jesper Juhl <[email protected]>
diff -up linux-2.6.10-rc2-bk6-orig/drivers/char/keyboard.c linux-2.6.10-rc2-bk6/drivers/char/keyboard.c
--- linux-2.6.10-rc2-bk6-orig/drivers/char/keyboard.c 2004-10-18 23:55:36.000000000 +0200
+++ linux-2.6.10-rc2-bk6/drivers/char/keyboard.c 2004-11-22 00:05:45.000000000 +0100
@@ -174,7 +174,7 @@ int getkeycode(unsigned int scancode)
if (!dev)
return -ENODEV;
- if (scancode < 0 || scancode >= dev->keycodemax)
+ if (scancode >= dev->keycodemax)
return -EINVAL;
return INPUT_KEYCODE(dev, scancode);
@@ -184,7 +184,7 @@ int setkeycode(unsigned int scancode, un
{
struct list_head * node;
struct input_dev *dev = NULL;
- int i, oldkey;
+ unsigned int i, oldkey;
list_for_each(node,&kbd_handler.h_list) {
struct input_handle *handle = to_handle_h(node);
@@ -197,7 +197,7 @@ int setkeycode(unsigned int scancode, un
if (!dev)
return -ENODEV;
- if (scancode < 0 || scancode >= dev->keycodemax)
+ if (scancode >= dev->keycodemax)
return -EINVAL;
oldkey = SET_INPUT_KEYCODE(dev, scancode, keycode);
@@ -354,7 +354,7 @@ void to_utf8(struct vc_data *vc, ushort
*/
void compute_shiftstate(void)
{
- int i, j, k, sym, val;
+ unsigned int i, j, k, sym, val;
shift_state = 0;
memset(shift_down, 0, sizeof(shift_down));
@@ -395,7 +395,7 @@ void compute_shiftstate(void)
unsigned char handle_diacr(struct vc_data *vc, unsigned char ch)
{
int d = diacr;
- int i;
+ unsigned int i;
diacr = 0;
On Mon, 22 Nov 2004, Jesper Juhl wrote:
>
> Hi,
>
> Sorry about the possibly irrelevant CC list, but I couldn't find a
> maintainer for drivers/char/keyboard.c listed anywhere, so I ended up
> sending to lkml and CC'ing a few people who has worked on the file, and
> akpm as a fallback person due to his 2.6 maintainer role.
>
> Here's a patch that removes a few pointless comparisons; "scancode" is
> unsigned so it can never be <0 which makes the test pointless.
> Also, there are a few instances where signed and unsigned variables are
> comared, and as far as I can tell they really should just all be unsigned.
>
> Comments welcome (I must confess that I've only compile tested this so
> far).
>
Just boot tested it as well and things seem to be fine on my box.
> Signed-off-by: Jesper Juhl <[email protected]>
>
> diff -up linux-2.6.10-rc2-bk6-orig/drivers/char/keyboard.c linux-2.6.10-rc2-bk6/drivers/char/keyboard.c
> --- linux-2.6.10-rc2-bk6-orig/drivers/char/keyboard.c 2004-10-18 23:55:36.000000000 +0200
> +++ linux-2.6.10-rc2-bk6/drivers/char/keyboard.c 2004-11-22 00:05:45.000000000 +0100
> @@ -174,7 +174,7 @@ int getkeycode(unsigned int scancode)
> if (!dev)
> return -ENODEV;
>
> - if (scancode < 0 || scancode >= dev->keycodemax)
> + if (scancode >= dev->keycodemax)
> return -EINVAL;
>
> return INPUT_KEYCODE(dev, scancode);
> @@ -184,7 +184,7 @@ int setkeycode(unsigned int scancode, un
> {
> struct list_head * node;
> struct input_dev *dev = NULL;
> - int i, oldkey;
> + unsigned int i, oldkey;
>
> list_for_each(node,&kbd_handler.h_list) {
> struct input_handle *handle = to_handle_h(node);
> @@ -197,7 +197,7 @@ int setkeycode(unsigned int scancode, un
> if (!dev)
> return -ENODEV;
>
> - if (scancode < 0 || scancode >= dev->keycodemax)
> + if (scancode >= dev->keycodemax)
> return -EINVAL;
>
> oldkey = SET_INPUT_KEYCODE(dev, scancode, keycode);
> @@ -354,7 +354,7 @@ void to_utf8(struct vc_data *vc, ushort
> */
> void compute_shiftstate(void)
> {
> - int i, j, k, sym, val;
> + unsigned int i, j, k, sym, val;
>
> shift_state = 0;
> memset(shift_down, 0, sizeof(shift_down));
> @@ -395,7 +395,7 @@ void compute_shiftstate(void)
> unsigned char handle_diacr(struct vc_data *vc, unsigned char ch)
> {
> int d = diacr;
> - int i;
> + unsigned int i;
>
> diacr = 0;
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
On Mon, Nov 22, 2004 at 12:21:55AM +0100, Jesper Juhl wrote:
>
> Hi,
>
> Sorry about the possibly irrelevant CC list, but I couldn't find a
> maintainer for drivers/char/keyboard.c listed anywhere, so I ended up
> sending to lkml and CC'ing a few people who has worked on the file, and
> akpm as a fallback person due to his 2.6 maintainer role.
>
> Here's a patch that removes a few pointless comparisons; "scancode" is
> unsigned so it can never be <0 which makes the test pointless.
> Also, there are a few instances where signed and unsigned variables are
> comared, and as far as I can tell they really should just all be unsigned.
>
> Comments welcome (I must confess that I've only compile tested this so
> far).
>
> Signed-off-by: Jesper Juhl <[email protected]>
Looks sane: Applied.
--
Vojtech Pavlik
SuSE Labs, SuSE CR