From 3a166b33235fab2284b4709062f43d8f467a74e1 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Mon, 6 Apr 2020 23:16:05 +0000 Subject: [PATCH] yp*: fix -fno-common build This is mostly two problems spread out far and wide: - ypldap_process should be declared properly - debug is defined differently in many programs For the latter, just extern it and define it everywhere that actually needs it. This mostly works out nicely for ^/libexec/ypxfr, which can remove the assignment at the beginning of main in favor of defining it properly. -fno-common will become the default in GCC10/LLVM11. MFC after: 3 days --- libexec/ypxfr/ypxfr_main.c | 4 ++-- usr.sbin/rpc.yppasswdd/yppasswdd_main.c | 3 +-- usr.sbin/rpc.ypupdated/ypupdated_main.c | 2 ++ usr.sbin/rpc.ypxfrd/ypxfrd_main.c | 2 ++ usr.sbin/ypldap/ypldap.c | 2 ++ usr.sbin/ypldap/ypldap.h | 5 +++-- usr.sbin/ypserv/yp_access.c | 2 -- usr.sbin/ypserv/yp_error.c | 2 -- usr.sbin/ypserv/yp_main.c | 2 +- 9 files changed, 13 insertions(+), 11 deletions(-) diff --git a/libexec/ypxfr/ypxfr_main.c b/libexec/ypxfr/ypxfr_main.c index d7eb75a94c5..6ea877a4992 100644 --- a/libexec/ypxfr/ypxfr_main.c +++ b/libexec/ypxfr/ypxfr_main.c @@ -53,6 +53,8 @@ __FBSDID("$FreeBSD$"); #include #include "ypxfr_extern.h" +int debug = 1; + char *progname = "ypxfr"; char *yp_dir = _PATH_YP; int _rpcpmstart = 0; @@ -176,8 +178,6 @@ main(int argc, char *argv[]) int interdom = 0; int secure = 0; - debug = 1; - if (!isatty(fileno(stderr))) { openlog("ypxfr", LOG_PID, LOG_DAEMON); _rpcpmstart = 1; diff --git a/usr.sbin/rpc.yppasswdd/yppasswdd_main.c b/usr.sbin/rpc.yppasswdd/yppasswdd_main.c index 349f1cd59e1..b48ba40aeec 100644 --- a/usr.sbin/rpc.yppasswdd/yppasswdd_main.c +++ b/usr.sbin/rpc.yppasswdd/yppasswdd_main.c @@ -83,6 +83,7 @@ static int _rpcfdtype; #define _IDLE 0 #define _SERVED 1 #define _SERVING 2 +int debug; static char _localhost[] = "localhost"; static char _passwd_byname[] = "passwd.byname"; @@ -173,8 +174,6 @@ main(int argc, char *argv[]) char myname[MAXHOSTNAMELEN + 2]; int maxrec = RPC_MAXDATASIZE; - extern int debug; - debug = 1; while ((ch = getopt(argc, argv, "t:d:p:sfamuivh")) != -1) { diff --git a/usr.sbin/rpc.ypupdated/ypupdated_main.c b/usr.sbin/rpc.ypupdated/ypupdated_main.c index 96bf4460a25..4d826afa4e6 100644 --- a/usr.sbin/rpc.ypupdated/ypupdated_main.c +++ b/usr.sbin/rpc.ypupdated/ypupdated_main.c @@ -76,6 +76,8 @@ static int _rpcfdtype; extern int _rpcsvcstate; /* Set when a request is serviced */ +int debug; + char *progname = "rpc.ypupdated"; char *yp_dir = "/var/yp/"; diff --git a/usr.sbin/rpc.ypxfrd/ypxfrd_main.c b/usr.sbin/rpc.ypxfrd/ypxfrd_main.c index 62420a48c0a..412190c9ebe 100644 --- a/usr.sbin/rpc.ypxfrd/ypxfrd_main.c +++ b/usr.sbin/rpc.ypxfrd/ypxfrd_main.c @@ -78,6 +78,8 @@ static int _rpcfdtype; extern int _rpcsvcstate; /* Set when a request is serviced */ +int debug; + char *progname = "rpc.ypxfrd"; char *yp_dir = "/var/yp/"; diff --git a/usr.sbin/ypldap/ypldap.c b/usr.sbin/ypldap/ypldap.c index d287119518f..9a6dc303dd9 100644 --- a/usr.sbin/ypldap/ypldap.c +++ b/usr.sbin/ypldap/ypldap.c @@ -40,6 +40,8 @@ #include "ypldap.h" +enum ypldap_process_type ypldap_process; + __dead2 void usage(void); int check_child(pid_t, const char *); void main_sig_handler(int, short, void *); diff --git a/usr.sbin/ypldap/ypldap.h b/usr.sbin/ypldap/ypldap.h index f76adb1263c..07e633fdeca 100644 --- a/usr.sbin/ypldap/ypldap.h +++ b/usr.sbin/ypldap/ypldap.h @@ -47,10 +47,11 @@ struct ypldap_addr { }; TAILQ_HEAD(ypldap_addr_list, ypldap_addr); -enum { +enum ypldap_process_type { PROC_MAIN, PROC_CLIENT -} ypldap_process; +}; +extern enum ypldap_process_type ypldap_process; struct userent { RB_ENTRY(userent) ue_name_node; diff --git a/usr.sbin/ypserv/yp_access.c b/usr.sbin/ypserv/yp_access.c index bee8dd4231d..50c8d3dbd53 100644 --- a/usr.sbin/ypserv/yp_access.c +++ b/usr.sbin/ypserv/yp_access.c @@ -57,8 +57,6 @@ __FBSDID("$FreeBSD$"); #include "tcpd.h" #endif -extern int debug; - static const char *yp_procs[] = { /* NIS v1 */ "ypoldproc_null", diff --git a/usr.sbin/ypserv/yp_error.c b/usr.sbin/ypserv/yp_error.c index 9bc287280c7..c22375f859a 100644 --- a/usr.sbin/ypserv/yp_error.c +++ b/usr.sbin/ypserv/yp_error.c @@ -47,8 +47,6 @@ __FBSDID("$FreeBSD$"); #include #include "yp_extern.h" -int debug; - extern int _rpcpmstart; extern char *progname; static void __verr(const char *fmt, va_list ap) __printflike(1, 0); diff --git a/usr.sbin/ypserv/yp_main.c b/usr.sbin/ypserv/yp_main.c index d0fff1eb1e8..452bee79d2c 100644 --- a/usr.sbin/ypserv/yp_main.c +++ b/usr.sbin/ypserv/yp_main.c @@ -89,7 +89,7 @@ extern int _rpc_dtablesize(void); extern int _rpcsvcstate; /* Set when a request is serviced */ char *progname = "ypserv"; char *yp_dir = _PATH_YP; -/*int debug = 0;*/ +int debug; int do_dns = 0; int resfd;