diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2007-01-15 08:19:12 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2007-01-15 08:19:12 +0000 |
commit | 7300a3c9866c58c75db9cf3f12d5d4492c040844 (patch) | |
tree | 18a1f1aecaabb94f0e5a77d7168dc7794cf554c0 /usr.sbin | |
parent | 7b97bb0346a400ffdf16127b2024dcb4e3c1476a (diff) |
Although Unix compilers accept more than one definition of a global
symbol, follow the guidelines from K&R: only one definition of a
global symbol (and possibly more declarations). Rename some vars
here and there to avoid shadowing. ok henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ntpd/ntp.c | 4 | ||||
-rw-r--r-- | usr.sbin/ntpd/ntpd.c | 42 | ||||
-rw-r--r-- | usr.sbin/ntpd/ntpd.h | 5 | ||||
-rw-r--r-- | usr.sbin/ntpd/sensors.c | 7 | ||||
-rw-r--r-- | usr.sbin/ntpd/server.c | 28 |
5 files changed, 42 insertions, 44 deletions
diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c index 316f35af230..41d8f788b32 100644 --- a/usr.sbin/ntpd/ntp.c +++ b/usr.sbin/ntpd/ntp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntp.c,v 1.97 2007/01/14 19:20:09 otto Exp $ */ +/* $OpenBSD: ntp.c,v 1.98 2007/01/15 08:19:11 otto Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -165,7 +165,7 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf) conf->status.precision = a; conf->scale = 1; - sensor_init(conf); + sensor_init(); log_info("ntp engine ready"); diff --git a/usr.sbin/ntpd/ntpd.c b/usr.sbin/ntpd/ntpd.c index 37bd314dc90..75930d1f5c2 100644 --- a/usr.sbin/ntpd/ntpd.c +++ b/usr.sbin/ntpd/ntpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.c,v 1.48 2006/06/30 16:52:13 deraadt Exp $ */ +/* $OpenBSD: ntpd.c,v 1.49 2007/01/15 08:19:11 otto Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -81,7 +81,7 @@ usage(void) int main(int argc, char *argv[]) { - struct ntpd_conf conf; + struct ntpd_conf lconf; struct pollfd pfd[POLL_MAX]; pid_t chld_pid = 0, pid; const char *conffile; @@ -90,7 +90,7 @@ main(int argc, char *argv[]) conffile = CONFFILE; - bzero(&conf, sizeof(conf)); + bzero(&lconf, sizeof(lconf)); log_init(1); /* log to stderr until daemonized */ res_init(); /* XXX */ @@ -98,16 +98,16 @@ main(int argc, char *argv[]) while ((ch = getopt(argc, argv, "df:sS")) != -1) { switch (ch) { case 'd': - conf.debug = 1; + lconf.debug = 1; break; case 'f': conffile = optarg; break; case 's': - conf.settime = 1; + lconf.settime = 1; break; case 'S': - conf.settime = 0; + lconf.settime = 0; break; default: usage(); @@ -115,7 +115,7 @@ main(int argc, char *argv[]) } } - if (parse_config(conffile, &conf)) + if (parse_config(conffile, &lconf)) exit(1); if (geteuid()) { @@ -130,9 +130,9 @@ main(int argc, char *argv[]) endpwent(); reset_adjtime(); - if (!conf.settime) { - log_init(conf.debug); - if (!conf.debug) + if (!lconf.settime) { + log_init(lconf.debug); + if (!lconf.debug) if (daemon(1, 0)) fatal("daemon"); } else @@ -143,7 +143,7 @@ main(int argc, char *argv[]) signal(SIGCHLD, sighdlr); /* fork child process */ - chld_pid = ntp_main(pipe_chld, &conf); + chld_pid = ntp_main(pipe_chld, &lconf); setproctitle("[priv]"); readfreq(); @@ -170,13 +170,13 @@ main(int argc, char *argv[]) quit = 1; } - if (nfds == 0 && conf.settime) { - conf.settime = 0; + if (nfds == 0 && lconf.settime) { + lconf.settime = 0; timeout = INFTIM; - log_init(conf.debug); + log_init(lconf.debug); log_debug("no reply received in time, skipping initial " "time setting"); - if (!conf.debug) + if (!lconf.debug) if (daemon(1, 0)) fatal("daemon"); } @@ -189,7 +189,7 @@ main(int argc, char *argv[]) if (nfds > 0 && pfd[PFD_PIPE].revents & POLLIN) { nfds--; - if (dispatch_imsg(&conf) == -1) + if (dispatch_imsg(&lconf) == -1) quit = 1; } @@ -244,7 +244,7 @@ check_child(pid_t pid, const char *pname) } int -dispatch_imsg(struct ntpd_conf *conf) +dispatch_imsg(struct ntpd_conf *lconf) { struct imsg imsg; int n, cnt; @@ -285,16 +285,16 @@ dispatch_imsg(struct ntpd_conf *conf) case IMSG_SETTIME: if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(d)) fatalx("invalid IMSG_SETTIME received"); - if (!conf->settime) + if (!lconf->settime) break; - log_init(conf->debug); + log_init(lconf->debug); memcpy(&d, imsg.data, sizeof(d)); ntpd_settime(d); /* daemonize now */ - if (!conf->debug) + if (!lconf->debug) if (daemon(1, 0)) fatal("daemon"); - conf->settime = 0; + lconf->settime = 0; break; case IMSG_HOST_DNS: name = imsg.data; diff --git a/usr.sbin/ntpd/ntpd.h b/usr.sbin/ntpd/ntpd.h index e5539e0589b..ccfeb63b07e 100644 --- a/usr.sbin/ntpd/ntpd.h +++ b/usr.sbin/ntpd/ntpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.h,v 1.80 2006/12/23 17:49:53 deraadt Exp $ */ +/* $OpenBSD: ntpd.h,v 1.81 2007/01/15 08:19:11 otto Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -263,6 +263,7 @@ int priv_adjtime(void); void priv_settime(double); void priv_host_dns(char *, u_int32_t); int offset_compare(const void *, const void *); +extern struct ntpd_conf *conf; /* parse.y */ int parse_config(const char *, struct ntpd_conf *); @@ -306,7 +307,7 @@ double sfp_to_d(struct s_fixedpt); struct s_fixedpt d_to_sfp(double); /* sensors.c */ -void sensor_init(struct ntpd_conf *); +void sensor_init(void); void sensor_scan(void); void sensor_query(struct ntp_sensor *); int sensor_hotplugfd(void); diff --git a/usr.sbin/ntpd/sensors.c b/usr.sbin/ntpd/sensors.c index 0216667163c..1058a341c69 100644 --- a/usr.sbin/ntpd/sensors.c +++ b/usr.sbin/ntpd/sensors.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sensors.c,v 1.29 2007/01/14 19:18:12 otto Exp $ */ +/* $OpenBSD: sensors.c,v 1.30 2007/01/15 08:19:11 otto Exp $ */ /* * Copyright (c) 2006 Henning Brauer <henning@openbsd.org> @@ -39,12 +39,9 @@ void sensor_add(int, char *); void sensor_remove(struct ntp_sensor *); void sensor_update(struct ntp_sensor *); -struct ntpd_conf *conf; - void -sensor_init(struct ntpd_conf *c) +sensor_init(void) { - conf = c; TAILQ_INIT(&conf->ntp_sensors); } diff --git a/usr.sbin/ntpd/server.c b/usr.sbin/ntpd/server.c index 8a823d217b4..3429aa011b5 100644 --- a/usr.sbin/ntpd/server.c +++ b/usr.sbin/ntpd/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.30 2006/07/01 18:52:46 otto Exp $ */ +/* $OpenBSD: server.c,v 1.31 2007/01/15 08:19:11 otto Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -28,7 +28,7 @@ #include "ntpd.h" int -setup_listeners(struct servent *se, struct ntpd_conf *conf, u_int *cnt) +setup_listeners(struct servent *se, struct ntpd_conf *lconf, u_int *cnt) { struct listen_addr *la; struct ifaddrs *ifa, *ifap; @@ -38,7 +38,7 @@ setup_listeners(struct servent *se, struct ntpd_conf *conf, u_int *cnt) u_int new_cnt = 0; int tos = IPTOS_LOWDELAY; - if (conf->listen_all) { + if (lconf->listen_all) { if (getifaddrs(&ifa) == -1) fatal("getifaddrs"); @@ -69,13 +69,13 @@ setup_listeners(struct servent *se, struct ntpd_conf *conf, u_int *cnt) fatal("setup_listeners calloc"); memcpy(&la->sa, sa, SA_LEN(sa)); - TAILQ_INSERT_TAIL(&conf->listen_addrs, la, entry); + TAILQ_INSERT_TAIL(&lconf->listen_addrs, la, entry); } freeifaddrs(ifa); } - TAILQ_FOREACH(la, &conf->listen_addrs, entry) { + TAILQ_FOREACH(la, &lconf->listen_addrs, entry) { new_cnt++; switch (la->sa.ss_family) { @@ -114,7 +114,7 @@ setup_listeners(struct servent *se, struct ntpd_conf *conf, u_int *cnt) } int -server_dispatch(int fd, struct ntpd_conf *conf) +server_dispatch(int fd, struct ntpd_conf *lconf) { ssize_t size; u_int8_t version; @@ -144,8 +144,8 @@ server_dispatch(int fd, struct ntpd_conf *conf) version = (query.status & VERSIONMASK) >> 3; bzero(&reply, sizeof(reply)); - if (conf->status.synced) - reply.status = conf->status.leap; + if (lconf->status.synced) + reply.status = lconf->status.leap; else reply.status = LI_ALARM; reply.status |= (query.status & VERSIONMASK); @@ -154,19 +154,19 @@ server_dispatch(int fd, struct ntpd_conf *conf) else reply.status |= MODE_SYM_PAS; - reply.stratum = conf->status.stratum; + reply.stratum = lconf->status.stratum; reply.ppoll = query.ppoll; - reply.precision = conf->status.precision; + reply.precision = lconf->status.precision; reply.rectime = d_to_lfp(rectime); - reply.reftime = d_to_lfp(conf->status.reftime); + reply.reftime = d_to_lfp(lconf->status.reftime); reply.xmttime = d_to_lfp(gettime_corrected()); reply.orgtime = query.xmttime; - reply.rootdelay = d_to_sfp(conf->status.rootdelay); + reply.rootdelay = d_to_sfp(lconf->status.rootdelay); if (version > 3) - reply.refid = conf->status.refid4; + reply.refid = lconf->status.refid4; else - reply.refid = conf->status.refid; + reply.refid = lconf->status.refid; ntp_sendmsg(fd, (struct sockaddr *)&fsa, &reply, size, 0); return (0); |