[PATCH 1/2] new valid_signal function (fwd)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andrew,

A while back I attempted to fix a little, not at all critical, gcc -W 
warning in fs/fcntl.c, during the discussion Matthew Wilcox noted that 
there were other locations that did the same thing and at least one 
location where there was an off-by-one error. He suggested that one good 
way of fixing the whole thing would be to introduce a new valid_signal() 
function. This can all be found in the '[PATCH] fs/fcntl.c : don't test 
unsigned value for less than zero' thread.
I created a patch to do that and also one that put it to good use and 
posted both patches to the list and a few people that I thought were 
relevant (same people that are CC: on this mail), but never heard anythng 
back and I didn't see the patches get merged either, so now I'm sending 
them to you in the hope that you'll merge them in -mm.

Below is the first patch that adds the new function.

-- Jesper Juhl


---------- Forwarded message ----------
Date: Mon, 18 Apr 2005 22:53:26 +0200 (CEST)
From: Jesper Juhl <[email protected]>
To: LKML <[email protected]>
Cc: Matthew Wilcox <[email protected]>, Herbert Xu <[email protected]>,
    Christoph Hellwig <[email protected]>
Subject: [PATCH 1/2] new valid_signal function

This patch adds a new function  valid_signal()  that tests if its argument 
is a valid signal number. 

The reasons for adding this new function are:
- some code currently testing _NSIG directly has off-by-one errors. Using 
this function instead avoids such errors.
- some code currently tests unsigned signal numbers for <0 which is 
pointless and generates warnings when building with gcc -W. Using this 
function instead avoids such warnings.

I considered various places to add this function but eventually settled on 
include/linux/signal.h as the most logical place for it. If there's some 
reason this is a bad choice then please let me know (hints as to a better 
location are then welcome of course).

A patch that converts most of the code that currently uses _NSIG directly 
to call this function instead is [PATCH 2/2] coming shortly..

Signed-off-by: Jesper Juhl <[email protected]>

 include/linux/signal.h |    6 ++++++
 1 files changed, 6 insertions(+)

--- linux-2.6.12-rc2-mm3-orig/include/linux/signal.h	2005-04-11 21:20:56.000000000 +0200
+++ linux-2.6.12-rc2-mm3/include/linux/signal.h	2005-04-18 20:09:50.000000000 +0200
@@ -220,6 +220,12 @@
 	INIT_LIST_HEAD(&sig->list);
 }
 
+/* Test if 'sig' is valid signal. Use this instead of testing _NSIG directly */
+static inline int valid_signal(unsigned long sig)
+{
+	return sig <= _NSIG ? 1 : 0;
+}
+
 extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p);
 extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
 extern long do_sigpending(void __user *, unsigned long);



-
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/
-
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/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux