public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs/fcntl.c - remove impossible <0 check in do_fcntl - arg is unsigned.
@ 2004-01-08  1:44 Jesper Juhl
  2004-01-08  2:47 ` Linus Torvalds
  0 siblings, 1 reply; 6+ messages in thread
From: Jesper Juhl @ 2004-01-08  1:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Matthew Wilcox, Linus Torvalds


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.


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

end of thread, other threads:[~2004-01-08 12:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-08  1:44 [PATCH] fs/fcntl.c - remove impossible <0 check in do_fcntl - arg is unsigned Jesper Juhl
2004-01-08  2:47 ` Linus Torvalds
2004-01-08 10:27   ` Jesper Juhl
2004-01-08 11:07     ` Paul Jackson
2004-01-08 11:10     ` Hans Reiser
2004-01-08 12:13   ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox