Take note this change is fine for modern POSIX systems, but there are earlier systems where unistd.h did not contain these externs.
That is why these externs were placed. As such, this change makes the software less portable against such ancient systems. At this point, I'm fine with that. Jan Stary <[email protected]> wrote: > On Dec 26 23:24:57, [email protected] wrote: > > ftpd doesn't need to declare extern int optreset > > as that is already done in the included unistd.h > > Here's more for usr.sbin/, if desirable. > > Jan > > > Index: usr.sbin//amd/amd/get_args.c > =================================================================== > RCS file: /cvs/src/usr.sbin/amd/amd/get_args.c,v > retrieving revision 1.14 > diff -u -p -u -p -r1.14 get_args.c > --- usr.sbin//amd/amd/get_args.c 20 Oct 2014 02:33:42 -0000 1.14 > +++ usr.sbin//amd/amd/get_args.c 27 Dec 2020 18:44:15 -0000 > @@ -44,9 +44,6 @@ > #include <sys/stat.h> > #include <unistd.h> > > -extern int optind; > -extern char *optarg; > - > #if defined(DEBUG) && defined(PARANOID) > char **gargv; > #endif /* defined(DEBUG) && defined(PARANOID) */ > Index: usr.sbin//amd/amq/amq.c > =================================================================== > RCS file: /cvs/src/usr.sbin/amd/amq/amq.c,v > retrieving revision 1.21 > diff -u -p -u -p -r1.21 amq.c > --- usr.sbin//amd/amq/amq.c 21 Jan 2017 08:33:51 -0000 1.21 > +++ usr.sbin//amd/amq/amq.c 27 Dec 2020 18:44:15 -0000 > @@ -59,9 +59,6 @@ static char *xlog_optstr; > static char localhost[] = "localhost"; > static char *def_server = localhost; > > -extern int optind; > -extern char *optarg; > - > static struct timeval tmo = { 10, 0 }; > #define TIMEOUT tmo > > Index: usr.sbin//crunchgen/crunchgen.c > =================================================================== > RCS file: /cvs/src/usr.sbin/crunchgen/crunchgen.c,v > retrieving revision 1.21 > diff -u -p -u -p -r1.21 crunchgen.c > --- usr.sbin//crunchgen/crunchgen.c 18 Oct 2018 14:25:14 -0000 1.21 > +++ usr.sbin//crunchgen/crunchgen.c 27 Dec 2020 18:44:15 -0000 > @@ -117,8 +117,6 @@ main(int argc, char *argv[]) > { > char *p; > int optc; > - extern int optind; > - extern char *optarg; > > if (pledge("stdio rpath wpath cpath proc exec", NULL) == -1) { > perror("pledge"); > Index: usr.sbin//mtree/mtree.c > =================================================================== > RCS file: /cvs/src/usr.sbin/mtree/mtree.c,v > retrieving revision 1.26 > diff -u -p -u -p -r1.26 mtree.c > --- usr.sbin//mtree/mtree.c 16 Sep 2018 12:43:40 -0000 1.26 > +++ usr.sbin//mtree/mtree.c 27 Dec 2020 18:44:15 -0000 > @@ -55,8 +55,6 @@ static void usage(void); > int > main(int argc, char *argv[]) > { > - extern int optind; > - extern char *optarg; > int ch; > char *dir, *p; > int status; > Index: usr.sbin//npppctl/npppctl.c > =================================================================== > RCS file: /cvs/src/usr.sbin/npppctl/npppctl.c,v > retrieving revision 1.9 > diff -u -p -u -p -r1.9 npppctl.c > --- usr.sbin//npppctl/npppctl.c 28 Jun 2019 13:32:49 -0000 1.9 > +++ usr.sbin//npppctl/npppctl.c 27 Dec 2020 18:44:15 -0000 > @@ -80,8 +80,6 @@ main(int argc, char *argv[]) > struct parse_result *result; > struct sockaddr_un sun; > const char *npppd_ctlpath = NPPPD_SOCKET; > - extern int optind; > - extern char *optarg; > > while ((ch = getopt(argc, argv, "ns:")) != -1) > switch (ch) { > Index: usr.sbin//npppd/npppd/npppd.c > =================================================================== > RCS file: /cvs/src/usr.sbin/npppd/npppd/npppd.c,v > retrieving revision 1.50 > diff -u -p -u -p -r1.50 npppd.c > --- usr.sbin//npppd/npppd/npppd.c 10 May 2019 01:29:31 -0000 1.50 > +++ usr.sbin//npppd/npppd/npppd.c 27 Dec 2020 18:44:15 -0000 > @@ -136,7 +136,6 @@ int > main(int argc, char *argv[]) > { > int ch, stop_by_error, runasdaemon = 1, nflag = 0; > - extern char *optarg; > const char *npppd_conf0 = DEFAULT_NPPPD_CONF; > struct passwd *pw; > > Index: usr.sbin//pstat/pstat.c > =================================================================== > RCS file: /cvs/src/usr.sbin/pstat/pstat.c,v > retrieving revision 1.123 > diff -u -p -u -p -r1.123 pstat.c > --- usr.sbin//pstat/pstat.c 28 Sep 2020 15:53:13 -0000 1.123 > +++ usr.sbin//pstat/pstat.c 27 Dec 2020 18:44:15 -0000 > @@ -150,8 +150,6 @@ main(int argc, char *argv[]) > int fileflag = 0, swapflag = 0, ttyflag = 0, vnodeflag = 0, ch; > char buf[_POSIX2_LINE_MAX]; > const char *dformat = NULL; > - extern char *optarg; > - extern int optind; > int i; > > hideroot = getuid(); > Index: usr.sbin//quotaon/quotaon.c > =================================================================== > RCS file: /cvs/src/usr.sbin/quotaon/quotaon.c,v > retrieving revision 1.27 > diff -u -p -u -p -r1.27 quotaon.c > --- usr.sbin//quotaon/quotaon.c 26 Apr 2018 12:42:51 -0000 1.27 > +++ usr.sbin//quotaon/quotaon.c 27 Dec 2020 18:44:15 -0000 > @@ -66,7 +66,6 @@ main(int argc, char *argv[]) > char *qfnp, *whoami; > long argnum, done = 0; > int i, offmode = 0, errs = 0; > - extern int optind; > int ch; > > whoami = strrchr(*argv, '/') + 1; > Index: usr.sbin//rarpd/rarpd.c > =================================================================== > RCS file: /cvs/src/usr.sbin/rarpd/rarpd.c,v > retrieving revision 1.76 > diff -u -p -u -p -r1.76 rarpd.c > --- usr.sbin//rarpd/rarpd.c 28 Jun 2019 13:32:50 -0000 1.76 > +++ usr.sbin//rarpd/rarpd.c 27 Dec 2020 18:44:15 -0000 > @@ -103,7 +103,6 @@ int > main(int argc, char *argv[]) > { > extern char *__progname; > - extern int optind, opterr; > int op; > > /* All error reporting is done through syslogs. */ > Index: usr.sbin//rdate/rdate.c > =================================================================== > RCS file: /cvs/src/usr.sbin/rdate/rdate.c,v > retrieving revision 1.35 > diff -u -p -u -p -r1.35 rdate.c > --- usr.sbin//rdate/rdate.c 23 Dec 2015 19:13:52 -0000 1.35 > +++ usr.sbin//rdate/rdate.c 27 Dec 2020 18:44:15 -0000 > @@ -82,7 +82,6 @@ main(int argc, char **argv) > int pr = 0, silent = 0, ntp = 1, verbose = 0; > int slidetime = 0, corrleaps = 0; > char *hname; > - extern int optind; > int c, p[2], pid; > int family = PF_UNSPEC; > > Index: usr.sbin//repquota/repquota.c > =================================================================== > RCS file: /cvs/src/usr.sbin/repquota/repquota.c,v > retrieving revision 1.35 > diff -u -p -u -p -r1.35 repquota.c > --- usr.sbin//repquota/repquota.c 16 Mar 2016 15:41:11 -0000 1.35 > +++ usr.sbin//repquota/repquota.c 27 Dec 2020 18:44:15 -0000 > @@ -77,8 +77,6 @@ main(int argc, char *argv[]) > struct group *gr; > int gflag = 0, uflag = 0, errs = 0; > long i, argnum, done = 0; > - extern char *optarg; > - extern int optind; > char *qfnp; > int ch; > > Index: usr.sbin//rpc.bootparamd/bootparamd.c > =================================================================== > RCS file: /cvs/src/usr.sbin/rpc.bootparamd/bootparamd.c,v > retrieving revision 1.21 > diff -u -p -u -p -r1.21 bootparamd.c > --- usr.sbin//rpc.bootparamd/bootparamd.c 16 Oct 2016 10:40:58 -0000 > 1.21 > +++ usr.sbin//rpc.bootparamd/bootparamd.c 27 Dec 2020 18:44:16 -0000 > @@ -50,8 +50,6 @@ struct sockaddr_in my_addr; > extern char *__progname; > char *bootpfile = _PATH_BOOTPARAMS; > > -extern char *optarg; > -extern int optind; > > static void > usage(void) > Index: usr.sbin//syslogc/syslogc.c > =================================================================== > RCS file: /cvs/src/usr.sbin/syslogc/syslogc.c,v > retrieving revision 1.18 > diff -u -p -u -p -r1.18 syslogc.c > --- usr.sbin//syslogc/syslogc.c 13 Oct 2015 16:30:55 -0000 1.18 > +++ usr.sbin//syslogc/syslogc.c 27 Dec 2020 18:44:16 -0000 > @@ -77,8 +77,6 @@ main(int argc, char **argv) > struct sockaddr_un ctl; > int ctlsock, ch, oflag, rval; > FILE *ctlf; > - extern char *optarg; > - extern int optind; > struct ctl_cmd cc; > struct ctl_reply_hdr rr; > const char *errstr; >
