diff options
author | ed <ed@FreeBSD.org> | 2012-09-01 14:45:15 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2012-09-01 14:45:15 +0000 |
commit | 02dcf28b5875df173bef8c14a9ddd3d3ce67c5d4 (patch) | |
tree | 496a0b9a3b14c27d50e1ae3b28265ecf5c2023f2 | |
parent | a6edc1e4b7ca5750cf84fb6a6b048b796c0cc77f (diff) | |
download | FreeBSD-src-02dcf28b5875df173bef8c14a9ddd3d3ce67c5d4.zip FreeBSD-src-02dcf28b5875df173bef8c14a9ddd3d3ce67c5d4.tar.gz |
Rework all non-contributed files that use `struct timezone'.
This structure is not part of POSIX. According to POSIX, gettimeofday()
has the following prototype:
int gettimeofday(struct timeval *restrict tp, void *restrict tzp);
Also, POSIX states that gettimeofday() shall return 0 (as long as tzp is
not used). Remove dead error handling code. Also use NULL for a
nul-pointer instead of integer 0.
While there, change all pieces of code that only use tv_sec to use
time(3), as this provides less overhead.
-rw-r--r-- | bin/date/date.c | 8 | ||||
-rw-r--r-- | bin/dd/dd.c | 4 | ||||
-rw-r--r-- | bin/dd/misc.c | 2 | ||||
-rw-r--r-- | lib/libc/rpc/auth_des.c | 2 | ||||
-rw-r--r-- | lib/libc/rpc/svc_auth_des.c | 2 | ||||
-rw-r--r-- | libexec/rbootd/rbootd.c | 7 | ||||
-rw-r--r-- | libexec/rbootd/rmpproto.c | 2 | ||||
-rw-r--r-- | libexec/rpc.rstatd/rstat_proc.c | 7 | ||||
-rw-r--r-- | release/picobsd/tinyware/login/pico-login.c | 14 | ||||
-rw-r--r-- | sbin/adjkerntz/adjkerntz.c | 5 | ||||
-rw-r--r-- | usr.bin/lock/lock.c | 33 | ||||
-rw-r--r-- | usr.bin/mail/util.c | 2 | ||||
-rw-r--r-- | usr.bin/systat/ifstat.c | 3 | ||||
-rw-r--r-- | usr.bin/time/time.c | 6 | ||||
-rw-r--r-- | usr.sbin/cron/crontab/crontab.c | 3 | ||||
-rw-r--r-- | usr.sbin/inetd/builtins.c | 8 | ||||
-rw-r--r-- | usr.sbin/keyserv/keyserv.c | 4 | ||||
-rw-r--r-- | usr.sbin/timed/timed/master.c | 32 | ||||
-rw-r--r-- | usr.sbin/timed/timed/measure.c | 6 | ||||
-rw-r--r-- | usr.sbin/timed/timed/readmsg.c | 6 | ||||
-rw-r--r-- | usr.sbin/timed/timed/slave.c | 28 | ||||
-rw-r--r-- | usr.sbin/timed/timed/timed.c | 6 | ||||
-rw-r--r-- | usr.sbin/timed/timedc/cmds.c | 2 |
23 files changed, 87 insertions, 105 deletions
diff --git a/bin/date/date.c b/bin/date/date.c index 1e9f281..58a9afb 100644 --- a/bin/date/date.c +++ b/bin/date/date.c @@ -137,7 +137,7 @@ main(int argc, char *argv[]) * If -d or -t, set the timezone or daylight savings time; this * doesn't belong here; the kernel should not know about either. */ - if (set_timezone && settimeofday((struct timeval *)NULL, &tz)) + if (set_timezone && settimeofday(NULL, &tz) != 0) err(1, "settimeofday (timezone)"); if (!rflag && time(&tval) == -1) @@ -273,14 +273,14 @@ setthetime(const char *fmt, const char *p, int jflag, int nflag) /* set the time */ if (nflag || netsettime(tval)) { utx.ut_type = OLD_TIME; - gettimeofday(&utx.ut_tv, NULL); + (void)gettimeofday(&utx.ut_tv, NULL); pututxline(&utx); tv.tv_sec = tval; tv.tv_usec = 0; - if (settimeofday(&tv, (struct timezone *)NULL)) + if (settimeofday(&tv, NULL) != 0) err(1, "settimeofday (timeval)"); utx.ut_type = NEW_TIME; - gettimeofday(&utx.ut_tv, NULL); + (void)gettimeofday(&utx.ut_tv, NULL); pututxline(&utx); } diff --git a/bin/dd/dd.c b/bin/dd/dd.c index 0bb43f7..637e0cc 100644 --- a/bin/dd/dd.c +++ b/bin/dd/dd.c @@ -232,8 +232,8 @@ setup(void) ctab = casetab; } - (void)gettimeofday(&tv, (struct timezone *)NULL); - st.start = tv.tv_sec + tv.tv_usec * 1e-6; + (void)gettimeofday(&tv, NULL); + st.start = tv.tv_sec + tv.tv_usec * 1e-6; } static void diff --git a/bin/dd/misc.c b/bin/dd/misc.c index 4f538bc..8edc5a5 100644 --- a/bin/dd/misc.c +++ b/bin/dd/misc.c @@ -59,7 +59,7 @@ summary(void) double secs; char buf[100]; - (void)gettimeofday(&tv, (struct timezone *)NULL); + (void)gettimeofday(&tv, NULL); secs = tv.tv_sec + tv.tv_usec * 1e-6 - st.start; if (secs < 1e-6) secs = 1e-6; diff --git a/lib/libc/rpc/auth_des.c b/lib/libc/rpc/auth_des.c index 8f363e9..1b45c3b 100644 --- a/lib/libc/rpc/auth_des.c +++ b/lib/libc/rpc/auth_des.c @@ -286,7 +286,7 @@ authdes_marshal(AUTH *auth, XDR *xdrs) * Figure out the "time", accounting for any time difference * with the server if necessary. */ - (void) gettimeofday(&ad->ad_timestamp, (struct timezone *)NULL); + (void)gettimeofday(&ad->ad_timestamp, NULL); ad->ad_timestamp.tv_sec += ad->ad_timediff.tv_sec; ad->ad_timestamp.tv_usec += ad->ad_timediff.tv_usec; while (ad->ad_timestamp.tv_usec >= USEC_PER_SEC) { diff --git a/lib/libc/rpc/svc_auth_des.c b/lib/libc/rpc/svc_auth_des.c index de4d1b4..bd45f20 100644 --- a/lib/libc/rpc/svc_auth_des.c +++ b/lib/libc/rpc/svc_auth_des.c @@ -271,7 +271,7 @@ _svcauth_des(rqst, msg) debug("timestamp before last seen"); return (AUTH_REJECTEDVERF); /* replay */ } - (void) gettimeofday(¤t, (struct timezone *)NULL); + (void)gettimeofday(¤t, NULL); current.tv_sec -= window; /* allow for expiration */ if (!BEFORE(¤t, ×tamp)) { debug("timestamp expired"); diff --git a/libexec/rbootd/rbootd.c b/libexec/rbootd/rbootd.c index e56a3e7..1d35bd1 100644 --- a/libexec/rbootd/rbootd.c +++ b/libexec/rbootd/rbootd.c @@ -310,16 +310,15 @@ void DoTimeout(void) { RMPCONN *rtmp; - struct timeval now; - - (void) gettimeofday(&now, (struct timezone *)0); + time_t now; /* * For each active connection, if RMP_TIMEOUT seconds have passed * since the last packet was sent, delete the connection. */ + now = time(NULL); for (rtmp = RmpConns; rtmp != NULL; rtmp = rtmp->next) - if ((rtmp->tstamp.tv_sec + RMP_TIMEOUT) < now.tv_sec) { + if ((rtmp->tstamp.tv_sec + RMP_TIMEOUT) < now) { syslog(LOG_WARNING, "%s: connection timed out (%u)", EnetStr(rtmp), rtmp->rmp.r_type); RemoveConn(rtmp); diff --git a/libexec/rbootd/rmpproto.c b/libexec/rbootd/rmpproto.c index 8d51445..d37ef85 100644 --- a/libexec/rbootd/rmpproto.c +++ b/libexec/rbootd/rmpproto.c @@ -575,7 +575,7 @@ SendPacket(RMPCONN *rconn) /* * Last time this connection was active. */ - (void) gettimeofday(&rconn->tstamp, (struct timezone *)0); + (void)gettimeofday(&rconn->tstamp, NULL); if (DbgFp != NULL) /* display packet */ DispPkt(rconn,DIR_SENT); diff --git a/libexec/rpc.rstatd/rstat_proc.c b/libexec/rpc.rstatd/rstat_proc.c index 76911c8..1b66c64 100644 --- a/libexec/rpc.rstatd/rstat_proc.c +++ b/libexec/rpc.rstatd/rstat_proc.c @@ -244,7 +244,7 @@ updatestat(void) FETCH_CNT(stats_all.s1.v_pswpout, vm.v_swappgsout); FETCH_CNT(stats_all.s1.v_intr, sys.v_intr); FETCH_CNT(stats_all.s2.v_swtch, sys.v_swtch); - gettimeofday(&tm, (struct timezone *) 0); + (void)gettimeofday(&tm, NULL); stats_all.s1.v_intr -= hz*(tm.tv_sec - btm.tv_sec) + hz*(tm.tv_usec - btm.tv_usec)/1000000; @@ -287,8 +287,9 @@ updatestat(void) stats_all.s1.if_oerrors += ifmd.ifmd_data.ifi_oerrors; stats_all.s1.if_collisions += ifmd.ifmd_data.ifi_collisions; } - gettimeofday((struct timeval *)&stats_all.s3.curtime, - (struct timezone *) 0); + (void)gettimeofday(&tm, NULL); + stats_all.s3.curtime.tv_sec = tm.tv_sec; + stats_all.s3.curtime.tv_usec = tm.tv_usec; alarm(1); } diff --git a/release/picobsd/tinyware/login/pico-login.c b/release/picobsd/tinyware/login/pico-login.c index 7834623..e540ca8 100644 --- a/release/picobsd/tinyware/login/pico-login.c +++ b/release/picobsd/tinyware/login/pico-login.c @@ -150,12 +150,11 @@ main(argc, argv) extern char **environ; struct group *gr; struct stat st; - struct timeval tp; struct utmpx utmp; int rootok, retries, backoff; int ask, ch, cnt, fflag, hflag, pflag, quietlog, rootlogin, rval; int changepass; - time_t warntime; + time_t now, warntime; uid_t uid, euid; gid_t egid; char *p, *ttyn; @@ -430,8 +429,7 @@ main(argc, argv) if (!quietlog) quietlog = access(_PATH_HUSHLOGIN, F_OK) == 0; - if (pwd->pw_change || pwd->pw_expire) - (void)gettimeofday(&tp, (struct timezone *)NULL); + now = time(NULL); #define DEFAULT_WARN (2L * 7L * 86400L) /* Two weeks */ @@ -439,10 +437,10 @@ main(argc, argv) DEFAULT_WARN); if (pwd->pw_expire) { - if (tp.tv_sec >= pwd->pw_expire) { + if (now >= pwd->pw_expire) { refused("Sorry -- your account has expired", "EXPIRED", 1); - } else if (pwd->pw_expire - tp.tv_sec < warntime && !quietlog) + } else if (pwd->pw_expire - now < warntime && !quietlog) (void)printf("Warning: your account expires on %s", ctime(&pwd->pw_expire)); } @@ -452,12 +450,12 @@ main(argc, argv) changepass = 0; if (pwd->pw_change) { - if (tp.tv_sec >= pwd->pw_change) { + if (now >= pwd->pw_change) { (void)printf("Sorry -- your password has expired.\n"); changepass = 1; syslog(LOG_INFO, "%s Password expired - forcing change", pwd->pw_name); - } else if (pwd->pw_change - tp.tv_sec < warntime && !quietlog) + } else if (pwd->pw_change - now < warntime && !quietlog) (void)printf("Warning: your password expires on %s", ctime(&pwd->pw_change)); } diff --git a/sbin/adjkerntz/adjkerntz.c b/sbin/adjkerntz/adjkerntz.c index 35d8da9..c42379d 100644 --- a/sbin/adjkerntz/adjkerntz.c +++ b/sbin/adjkerntz/adjkerntz.c @@ -315,10 +315,7 @@ recalculate: * restoring disrtcset, since we don't clean up * anything. */ - if (gettimeofday(&tv, (struct timezone *)NULL)) { - syslog(LOG_ERR, "gettimeofday: %m"); - return 1; - } + (void)gettimeofday(&tv, NULL); tv.tv_sec += diff; stv = &tv; } diff --git a/usr.bin/lock/lock.c b/usr.bin/lock/lock.c index 3f23a98..0382e83 100644 --- a/usr.bin/lock/lock.c +++ b/usr.bin/lock/lock.c @@ -54,9 +54,9 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/stat.h> -#include <sys/time.h> #include <sys/signal.h> #include <sys/consio.h> + #include <err.h> #include <ctype.h> #include <errno.h> @@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$"); #include <string.h> #include <syslog.h> #include <termios.h> +#include <time.h> #include <unistd.h> #define TIMEOUT 15 @@ -89,10 +90,9 @@ int main(int argc, char **argv) { struct passwd *pw; - struct timeval timval; - time_t timval_sec; struct itimerval ntimer, otimer; struct tm *timp; + time_t timval; int ch, failures, sectimeout, usemine, vtylock; char *ap, *cryptpw, *mypw, *ttynam, *tzn; char hostname[MAXHOSTNAMELEN], s[BUFSIZ], s1[BUFSIZ]; @@ -138,11 +138,9 @@ main(int argc, char **argv) errx(1, "not a terminal?"); if (strncmp(ttynam, _PATH_DEV, strlen(_PATH_DEV)) == 0) ttynam += strlen(_PATH_DEV); - if (gettimeofday(&timval, (struct timezone *)NULL)) - err(1, "gettimeofday"); - nexttime = timval.tv_sec + (sectimeout * 60); - timval_sec = timval.tv_sec; - timp = localtime(&timval_sec); + timval = time(NULL); + nexttime = timval + (sectimeout * 60); + timp = localtime(&timval); ap = asctime(timp); tzn = timp->tm_zone; @@ -256,17 +254,16 @@ usage(void) static void hi(int signo __unused) { - struct timeval timval; + time_t timval; - if (!gettimeofday(&timval, (struct timezone *)NULL)) { - (void)printf("lock: type in the unlock key. "); - if (no_timeout) { - (void)putchar('\n'); - } else { - (void)printf("timeout in %jd:%jd minutes\n", - (intmax_t)(nexttime - timval.tv_sec) / 60, - (intmax_t)(nexttime - timval.tv_sec) % 60); - } + timval = time(NULL); + (void)printf("lock: type in the unlock key. "); + if (no_timeout) { + (void)putchar('\n'); + } else { + (void)printf("timeout in %jd:%jd minutes\n", + (intmax_t)(nexttime - timval) / 60, + (intmax_t)(nexttime - timval) % 60); } } diff --git a/usr.bin/mail/util.c b/usr.bin/mail/util.c index c90fe90..4e3a0f6 100644 --- a/usr.bin/mail/util.c +++ b/usr.bin/mail/util.c @@ -324,7 +324,7 @@ alter(char *name) if (stat(name, &sb)) return; - (void)gettimeofday(&tv[0], (struct timezone *)NULL); + (void)gettimeofday(&tv[0], NULL); tv[0].tv_sec++; TIMESPEC_TO_TIMEVAL(&tv[1], &sb.st_mtim); (void)utimes(name, tv); diff --git a/usr.bin/systat/ifstat.c b/usr.bin/systat/ifstat.c index fc853b0..3e45499 100644 --- a/usr.bin/systat/ifstat.c +++ b/usr.bin/systat/ifstat.c @@ -247,8 +247,7 @@ fetchifstat(void) old_outb = ifp->if_mib.ifmd_data.ifi_obytes; ifp->tv_lastchanged = ifp->if_mib.ifmd_data.ifi_lastchange; - if (gettimeofday(&new_tv, (struct timezone *)0) != 0) - IFSTAT_ERR(2, "error getting time of day"); + (void)gettimeofday(&new_tv, NULL); (void)getifmibdata(ifp->if_row, &ifp->if_mib); new_inb = ifp->if_mib.ifmd_data.ifi_ibytes; diff --git a/usr.bin/time/time.c b/usr.bin/time/time.c index 2cb7f13..ebee542 100644 --- a/usr.bin/time/time.c +++ b/usr.bin/time/time.c @@ -117,7 +117,7 @@ main(int argc, char **argv) setvbuf(out, (char *)NULL, _IONBF, (size_t)0); } - gettimeofday(&before_tv, (struct timezone *)NULL); + (void)gettimeofday(&before_tv, NULL); switch(pid = fork()) { case -1: /* error */ err(1, "time"); @@ -134,7 +134,7 @@ main(int argc, char **argv) (void)signal(SIGQUIT, SIG_IGN); (void)signal(SIGINFO, siginfo); while (wait4(pid, &status, 0, &ru) != pid); - gettimeofday(&after, (struct timezone *)NULL); + (void)gettimeofday(&after, NULL); if ( ! WIFEXITED(status)) warnx("command terminated abnormally"); exitonsig = WIFSIGNALED(status) ? WTERMSIG(status) : 0; @@ -297,7 +297,7 @@ siginfo(int sig __unused) struct timeval after; struct rusage ru; - gettimeofday(&after, (struct timezone *)NULL); + (void)gettimeofday(&after, NULL); getrusage(RUSAGE_CHILDREN, &ru); showtime(stdout, &before_tv, &after, &ru); } diff --git a/usr.sbin/cron/crontab/crontab.c b/usr.sbin/cron/crontab/crontab.c index 69c4606..1ac81b0 100644 --- a/usr.sbin/cron/crontab/crontab.c +++ b/usr.sbin/cron/crontab/crontab.c @@ -627,9 +627,8 @@ static void poke_daemon() { #ifdef USE_UTIMES struct timeval tvs[2]; - struct timezone tz; - (void) gettimeofday(&tvs[0], &tz); + (void)gettimeofday(&tvs[0], NULL); tvs[1] = tvs[0]; if (utimes(SPOOL_DIR, tvs) < OK) { warn("can't update mtime on spooldir %s", SPOOL_DIR); diff --git a/usr.sbin/inetd/builtins.c b/usr.sbin/inetd/builtins.c index 974e54f..3ccdab0 100644 --- a/usr.sbin/inetd/builtins.c +++ b/usr.sbin/inetd/builtins.c @@ -691,15 +691,9 @@ printit: uint32_t machtime(void) { - struct timeval tv; - if (gettimeofday(&tv, (struct timezone *)NULL) < 0) { - if (debug) - warnx("unable to get time of day"); - return (0L); - } #define OFFSET ((uint32_t)25567 * 24*60*60) - return (htonl((uint32_t)(tv.tv_sec + OFFSET))); + return (htonl((uint32_t)(time(NULL) + OFFSET))); #undef OFFSET } diff --git a/usr.sbin/keyserv/keyserv.c b/usr.sbin/keyserv/keyserv.c index 2366ba0..79bf90d 100644 --- a/usr.sbin/keyserv/keyserv.c +++ b/usr.sbin/keyserv/keyserv.c @@ -232,7 +232,7 @@ randomize(master) seed = 0; for (i = 0; i < 1024; i++) { - (void) gettimeofday(&tv, (struct timezone *) NULL); + (void)gettimeofday(&tv, NULL); shift = i % 8 * sizeof (int); seed ^= (tv.tv_usec << shift) | (tv.tv_usec >> (32 - shift)); } @@ -575,7 +575,7 @@ key_gen_1_svc_prog(v, s) static des_block keygen; static des_block key; - (void) gettimeofday(&time, (struct timezone *) NULL); + (void)gettimeofday(&time, NULL); keygen.key.high += (time.tv_sec ^ time.tv_usec); keygen.key.low += (time.tv_sec ^ time.tv_usec); ecb_crypt((char *)&masterkey, (char *)&keygen, sizeof (keygen), diff --git a/usr.sbin/timed/timed/master.c b/usr.sbin/timed/timed/master.c index a7d74ee..b64259b 100644 --- a/usr.sbin/timed/timed/master.c +++ b/usr.sbin/timed/timed/master.c @@ -85,7 +85,7 @@ master() if (ntp->status == MASTER) masterup(ntp); } - (void)gettimeofday(&ntime, 0); + (void)gettimeofday(&ntime, NULL); pollingtime = ntime.tv_sec+3; if (justquit) polls = 0; @@ -96,14 +96,14 @@ master() * to update all timers. */ loop: - (void)gettimeofday(&ntime, 0); + (void)gettimeofday(&ntime, NULL); wait.tv_sec = pollingtime - ntime.tv_sec; if (wait.tv_sec < 0) wait.tv_sec = 0; wait.tv_usec = 0; msg = readmsg(TSP_ANY, ANYADDR, &wait, 0); if (!msg) { - (void)gettimeofday(&ntime, 0); + (void)gettimeofday(&ntime, NULL); if (ntime.tv_sec >= pollingtime) { pollingtime = ntime.tv_sec + SAMPLEINTVL; get_goodgroup(0); @@ -175,7 +175,7 @@ loop: } mchgdate(msg); - (void)gettimeofday(&ntime, 0); + (void)gettimeofday(&ntime, NULL); pollingtime = ntime.tv_sec + SAMPLEINTVL; break; @@ -203,7 +203,7 @@ loop: } mchgdate(msg); - (void)gettimeofday(&ntime, 0); + (void)gettimeofday(&ntime, NULL); pollingtime = ntime.tv_sec + SAMPLEINTVL; break; @@ -284,7 +284,7 @@ loop: * do not want to call synch() while waiting * to be killed! */ - (void)gettimeofday(&ntime, (struct timezone *)0); + (void)gettimeofday(&ntime, NULL); pollingtime = ntime.tv_sec + SAMPLEINTVL; break; @@ -354,7 +354,7 @@ mchgdate(msg) (void)strcpy(olddate, date()); /* adjust time for residence on the queue */ - (void)gettimeofday(&otime, 0); + (void)gettimeofday(&otime, NULL); adj_msg_time(msg,&otime); tmptv.tv_sec = msg->tsp_time.tv_sec; @@ -368,11 +368,11 @@ mchgdate(msg) synch(tvtomsround(ntime)); } else { utx.ut_type = OLD_TIME; - gettimeofday(&utx.ut_tv, NULL); + (void)gettimeofday(&utx.ut_tv, NULL); pututxline(&utx); (void)settimeofday(&tmptv, 0); utx.ut_type = NEW_TIME; - gettimeofday(&utx.ut_tv, NULL); + (void)gettimeofday(&utx.ut_tv, NULL); pututxline(&utx); spreadtime(); } @@ -396,7 +396,7 @@ synch(mydelta) if (slvcount > 0) { if (trace) fprintf(fd, "measurements starting at %s\n", date()); - (void)gettimeofday(&check, 0); + (void)gettimeofday(&check, NULL); for (htp = self.l_fwd; htp != &self; htp = htp->l_fwd) { if (htp->noanswer != 0) { measure_status = measure(500, 100, @@ -424,7 +424,7 @@ synch(mydelta) } else { htp->delta = measure_delta; } - (void)gettimeofday(&stop, 0); + (void)gettimeofday(&stop, NULL); timevalsub(&stop, &stop, &check); if (stop.tv_sec >= 1) { if (trace) @@ -437,7 +437,7 @@ synch(mydelta) if (0 != readmsg(TSP_TRACEON,ANYADDR, &wait,0)) traceon(); - (void)gettimeofday(&check, 0); + (void)gettimeofday(&check, NULL); } } if (trace) @@ -474,7 +474,7 @@ spreadtime() for (htp = self.l_fwd; htp != &self; htp = htp->l_fwd) { to.tsp_type = TSP_SETTIME; (void)strcpy(to.tsp_name, hostname); - (void)gettimeofday(&tmptv, 0); + (void)gettimeofday(&tmptv, NULL); to.tsp_time.tv_sec = tmptv.tv_sec; to.tsp_time.tv_usec = tmptv.tv_usec; answer = acksend(&to, &htp->addr, htp->name, @@ -732,7 +732,7 @@ masterup(net) * we do not tell them to start using our time, before we have * found a good master. */ - (void)gettimeofday(&net->slvwait, 0); + (void)gettimeofday(&net->slvwait, NULL); } void @@ -755,12 +755,12 @@ newslave(msg) * If we are stable, send our time to the slave. * Do not go crazy if the date has been changed. */ - (void)gettimeofday(&now, 0); + (void)gettimeofday(&now, NULL); if (now.tv_sec >= fromnet->slvwait.tv_sec+3 || now.tv_sec < fromnet->slvwait.tv_sec) { to.tsp_type = TSP_SETTIME; (void)strcpy(to.tsp_name, hostname); - (void)gettimeofday(&tmptv, 0); + (void)gettimeofday(&tmptv, NULL); to.tsp_time.tv_sec = tmptv.tv_sec; to.tsp_time.tv_usec = tmptv.tv_usec; answer = acksend(&to, &htp->addr, diff --git a/usr.sbin/timed/timed/measure.c b/usr.sbin/timed/timed/measure.c index 7f14e79..81ab7c4 100644 --- a/usr.sbin/timed/timed/measure.c +++ b/usr.sbin/timed/timed/measure.c @@ -128,7 +128,7 @@ measure(maxmsec, wmsec, hname, addr, print) FD_ZERO(&ready); - (void)gettimeofday(&tdone, 0); + (void)gettimeofday(&tdone, NULL); mstotvround(&tout, maxmsec); timevaladd(&tdone, &tout); /* when we give up */ @@ -136,7 +136,7 @@ measure(maxmsec, wmsec, hname, addr, print) rcvcount = 0; while (rcvcount < MSGS) { - (void)gettimeofday(&tcur, 0); + (void)gettimeofday(&tcur, NULL); /* * keep sending until we have sent the max @@ -173,7 +173,7 @@ measure(maxmsec, wmsec, hname, addr, print) FD_SET(sock_raw, &ready); count = select(sock_raw+1, &ready, (fd_set *)0, (fd_set *)0, &tout); - (void)gettimeofday(&tcur, (struct timezone *)0); + (void)gettimeofday(&tcur, NULL); if (count <= 0) break; diff --git a/usr.sbin/timed/timed/readmsg.c b/usr.sbin/timed/timed/readmsg.c index 9bbb3d7..aca2dbe 100644 --- a/usr.sbin/timed/timed/readmsg.c +++ b/usr.sbin/timed/timed/readmsg.c @@ -168,11 +168,11 @@ again: * right one, return it, otherwise insert it in the linked list. */ - (void)gettimeofday(&rtout, 0); + (void)gettimeofday(&rtout, NULL); timevaladd(&rtout, intvl); FD_ZERO(&ready); for (;;) { - (void)gettimeofday(&rtime, 0); + (void)gettimeofday(&rtime, NULL); timevalsub(&rwait, &rtout, &rtime); if (rwait.tv_sec < 0) rwait.tv_sec = rwait.tv_usec = 0; @@ -219,7 +219,7 @@ again: inet_ntoa(from.sin_addr)); continue; } - (void)gettimeofday(&from_when, (struct timezone *)0); + (void)gettimeofday(&from_when, NULL); bytehostorder(&msgin); if (msgin.tsp_vers > TSPVERSION) { diff --git a/usr.sbin/timed/timed/slave.c b/usr.sbin/timed/timed/slave.c index 9076d17..26e34f7 100644 --- a/usr.sbin/timed/timed/slave.c +++ b/usr.sbin/timed/timed/slave.c @@ -83,7 +83,7 @@ slave() refusetime = 0; adjtime = 0; - (void)gettimeofday(&ntime, 0); + (void)gettimeofday(&ntime, NULL); electiontime = ntime.tv_sec + delay2; fastelection = ntime.tv_sec + FASTTOUT; if (justquit) @@ -103,7 +103,7 @@ slave() loop: get_goodgroup(0); - (void)gettimeofday(&ntime, (struct timezone *)0); + (void)gettimeofday(&ntime, NULL); if (ntime.tv_sec > electiontime) { if (trace) fprintf(fd, "election timer expired\n"); @@ -132,7 +132,7 @@ loop: makeslave(slavenet); /* prune extras */ setstatus(); } - (void)gettimeofday(&ntime, 0); + (void)gettimeofday(&ntime, NULL); looktime = ntime.tv_sec + delay2; } if (ntime.tv_sec >= looptime) { @@ -153,7 +153,7 @@ loop: } } } - (void)gettimeofday(&ntime, 0); + (void)gettimeofday(&ntime, NULL); looptime = ntime.tv_sec + delay2; } @@ -225,7 +225,7 @@ loop: * Otherwise the clocks can race until the loop * is found. */ - (void)gettimeofday(&otime, 0); + (void)gettimeofday(&otime, NULL); if (adjtime < otime.tv_sec) looptime -= (looptime-otime.tv_sec)/2 + 1; @@ -234,7 +234,7 @@ loop: seq = msg->tsp_seq; synch(tvtomsround(msg->tsp_time)); } - (void)gettimeofday(&ntime, 0); + (void)gettimeofday(&ntime, NULL); electiontime = ntime.tv_sec + delay2; fastelection = ntime.tv_sec + FASTTOUT; adjtime = ntime.tv_sec + SAMPLEINTVL*2; @@ -248,7 +248,7 @@ loop: seq = msg->tsp_seq; /* adjust time for residence on the queue */ - (void)gettimeofday(&otime, 0); + (void)gettimeofday(&otime, NULL); adj_msg_time(msg,&otime); /* * the following line is necessary due to syslog @@ -289,7 +289,7 @@ loop: if (status & MASTER) spreadtime(); } - (void)gettimeofday(&ntime, 0); + (void)gettimeofday(&ntime, NULL); electiontime = ntime.tv_sec + delay2; fastelection = ntime.tv_sec + FASTTOUT; @@ -327,7 +327,7 @@ loop: setstatus(); answerdelay(); xmit(TSP_SLAVEUP, 0, &from); - (void)gettimeofday(&ntime, 0); + (void)gettimeofday(&ntime, NULL); electiontime = ntime.tv_sec + delay2; fastelection = ntime.tv_sec + FASTTOUT; refusetime = 0; @@ -336,7 +336,7 @@ loop: case TSP_MASTERREQ: if (fromnet->status != SLAVE) break; - (void)gettimeofday(&ntime, 0); + (void)gettimeofday(&ntime, NULL); electiontime = ntime.tv_sec + delay2; break; @@ -381,7 +381,7 @@ loop: case TSP_ELECTION: if (fromnet->status == SLAVE) { - (void)gettimeofday(&ntime, 0); + (void)gettimeofday(&ntime, NULL); electiontime = ntime.tv_sec + delay2; fastelection = ntime.tv_sec + FASTTOUT; seq = 0; @@ -538,7 +538,7 @@ loop: electiontime = 0; } } - (void)gettimeofday(&ntime, 0); + (void)gettimeofday(&ntime, NULL); looptime = ntime.tv_sec + FASTTOUT; } else { if (msg->tsp_hopcnt-- < 1) @@ -590,7 +590,7 @@ loop: (void)remmach(htp); } } - (void)gettimeofday(&ntime, 0); + (void)gettimeofday(&ntime, NULL); looptime = ntime.tv_sec + FASTTOUT; } break; @@ -660,7 +660,7 @@ schgdate(msg, newdate) msg->tsp_name, newdate); /* adjust time for residence on the queue */ - (void)gettimeofday(&otime, 0); + (void)gettimeofday(&otime, NULL); adj_msg_time(msg, &otime); to.tsp_type = TSP_SETDATEREQ; diff --git a/usr.sbin/timed/timed/timed.c b/usr.sbin/timed/timed/timed.c index 63d1a48..e3397a9 100644 --- a/usr.sbin/timed/timed/timed.c +++ b/usr.sbin/timed/timed/timed.c @@ -232,7 +232,7 @@ main(argc, argv) } /* choose a unique seed for random number generation */ - (void)gettimeofday(&ntime, 0); + (void)gettimeofday(&ntime, NULL); srandom(ntime.tv_sec + ntime.tv_usec); sequence = random(); /* initial seq number */ @@ -701,11 +701,9 @@ casual(inf, sup) char * date() { - struct timeval tv; time_t tv_sec; - (void)gettimeofday(&tv, (struct timezone *)0); - tv_sec = tv.tv_sec; + tv_sec = time(NULL); return (ctime(&tv_sec)); } diff --git a/usr.sbin/timed/timedc/cmds.c b/usr.sbin/timed/timedc/cmds.c index b778b1a..84740f6 100644 --- a/usr.sbin/timed/timedc/cmds.c +++ b/usr.sbin/timed/timedc/cmds.c @@ -131,7 +131,7 @@ daydiff(hostname) } sec -= BU; - (void)gettimeofday(&now, (struct timezone*)0); + (void)gettimeofday(&now, NULL); return (sec - now.tv_sec); } } |