git: a2cc93ec7fa1 - main - Mark usage function as __dead2 in programs where it does not return

From: Warner Losh <imp_at_FreeBSD.org>
Date: Fri, 07 Jul 2023 16:51:17 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=a2cc93ec7fa15eed4d3a39998adff641c15dca4f

commit a2cc93ec7fa15eed4d3a39998adff641c15dca4f
Author:     Alfonso Gregory <gfunni234@gmail.com>
AuthorDate: 2023-07-07 16:39:23 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-07-07 16:45:18 +0000

    Mark usage function as __dead2 in programs where it does not return
    
    In most cases, usage does not return, so mark them as __dead2. For the
    cases where they do return, they have not been marked __dead2.
    
    Reviewed by: imp
    Pull Request: https://github.com/freebsd/freebsd-src/pull/735
---
 usr.sbin/pnfsdscopymr/pnfsdscopymr.c | 2 +-
 usr.sbin/pnfsdsfile/pnfsdsfile.c     | 2 +-
 usr.sbin/pnfsdskill/pnfsdskill.c     | 2 +-
 usr.sbin/quotaon/quotaon.c           | 2 +-
 usr.sbin/repquota/repquota.c         | 2 +-
 usr.sbin/rip6query/rip6query.c       | 7 +++----
 usr.sbin/rtprio/rtprio.c             | 2 +-
 usr.sbin/rwhod/rwhod.c               | 2 +-
 usr.sbin/setfib/setfib.c             | 2 +-
 usr.sbin/spray/spray.c               | 2 +-
 usr.sbin/tcpdrop/tcpdrop.c           | 2 +-
 11 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/usr.sbin/pnfsdscopymr/pnfsdscopymr.c b/usr.sbin/pnfsdscopymr/pnfsdscopymr.c
index 33dcd302ef73..7a6eb298fa8d 100644
--- a/usr.sbin/pnfsdscopymr/pnfsdscopymr.c
+++ b/usr.sbin/pnfsdscopymr/pnfsdscopymr.c
@@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
 #include <fs/nfs/nfs.h>
 #include <fs/nfs/nfsrvstate.h>
 
-static void usage(void);
+static void usage(void) __dead2;
 
 static struct option longopts[] = {
 	{ "migrate",	required_argument,	NULL,	'm'	},
diff --git a/usr.sbin/pnfsdsfile/pnfsdsfile.c b/usr.sbin/pnfsdsfile/pnfsdsfile.c
index ca17586dd3bd..7669f1f29b93 100644
--- a/usr.sbin/pnfsdsfile/pnfsdsfile.c
+++ b/usr.sbin/pnfsdsfile/pnfsdsfile.c
@@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$");
 #include <fs/nfs/nfs.h>
 #include <fs/nfs/nfsrvstate.h>
 
-static void usage(void);
+static void usage(void) __dead2;
 
 static struct option longopts[] = {
 	{ "changeds",	required_argument,	NULL,	'c'	},
diff --git a/usr.sbin/pnfsdskill/pnfsdskill.c b/usr.sbin/pnfsdskill/pnfsdskill.c
index dcca4a17b626..878ca584d142 100644
--- a/usr.sbin/pnfsdskill/pnfsdskill.c
+++ b/usr.sbin/pnfsdskill/pnfsdskill.c
@@ -43,7 +43,7 @@ __FBSDID("$FreeBSD$");
 #include <fs/nfs/nfskpiport.h>
 #include <fs/nfs/nfs.h>
 
-static void usage(void);
+static void usage(void) __dead2;
 
 static struct option longopts[] = {
 	{ "force",	no_argument,	NULL,	'f'	},
diff --git a/usr.sbin/quotaon/quotaon.c b/usr.sbin/quotaon/quotaon.c
index f5340c6b44c5..224da3b2032c 100644
--- a/usr.sbin/quotaon/quotaon.c
+++ b/usr.sbin/quotaon/quotaon.c
@@ -70,7 +70,7 @@ static int	vflag;		/* verbose */
 
 static int oneof(char *, char *[], int);
 static int quotaonoff(struct fstab *fs, int, int);
-static void usage(void);
+static void usage(void) __dead2;
 
 int
 main(int argc, char **argv)
diff --git a/usr.sbin/repquota/repquota.c b/usr.sbin/repquota/repquota.c
index 23abcca93752..9fc8829ad1b6 100644
--- a/usr.sbin/repquota/repquota.c
+++ b/usr.sbin/repquota/repquota.c
@@ -104,7 +104,7 @@ int oneof(char *, char *[], int);
 int repquota(struct fstab *, int);
 char *timeprt(time_t);
 static void prthumanval(int64_t bytes);
-static void usage(void);
+static void usage(void) __dead2;
 
 int
 main(int argc, char *argv[])
diff --git a/usr.sbin/rip6query/rip6query.c b/usr.sbin/rip6query/rip6query.c
index b3d745965965..549e05c4bae6 100644
--- a/usr.sbin/rip6query/rip6query.c
+++ b/usr.sbin/rip6query/rip6query.c
@@ -62,7 +62,7 @@ static struct rip6	*ripbuf;
 #define	RIPSIZE(n)	(sizeof(struct rip6) + (n-1) * sizeof(struct netinfo6))
 
 int main(int, char **);
-static void usage(void);
+static void usage(void) __dead2;
 static const char *sa_n2a(struct sockaddr *);
 static const char *inet6_n2a(struct in6_addr *);
 
@@ -90,7 +90,6 @@ main(int argc, char *argv[])
 			break;
 		default:
 			usage();
-			exit(1);
 			/*NOTREACHED*/
 		}
 	}
@@ -99,7 +98,6 @@ main(int argc, char *argv[])
 
 	if (argc != 1) {
 		usage();
-		exit(1);
 	}
 
 	if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
@@ -168,13 +166,14 @@ main(int argc, char *argv[])
 		}
 	} while (len == RIPSIZE(24));
 
-	exit(0);
+	return 0;
 }
 
 static void
 usage(void)
 {
 	fprintf(stderr, "usage: rip6query [-I iface] address\n");
+	exit(1);
 }
 
 /* getnameinfo() is preferred as we may be able to show ifindex as ifname */
diff --git a/usr.sbin/rtprio/rtprio.c b/usr.sbin/rtprio/rtprio.c
index 9ce74b5547ad..f8da2cc96290 100644
--- a/usr.sbin/rtprio/rtprio.c
+++ b/usr.sbin/rtprio/rtprio.c
@@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$");
 #include <unistd.h>
 
 static int parseint(const char *, const char *);
-static void usage(void);
+static void usage(void) __dead2;
 
 int
 main(int argc, char *argv[])
diff --git a/usr.sbin/rwhod/rwhod.c b/usr.sbin/rwhod/rwhod.c
index 23c307e33829..1b2b2b153a0f 100644
--- a/usr.sbin/rwhod/rwhod.c
+++ b/usr.sbin/rwhod/rwhod.c
@@ -137,7 +137,7 @@ void	run_as(uid_t *uid, gid_t *gid);
 void	quit(const char *msg);
 void	sender_process(void);
 int	verify(char *name, int maxlen);
-static void usage(void);
+static void usage(void) __dead2;
 
 #ifdef DEBUG
 char	*interval(int time, char *updown);
diff --git a/usr.sbin/setfib/setfib.c b/usr.sbin/setfib/setfib.c
index 0783a07f4597..1c8adbc988da 100644
--- a/usr.sbin/setfib/setfib.c
+++ b/usr.sbin/setfib/setfib.c
@@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/socket.h>
 #include <sys/sysctl.h>
 
-static void usage(void);
+static void usage(void) __dead2;
 
 int
 main(int argc, char *argv[])
diff --git a/usr.sbin/spray/spray.c b/usr.sbin/spray/spray.c
index d8d25ef8a33c..18caf3ff3bd9 100644
--- a/usr.sbin/spray/spray.c
+++ b/usr.sbin/spray/spray.c
@@ -47,7 +47,7 @@ static const char rcsid[] =
 #define SPRAYOVERHEAD	86
 #endif
 
-static void usage(void);
+static void usage(void) __dead2;
 static void print_xferstats(unsigned int, int, double);
 
 /* spray buffer */
diff --git a/usr.sbin/tcpdrop/tcpdrop.c b/usr.sbin/tcpdrop/tcpdrop.c
index 135f1b52c403..018ef8456e6a 100644
--- a/usr.sbin/tcpdrop/tcpdrop.c
+++ b/usr.sbin/tcpdrop/tcpdrop.c
@@ -58,7 +58,7 @@ static bool tcpdropall(const char *, const char *, int);
 static bool tcpdropbyname(const char *, const char *, const char *,
     const char *);
 static bool tcpdropconn(const struct in_conninfo *);
-static void usage(void);
+static void usage(void) __dead2;
 
 /*
  * Drop a tcp connection.