提交 e5bdd883 编写于 作者: J Jesper Juhl 提交者: Linus Torvalds

[PATCH] 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).
Signed-off-by: NJesper Juhl <juhl-lkml@dif.dk>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 1c72d46d
...@@ -220,6 +220,12 @@ static inline void init_sigpending(struct sigpending *sig) ...@@ -220,6 +220,12 @@ static inline void init_sigpending(struct sigpending *sig)
INIT_LIST_HEAD(&sig->list); 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 sig, struct siginfo *info, struct task_struct *p);
extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *); extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
extern long do_sigpending(void __user *, unsigned long); extern long do_sigpending(void __user *, unsigned long);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册