extern optind and friends are already declared once unistd.h is included, to these can be removed.
This is the usr.sbin part; I am not touching nsd and other third-party stuff. Jan Index: usr.sbin//yppoll/yppoll.c =================================================================== RCS file: /cvs/src/usr.sbin/yppoll/yppoll.c,v retrieving revision 1.15 diff -u -p -r1.15 yppoll.c --- usr.sbin//yppoll/yppoll.c 16 Jan 2015 06:40:22 -0000 1.15 +++ usr.sbin//yppoll/yppoll.c 22 Nov 2021 23:06:04 -0000 @@ -126,8 +126,6 @@ int main(int argc, char *argv[]) { char *domainname, *hostname = NULL, *inmap, *master; - extern char *optarg; - extern int optind; int order, c, r; time_t torder; Index: usr.sbin//ypserv/makedbm/makedbm.c =================================================================== RCS file: /cvs/src/usr.sbin/ypserv/makedbm/makedbm.c,v retrieving revision 1.33 diff -u -p -r1.33 makedbm.c --- usr.sbin//ypserv/makedbm/makedbm.c 9 Feb 2015 23:00:15 -0000 1.33 +++ usr.sbin//ypserv/makedbm/makedbm.c 22 Nov 2021 23:06:04 -0000 @@ -302,9 +302,6 @@ main(int argc, char *argv[]) char *infile, *outfile; int ch; - extern int optind; - extern char *optarg; - yp_input_file = yp_output_file = NULL; yp_master_name = yp_domain_name = NULL; aflag = uflag = bflag = lflag = sflag = Uflag = 0; Index: usr.sbin//ypserv/yppush/yppush.c =================================================================== RCS file: /cvs/src/usr.sbin/ypserv/yppush/yppush.c,v retrieving revision 1.31 diff -u -p -r1.31 yppush.c --- usr.sbin//ypserv/yppush/yppush.c 16 Jan 2015 06:40:23 -0000 1.31 +++ usr.sbin//ypserv/yppush/yppush.c 22 Nov 2021 23:06:04 -0000 @@ -216,8 +216,6 @@ int main(int argc, char *argv[]) { struct ypall_callback ypcb; - extern char *optarg; - extern int optind; char *domain, *map, *hostname; int c, r, i; char *ypmap = "ypservers"; Index: usr.sbin//ypset/ypset.c =================================================================== RCS file: /cvs/src/usr.sbin/ypset/ypset.c,v retrieving revision 1.20 diff -u -p -r1.20 ypset.c --- usr.sbin//ypset/ypset.c 16 Jan 2015 06:40:23 -0000 1.20 +++ usr.sbin//ypset/ypset.c 22 Nov 2021 23:06:04 -0000 @@ -106,8 +106,6 @@ main(int argc, char *argv[]) { struct sockaddr_in sin; struct hostent *hent; - extern char *optarg; - extern int optind; char *domainname; int c;