Hello tech@

This patch brings npppd(8)'s option parsing in sync with all the other userland 
utils that don't recognize -h for help/usage (except for some games, still).

Also exit(3) at the end of the usage() function and mark it as __dead.

Greetings Ben

Index: npppd/npppd.8
===================================================================
RCS file: /cvs/src/usr.sbin/npppd/npppd/npppd.8,v
retrieving revision 1.5
diff -u -p -r1.5 npppd.8
--- npppd/npppd.8       29 Jan 2013 15:42:20 -0000      1.5
+++ npppd/npppd.8       8 Nov 2015 20:30:35 -0000
@@ -23,7 +23,7 @@
 .Nd new Point-to-Point Protocol daemon
 .Sh SYNOPSIS
 .Nm npppd
-.Op Fl dhn
+.Op Fl dn
 .Op Fl f Ar config_file
 .Sh DESCRIPTION
 .Nm
@@ -38,8 +38,6 @@ will run in the foreground and log to
 .Em stderr .
 .It Fl f Ar config_file
 Specify an alternative configuration file.
-.It Fl h
-Show the usage.
 .It Fl n
 Configtest mode.
 Only check the configuration file for validity.
Index: npppd/npppd.c
===================================================================
RCS file: /cvs/src/usr.sbin/npppd/npppd/npppd.c,v
retrieving revision 1.41
diff -u -p -r1.41 npppd.c
--- npppd/npppd.c       24 Jun 2015 04:57:55 -0000      1.41
+++ npppd/npppd.c       8 Nov 2015 20:54:15 -0000
@@ -145,7 +145,7 @@ main(int argc, char *argv[])
        const char    *npppd_conf0 = DEFAULT_NPPPD_CONF;
        struct passwd *pw;

-       while ((ch = getopt(argc, argv, "nf:dh")) != -1) {
+       while ((ch = getopt(argc, argv, "nf:d")) != -1) {
                switch (ch) {
                case 'n':
                        nflag = 1;
@@ -157,17 +157,14 @@ main(int argc, char *argv[])
                        debuglevel++;
                        runasdaemon = 0;
                        break;
-               case '?':
-               case 'h':
+               default:
                        usage();
-                       exit(1);
                }
        }
        argc -= optind;
        argv += optind;
        if (argc != 0) {
                usage();
-               exit(1);
        }
        if (nflag) {
                debuglevel++;
@@ -225,10 +222,11 @@ main(int argc, char *argv[])
        exit((!stop_by_error)? EXIT_SUCCESS : EXIT_FAILURE);
 }

-static void
-usage()
+static __dead void
+usage(void)
 {
-       fprintf(stderr, "usage: npppd [-dhn] [-f config_file]\n");
+       fprintf(stderr, "usage: npppd [-dn] [-f config_file]\n");
+       exit(1);
 }

 /** Returns the singleton npppd instance */

Reply via email to