Date: Tue, 6 Sep 2016 22:03:53 +0000 (UTC) From: Brooks Davis <brooks@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r305506 - head/sys/kern Message-ID: <201609062203.u86M3rfu049788@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: brooks Date: Tue Sep 6 22:03:53 2016 New Revision: 305506 URL: https://svnweb.freebsd.org/changeset/base/305506 Log: Modernize the initalization of sigproptbl. Use C99 designators to set the value of each slot and the nitems macro to check for valid entries. In the process, switch to indexing by signal number rather than signal-1 for improved clarity. Obtained from: CheriBSD (a6053c5abf03a5f53bbfcdd3a26429383f67e09f) Sponsored by: DARPA, AFRL Reviewed by: kib Modified: head/sys/kern/kern_sig.c Modified: head/sys/kern/kern_sig.c ============================================================================== --- head/sys/kern/kern_sig.c Tue Sep 6 21:36:20 2016 (r305505) +++ head/sys/kern/kern_sig.c Tue Sep 6 22:03:53 2016 (r305506) @@ -198,37 +198,37 @@ SYSCTL_INT(_kern, OID_AUTO, coredump_dev #define SIGPROP_CANTMASK 0x40 /* non-maskable, catchable */ static int sigproptbl[NSIG] = { - SIGPROP_KILL, /* SIGHUP */ - SIGPROP_KILL, /* SIGINT */ - SIGPROP_KILL | SIGPROP_CORE, /* SIGQUIT */ - SIGPROP_KILL | SIGPROP_CORE, /* SIGILL */ - SIGPROP_KILL | SIGPROP_CORE, /* SIGTRAP */ - SIGPROP_KILL | SIGPROP_CORE, /* SIGABRT */ - SIGPROP_KILL | SIGPROP_CORE, /* SIGEMT */ - SIGPROP_KILL | SIGPROP_CORE, /* SIGFPE */ - SIGPROP_KILL, /* SIGKILL */ - SIGPROP_KILL | SIGPROP_CORE, /* SIGBUS */ - SIGPROP_KILL | SIGPROP_CORE, /* SIGSEGV */ - SIGPROP_KILL | SIGPROP_CORE, /* SIGSYS */ - SIGPROP_KILL, /* SIGPIPE */ - SIGPROP_KILL, /* SIGALRM */ - SIGPROP_KILL, /* SIGTERM */ - SIGPROP_IGNORE, /* SIGURG */ - SIGPROP_STOP, /* SIGSTOP */ - SIGPROP_STOP | SIGPROP_TTYSTOP, /* SIGTSTP */ - SIGPROP_IGNORE | SIGPROP_CONT, /* SIGCONT */ - SIGPROP_IGNORE, /* SIGCHLD */ - SIGPROP_STOP | SIGPROP_TTYSTOP, /* SIGTTIN */ - SIGPROP_STOP | SIGPROP_TTYSTOP, /* SIGTTOU */ - SIGPROP_IGNORE, /* SIGIO */ - SIGPROP_KILL, /* SIGXCPU */ - SIGPROP_KILL, /* SIGXFSZ */ - SIGPROP_KILL, /* SIGVTALRM */ - SIGPROP_KILL, /* SIGPROF */ - SIGPROP_IGNORE, /* SIGWINCH */ - SIGPROP_IGNORE, /* SIGINFO */ - SIGPROP_KILL, /* SIGUSR1 */ - SIGPROP_KILL, /* SIGUSR2 */ + [SIGHUP] = SIGPROP_KILL, + [SIGINT] = SIGPROP_KILL, + [SIGQUIT] = SIGPROP_KILL | SIGPROP_CORE, + [SIGILL] = SIGPROP_KILL | SIGPROP_CORE, + [SIGTRAP] = SIGPROP_KILL | SIGPROP_CORE, + [SIGABRT] = SIGPROP_KILL | SIGPROP_CORE, + [SIGEMT] = SIGPROP_KILL | SIGPROP_CORE, + [SIGFPE] = SIGPROP_KILL | SIGPROP_CORE, + [SIGKILL] = SIGPROP_KILL, + [SIGBUS] = SIGPROP_KILL | SIGPROP_CORE, + [SIGSEGV] = SIGPROP_KILL | SIGPROP_CORE, + [SIGSYS] = SIGPROP_KILL | SIGPROP_CORE, + [SIGPIPE] = SIGPROP_KILL, + [SIGALRM] = SIGPROP_KILL, + [SIGTERM] = SIGPROP_KILL, + [SIGURG] = SIGPROP_IGNORE, + [SIGSTOP] = SIGPROP_STOP, + [SIGTSTP] = SIGPROP_STOP | SIGPROP_TTYSTOP, + [SIGCONT] = SIGPROP_IGNORE | SIGPROP_CONT, + [SIGCHLD] = SIGPROP_IGNORE, + [SIGTTIN] = SIGPROP_STOP | SIGPROP_TTYSTOP, + [SIGTTOU] = SIGPROP_STOP | SIGPROP_TTYSTOP, + [SIGIO] = SIGPROP_IGNORE, + [SIGXCPU] = SIGPROP_KILL, + [SIGXFSZ] = SIGPROP_KILL, + [SIGVTALRM] = SIGPROP_KILL, + [SIGPROF] = SIGPROP_KILL, + [SIGWINCH] = SIGPROP_IGNORE, + [SIGINFO] = SIGPROP_IGNORE, + [SIGUSR1] = SIGPROP_KILL, + [SIGUSR2] = SIGPROP_KILL, }; static void reschedule_signals(struct proc *p, sigset_t block, int flags); @@ -611,8 +611,8 @@ static __inline int sigprop(int sig) { - if (sig > 0 && sig < NSIG) - return (sigproptbl[_SIG_IDX(sig)]); + if (sig > 0 && sig < nitems(sigproptbl)) + return (sigproptbl[sig]); return (0); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201609062203.u86M3rfu049788>