Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Sep 2012 14:45:15 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r239991 - in head: bin/date bin/dd lib/libc/rpc libexec/rbootd libexec/rpc.rstatd release/picobsd/tinyware/login sbin/adjkerntz usr.bin/lock usr.bin/mail usr.bin/systat usr.bin/time usr...
Message-ID:  <201209011445.q81EjF2j025306@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Sat Sep  1 14:45:15 2012
New Revision: 239991
URL: http://svn.freebsd.org/changeset/base/239991

Log:
  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.

Modified:
  head/bin/date/date.c
  head/bin/dd/dd.c
  head/bin/dd/misc.c
  head/lib/libc/rpc/auth_des.c
  head/lib/libc/rpc/svc_auth_des.c
  head/libexec/rbootd/rbootd.c
  head/libexec/rbootd/rmpproto.c
  head/libexec/rpc.rstatd/rstat_proc.c
  head/release/picobsd/tinyware/login/pico-login.c
  head/sbin/adjkerntz/adjkerntz.c
  head/usr.bin/lock/lock.c
  head/usr.bin/mail/util.c
  head/usr.bin/systat/ifstat.c
  head/usr.bin/time/time.c
  head/usr.sbin/cron/crontab/crontab.c
  head/usr.sbin/inetd/builtins.c
  head/usr.sbin/keyserv/keyserv.c
  head/usr.sbin/timed/timed/master.c
  head/usr.sbin/timed/timed/measure.c
  head/usr.sbin/timed/timed/readmsg.c
  head/usr.sbin/timed/timed/slave.c
  head/usr.sbin/timed/timed/timed.c
  head/usr.sbin/timed/timedc/cmds.c

Modified: head/bin/date/date.c
==============================================================================
--- head/bin/date/date.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/bin/date/date.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -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 *
 		/* 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);
 		}
 

Modified: head/bin/dd/dd.c
==============================================================================
--- head/bin/dd/dd.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/bin/dd/dd.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -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

Modified: head/bin/dd/misc.c
==============================================================================
--- head/bin/dd/misc.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/bin/dd/misc.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -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;

Modified: head/lib/libc/rpc/auth_des.c
==============================================================================
--- head/lib/libc/rpc/auth_des.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/lib/libc/rpc/auth_des.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -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) {

Modified: head/lib/libc/rpc/svc_auth_des.c
==============================================================================
--- head/lib/libc/rpc/svc_auth_des.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/lib/libc/rpc/svc_auth_des.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -271,7 +271,7 @@ _svcauth_des(rqst, msg)
 			debug("timestamp before last seen");
 			return (AUTH_REJECTEDVERF);	/* replay */
 		}
-		(void) gettimeofday(&current, (struct timezone *)NULL);
+		(void)gettimeofday(&current, NULL);
 		current.tv_sec -= window;	/* allow for expiration */
 		if (!BEFORE(&current, &timestamp)) {
 			debug("timestamp expired");

Modified: head/libexec/rbootd/rbootd.c
==============================================================================
--- head/libexec/rbootd/rbootd.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/libexec/rbootd/rbootd.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -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);

Modified: head/libexec/rbootd/rmpproto.c
==============================================================================
--- head/libexec/rbootd/rmpproto.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/libexec/rbootd/rmpproto.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -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);

Modified: head/libexec/rpc.rstatd/rstat_proc.c
==============================================================================
--- head/libexec/rpc.rstatd/rstat_proc.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/libexec/rpc.rstatd/rstat_proc.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -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);
 }
 

Modified: head/release/picobsd/tinyware/login/pico-login.c
==============================================================================
--- head/release/picobsd/tinyware/login/pico-login.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/release/picobsd/tinyware/login/pico-login.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -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));
 	}

Modified: head/sbin/adjkerntz/adjkerntz.c
==============================================================================
--- head/sbin/adjkerntz/adjkerntz.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/sbin/adjkerntz/adjkerntz.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -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;
 		}

Modified: head/usr.bin/lock/lock.c
==============================================================================
--- head/usr.bin/lock/lock.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/usr.bin/lock/lock.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -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);
 	}
 }
 

Modified: head/usr.bin/mail/util.c
==============================================================================
--- head/usr.bin/mail/util.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/usr.bin/mail/util.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -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);

Modified: head/usr.bin/systat/ifstat.c
==============================================================================
--- head/usr.bin/systat/ifstat.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/usr.bin/systat/ifstat.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -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;

Modified: head/usr.bin/time/time.c
==============================================================================
--- head/usr.bin/time/time.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/usr.bin/time/time.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -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);
 }

Modified: head/usr.sbin/cron/crontab/crontab.c
==============================================================================
--- head/usr.sbin/cron/crontab/crontab.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/usr.sbin/cron/crontab/crontab.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -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);

Modified: head/usr.sbin/inetd/builtins.c
==============================================================================
--- head/usr.sbin/inetd/builtins.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/usr.sbin/inetd/builtins.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -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
 }
 

Modified: head/usr.sbin/keyserv/keyserv.c
==============================================================================
--- head/usr.sbin/keyserv/keyserv.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/usr.sbin/keyserv/keyserv.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -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),

Modified: head/usr.sbin/timed/timed/master.c
==============================================================================
--- head/usr.sbin/timed/timed/master.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/usr.sbin/timed/timed/master.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -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,

Modified: head/usr.sbin/timed/timed/measure.c
==============================================================================
--- head/usr.sbin/timed/timed/measure.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/usr.sbin/timed/timed/measure.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -128,7 +128,7 @@ measure(maxmsec, wmsec, hname, addr, pri
 
 	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, pri
 
 	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, pri
 			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;
 

Modified: head/usr.sbin/timed/timed/readmsg.c
==============================================================================
--- head/usr.sbin/timed/timed/readmsg.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/usr.sbin/timed/timed/readmsg.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -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) {

Modified: head/usr.sbin/timed/timed/slave.c
==============================================================================
--- head/usr.sbin/timed/timed/slave.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/usr.sbin/timed/timed/slave.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -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;

Modified: head/usr.sbin/timed/timed/timed.c
==============================================================================
--- head/usr.sbin/timed/timed/timed.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/usr.sbin/timed/timed/timed.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -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));
 }
 

Modified: head/usr.sbin/timed/timedc/cmds.c
==============================================================================
--- head/usr.sbin/timed/timedc/cmds.c	Sat Sep  1 11:24:02 2012	(r239990)
+++ head/usr.sbin/timed/timedc/cmds.c	Sat Sep  1 14:45:15 2012	(r239991)
@@ -131,7 +131,7 @@ daydiff(hostname)
 			}
 			sec -= BU;
 
-			(void)gettimeofday(&now, (struct timezone*)0);
+			(void)gettimeofday(&now, NULL);
 			return (sec - now.tv_sec);
 		}
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201209011445.q81EjF2j025306>