From 31f535632701ad2a1608b5ddb20e55d24ce95d60 Mon Sep 17 00:00:00 2001 From: Alexey Gladkov Date: Thu, 16 Dec 2021 18:20:43 +0300 Subject: ALT: Mark usage() functions as noreturn --- src/bootlogd.c | 1 + src/halt.c | 1 + src/init.c | 3 +++ src/killall5.c | 1 + src/last.c | 1 + src/mountpoint.c | 1 + src/shutdown.c | 1 + src/sulogin.c | 1 + src/utmpdump.c | 1 + 9 files changed, 11 insertions(+) diff --git a/src/bootlogd.c b/src/bootlogd.c index 78e4c81..130733c 100644 --- a/src/bootlogd.c +++ b/src/bootlogd.c @@ -453,6 +453,7 @@ void writelog(FILE *fp, unsigned char *ptr, int len, int print_escape_characters /* * Print usage message and exit. */ +__attribute__((noreturn)) void usage(void) { fprintf(stderr, "Usage: bootlogd [-v] [-r] [-d] [-e] [-s] [-c] [-p pidfile] [-l logfile]\n"); diff --git a/src/halt.c b/src/halt.c index 5f1d98f..09a1403 100644 --- a/src/halt.c +++ b/src/halt.c @@ -74,6 +74,7 @@ extern void write_wtmp(char *user, char *id, int pid, int type, char *line); /* * Send usage message. */ +__attribute__((noreturn)) void usage(void) { fprintf(stderr, "usage: %s [-n] [-w] [-d] [-f] [-h] [-i]%s\n", diff --git a/src/init.c b/src/init.c index 92c1877..5f5885b 100644 --- a/src/init.c +++ b/src/init.c @@ -2961,6 +2961,7 @@ void init_main(void) /* * Tell the user about the syntax we expect. */ +__attribute__((noreturn)) static void usage(char *s) { @@ -2979,6 +2980,8 @@ int telinit(char *progname, int argc, char **argv) int f, fd, l; char *env = NULL; + if (!argc) usage(progname); + memset(&request, 0, sizeof(request)); request.magic = INIT_MAGIC; diff --git a/src/killall5.c b/src/killall5.c index c0fea9c..a5e26ee 100644 --- a/src/killall5.c +++ b/src/killall5.c @@ -938,6 +938,7 @@ PIDQ_HEAD *pidof(char *prog) } /* Give usage message and exit. */ +__attribute__((noreturn)) void usage(void) { nsyslog(LOG_ERR, "only one argument, a signal number, allowed"); diff --git a/src/last.c b/src/last.c index 2591164..9eaf9ac 100644 --- a/src/last.c +++ b/src/last.c @@ -569,6 +569,7 @@ int list(struct utmp *p, time_t t, int what) /* * show usage */ +__attribute__((noreturn)) void usage(char *s) { fprintf(stderr, "Usage: %s [-num | -n num] [-f file] " diff --git a/src/mountpoint.c b/src/mountpoint.c index b24335e..a6eff1b 100644 --- a/src/mountpoint.c +++ b/src/mountpoint.c @@ -101,6 +101,7 @@ int do_proc_check(char *path) } +__attribute__((noreturn)) void usage(void) { fprintf(stderr, "Usage: mountpoint [-p] [-q] [-d] [-x] path\n"); exit(1); diff --git a/src/shutdown.c b/src/shutdown.c index 89b63a5..fccf2eb 100644 --- a/src/shutdown.c +++ b/src/shutdown.c @@ -135,6 +135,7 @@ void stopit(int sig) /* * Show usage message. */ +__attribute__((noreturn)) void usage(void) { fprintf(stderr, diff --git a/src/sulogin.c b/src/sulogin.c index 211eb62..2117880 100644 --- a/src/sulogin.c +++ b/src/sulogin.c @@ -837,6 +837,7 @@ void getmounts(void) } #endif +__attribute__((noreturn)) static void usage(void) { diff --git a/src/utmpdump.c b/src/utmpdump.c index f918041..3e56dfd 100644 --- a/src/utmpdump.c +++ b/src/utmpdump.c @@ -252,6 +252,7 @@ undump(FILE *fp, int forever, int oldfmt) free(linestart); } +__attribute__((noreturn)) void usage(int result) { -- 2.25.4