[PATCH] fs/fcntl.c - remove impossible <0 check in do_fcntl - argis unsigned.

From: Jesper Juhl
Date: Wed Jan 07 2004 - 20:48:53 EST



The 'arg' argument to the function do_fcntl in fs/fcntl.c is of type
'unsigned long', thus it can never be less than zero (all callers of
do_fcntl take unsigned arguments as well and pass on unsigned values),
thus the check for 'arg < 0' in the F_SETSIG case of the switch in
do_fcntl can never be true and thus does not need to be there in the first
place. Patch below (against 2.6.1-rc1-mm2) removes this dead code.


--- linux-2.6.1-rc1-mm2-orig/fs/fcntl.c 2004-01-06 01:33:08.000000000 +0100
+++ linux-2.6.1-rc1-mm2/fs/fcntl.c 2004-01-08 02:44:45.000000000 +0100
@@ -331,9 +331,8 @@ static long do_fcntl(unsigned int fd, un
break;
case F_SETSIG:
/* arg == 0 restores default behaviour. */
- if (arg < 0 || arg > _NSIG) {
+ if (arg > _NSIG)
break;
- }
err = 0;
filp->f_owner.signum = arg;
break;


Patch is only compile tested, but as far as I can see it should be
correct.


Kind regards,

Jesper Juhl



PS. CC'ing Matthew Wilcox as he's listed as 'file locking' maintainer in
MAINTAINERS, and Linus Torvalds as he's listed as original author in the
file - sorry for the inconvenience, if any.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/