lkml.org 
[lkml]   [2003]   [Feb]   [8]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
DateSat, 8 Feb 2003 20:18:38 +0300
FromOleg Drokin <>
Subject2.4.21-pre4 comparison bugs
Hello!

   Thanks to whoever mentioned "gcc -W", it's *sweet*  ;)
   Looking at it's output I found few cases where error checking
   does not work.
   Though nothing too serious it seems (except maybe IDE setup-pci stuff,
   I just do not know about that, and may be in that case
   we actually want to change all the functions to return signed
   value, though my fix is certainly less intrusive ;) )
   Most of the patched stuff in here assigns signed value to unsigned
   variable and then checks if it is less than zero which does not work
   for obvious reasons ;)
   I decided taht in most cases simple casting to int would be best
   and least intrusive resolution of a problem.
   The only exception is fs/isofs/inode.c, there we have unsigned int
   (so it is unsigned not depending on any arch) and so '> some num'
   stuff will also check for former negative numbers anyway. So
   I removed one extra comparison in that case.
   See the patch below.

Bye,
    Oleg

===== drivers/ide/setup-pci.c 1.2 vs edited =====
--- 1.2/drivers/ide/setup-pci.c	Thu Dec 12 04:09:23 2002
+++ edited/drivers/ide/setup-pci.c	Sat Feb  8 19:06:13 2003
@@ -582,7 +582,7 @@
 
 	index.all = 0xf0f0;
 
-	if((autodma = ide_setup_pci_controller(dev, d, noisy, &tried_config)) < 0)
+	if((int)(autodma = ide_setup_pci_controller(dev, d, noisy, &tried_config)) < 0)
 		return index;
 
 	/*
@@ -613,7 +613,7 @@
 	} else {
 		if (d->init_chipset)
 		{
-			if(d->init_chipset(dev, d->name) < 0)
+			if((int)d->init_chipset(dev, d->name) < 0)
 				return index;
 		}
 		if (noisy)
===== drivers/net/tun.c 1.8 vs edited =====
--- 1.8/drivers/net/tun.c	Mon Apr 22 21:38:08 2002
+++ edited/drivers/net/tun.c	Sat Feb  8 19:07:28 2003
@@ -188,7 +188,7 @@
 	size_t len = count;
 
 	if (!(tun->flags & TUN_NO_PI)) {
-		if ((len -= sizeof(pi)) < 0)
+		if ((int)(len -= sizeof(pi)) < 0)
 			return -EINVAL;
 
 		memcpy_fromiovec((void *)&pi, iv, sizeof(pi));
===== fs/isofs/inode.c 1.9 vs edited =====
--- 1.9/fs/isofs/inode.c	Mon Jul  1 02:25:33 2002
+++ edited/fs/isofs/inode.c	Sat Feb  8 19:15:41 2003
@@ -343,13 +343,13 @@
 		if (!strcmp(this_char,"session") && value) {
 			char * vpnt = value;
 			unsigned int ivalue = simple_strtoul(vpnt, &vpnt, 0);
-			if(ivalue < 0 || ivalue >99) return 0;
+			if(ivalue > 99) return 0;
 			popt->session=ivalue+1;
 		}
 		if (!strcmp(this_char,"sbsector") && value) {
 			char * vpnt = value;
 			unsigned int ivalue = simple_strtoul(vpnt, &vpnt, 0);
-			if(ivalue < 0 || ivalue >660*512) return 0;
+			if(ivalue > 660*512) return 0;
 			popt->sbsector=ivalue;
 		}
 		else if (!strcmp(this_char,"check") && value) {
===== net/sunrpc/pmap_clnt.c 1.3 vs edited =====
--- 1.3/net/sunrpc/pmap_clnt.c	Wed Apr 24 12:58:19 2002
+++ edited/net/sunrpc/pmap_clnt.c	Sat Feb  8 19:09:20 2003
@@ -149,7 +149,7 @@
 	struct sockaddr_in	sin;
 	struct rpc_portmap	map;
 	struct rpc_clnt		*pmap_clnt;
-	unsigned int		error = 0;
+	int			error = 0;
 
 	dprintk("RPC: registering (%d, %d, %d, %d) with portmapper.\n",
 			prog, vers, prot, port);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 12:33    [from the cache]
©2003-2008