All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH TRIVIAL] 2.4.28-rc1 RFC remove three compiler warnings
@ 2004-10-26 23:45 Grant
  0 siblings, 0 replies; 2+ messages in thread
From: Grant @ 2004-10-26 23:45 UTC (permalink / raw)
  To: linux-kernel

Hi there,

Three compiler warnings are related and due to comparison of 
an unsigned char against 256, resulting in these warnings:

vt.c: In function `do_kdsk_ioctl':
vt.c:166: warning: comparison is always false due to limited range of data type
vt.c: In function `do_kdgkb_ioctl':
vt.c:283: warning: comparison is always false due to limited range of data type
keyboard.c: In function `do_fn':
keyboard.c:640: warning: comparison is always true due to limited range of data type

Related constants:
include/linux/keyboard.h:#define MAX_NR_KEYMAPS 256
include/linux/keyboard.h:#define MAX_NR_FUNC    256
drivers/char/defkeymap.c:char *func_table[MAX_NR_FUNC] = {

Compiler: gcc (GCC) 3.3.4, system is slackware-10.0 on a pII box. 

Is removing useless comparisions the correct solution?

Dot config, dmesg, patch files at:
  http://users.netconnect.com.au/~gcoady/2.4.28-rc1/

Cheers,
Grant Coady.
--

diff -urN -X dontdiff linux-2.4.28-rc1-orig/drivers/char/keyboard.c linux-2.4.28-rc1/drivers/char/keyboard.c
--- linux-2.4.28-rc1-orig/drivers/char/keyboard.c	2003-11-29 05:26:20.000000000 +1100
+++ linux-2.4.28-rc1/drivers/char/keyboard.c	2004-10-26 19:02:24.000000000 +1000
@@ -637,11 +637,8 @@
 {
 	if (up_flag)
 		return;
-	if (value < SIZE(func_table)) {
-		if (func_table[value])
-			puts_queue(func_table[value]);
-	} else
-		printk(KERN_ERR "do_fn called with value=%d\n", value);
+	if (func_table[value])
+		puts_queue(func_table[value]);
 }
 
 static void do_pad(unsigned char value, char up_flag)
diff -urN -X dontdiff linux-2.4.28-rc1-orig/drivers/char/vt.c linux-2.4.28-rc1/drivers/char/vt.c
--- linux-2.4.28-rc1-orig/drivers/char/vt.c	2002-11-29 10:53:12.000000000 +1100
+++ linux-2.4.28-rc1/drivers/char/vt.c	2004-10-26 19:00:29.000000000 +1000
@@ -163,7 +163,7 @@
 
 	if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
 		return -EFAULT;
-	if (i >= NR_KEYS || s >= MAX_NR_KEYMAPS)
+	if (i >= NR_KEYS)
 		return -EINVAL;	
 
 	switch (cmd) {
@@ -280,8 +280,6 @@
 	if (copy_from_user(&tmp, user_kdgkb, sizeof(struct kbsentry)))
 		return -EFAULT;
 	tmp.kb_string[sizeof(tmp.kb_string)-1] = '\0';
-	if (tmp.kb_func >= MAX_NR_FUNC)
-		return -EINVAL;
 	i = tmp.kb_func;
 
 	switch (cmd) {

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

* Re: [PATCH TRIVIAL] 2.4.28-rc1 RFC remove three compiler warnings
@ 2004-10-27  9:14 sezeroz
  0 siblings, 0 replies; 2+ messages in thread
From: sezeroz @ 2004-10-27  9:14 UTC (permalink / raw)
  To: linux-kernel

Grant:
This one's not that trivial, I think. Please see:
http://marc.theaimsgroup.com/?t=108462688000001&r=1&w=2
http://marc.theaimsgroup.com/?l=linux-kernel&m=108479097911074&w=2

Regards,
O. Sezer

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

end of thread, other threads:[~2004-10-27  9:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-27  9:14 [PATCH TRIVIAL] 2.4.28-rc1 RFC remove three compiler warnings sezeroz
  -- strict thread matches above, loose matches on Subject: below --
2004-10-26 23:45 Grant

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.