summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2012-09-01 14:45:15 +0000
committered <ed@FreeBSD.org>2012-09-01 14:45:15 +0000
commit02dcf28b5875df173bef8c14a9ddd3d3ce67c5d4 (patch)
tree496a0b9a3b14c27d50e1ae3b28265ecf5c2023f2 /libexec
parenta6edc1e4b7ca5750cf84fb6a6b048b796c0cc77f (diff)
downloadFreeBSD-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.
Diffstat (limited to 'libexec')
-rw-r--r--libexec/rbootd/rbootd.c7
-rw-r--r--libexec/rbootd/rmpproto.c2
-rw-r--r--libexec/rpc.rstatd/rstat_proc.c7
3 files changed, 8 insertions, 8 deletions
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);
}
OpenPOWER on IntegriCloud