From b657e7e08ae47335024257dd298edb55308a1c16 Mon Sep 17 00:00:00 2001 From: albert <> Date: Mon, 9 Dec 2002 07:53:09 +0000 Subject: [PATCH] NORETURN --- pgrep.c | 4 ++-- pmap.c | 1 + proc/procps.h | 3 +++ skill.c | 3 +++ top.c | 3 +++ vmstat.c | 3 ++- watch.c | 12 ++++++------ 7 files changed, 20 insertions(+), 9 deletions(-) diff --git a/pgrep.c b/pgrep.c index a11e2bf4..4770e7c3 100644 --- a/pgrep.c +++ b/pgrep.c @@ -57,8 +57,8 @@ static union el *opt_ruid = NULL; static char *opt_pattern = NULL; -static int -usage (int opt) +static int usage (int opt) NORETURN; +static int usage (int opt) { if (i_am_pkill) fprintf (stderr, "Usage: pkill [-SIGNAL] [-fvx] "); diff --git a/pmap.c b/pmap.c index 9f91ccb2..80eefa04 100644 --- a/pmap.c +++ b/pmap.c @@ -19,6 +19,7 @@ #include #include "proc/version.h" // FIXME: we need to link the lib for this :-( +static void usage(void) NORETURN; static void usage(void){ fprintf(stderr, "Usage: pmap [-r] [-x] pid...\n" diff --git a/proc/procps.h b/proc/procps.h index 44aab672..8fbaa503 100644 --- a/proc/procps.h +++ b/proc/procps.h @@ -18,6 +18,9 @@ #endif #endif +// since gcc-2.5 +#define NORETURN __attribute__((__noreturn__)) + #if __GNUC__ > 2 || __GNUC_MINOR__ >= 96 // won't alias anything, and aligned enough for anything #define MALLOC __attribute__ ((__malloc__)) diff --git a/skill.c b/skill.c index b58200bb..e4dce0d7 100644 --- a/skill.c +++ b/skill.c @@ -231,6 +231,7 @@ static void iterate(void){ } /***** kill help */ +static void kill_usage(void) NORETURN; static void kill_usage(void){ fprintf(stderr, "Usage:\n" @@ -245,6 +246,7 @@ static void kill_usage(void){ } /***** kill */ +static void kill_main(int argc, const char *restrict const *restrict argv) NORETURN; static void kill_main(int argc, const char *restrict const *restrict argv){ const char *sigptr; int signo = SIGTERM; @@ -317,6 +319,7 @@ no_more_args: } /***** skill/snice help */ +static void skillsnice_usage(void) NORETURN; static void skillsnice_usage(void){ if(program==PROG_SKILL){ fprintf(stderr, diff --git a/top.c b/top.c index 295db89a..97235a7b 100644 --- a/top.c +++ b/top.c @@ -324,6 +324,7 @@ static const char *tg2 (int x, int y) /* * The usual program end -- * called only by functions in this section. */ +static void bye_bye (int eno, const char *str) NORETURN; static void bye_bye (int eno, const char *str) { if (!Batch) @@ -408,6 +409,7 @@ static void bye_bye (int eno, const char *str) * Normal end of execution. * catches: * SIGALRM, SIGHUP, SIGINT, SIGPIPE, SIGQUIT and SIGTERM */ +static void end_pgm (int dont_care_sig) NORETURN; static void end_pgm (int dont_care_sig) { (void)dont_care_sig; @@ -417,6 +419,7 @@ static void end_pgm (int dont_care_sig) /* * Standard error handler to normalize the look of all err o/p */ +static void std_err (const char *str) NORETURN; static void std_err (const char *str) { static char buf[SMLBUFSIZ]; diff --git a/vmstat.c b/vmstat.c index f429cd94..f9f6c5c9 100644 --- a/vmstat.c +++ b/vmstat.c @@ -36,7 +36,7 @@ static unsigned int moreheaders=TRUE; ///////////////////////////////////////////////////////////////////////// - +static void usage(void) NORETURN; static void usage(void) { fprintf(stderr,"usage: vmstat [-V] [-n] [delay [count]]\n"); fprintf(stderr," -V prints version.\n"); @@ -47,6 +47,7 @@ static void usage(void) { exit(EXIT_FAILURE); } +static void crash(const char *filename) NORETURN; static void crash(const char *filename) { perror(filename); exit(EXIT_FAILURE); diff --git a/watch.c b/watch.c index 41445ade..6cad945f 100644 --- a/watch.c +++ b/watch.c @@ -42,15 +42,15 @@ static int first_screen = 1; #define min(x,y) ((x) > (y) ? (y) : (x)) -static void -do_usage(void) +static void do_usage(void) NORETURN; +static void do_usage(void) { fprintf(stderr, usage, progname); exit(1); } -static void -do_exit(int status) +static void do_exit(int status) NORETURN; +static void do_exit(int status) { if (curses_started) endwin(); @@ -58,8 +58,8 @@ do_exit(int status) } /* signal handler */ -static void -die(int notused) +static void die(int notused) NORETURN; +static void die(int notused) { (void) notused; do_exit(0);