mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
As we only use the .tv_sec field, simplify gettimeofday(2) -> time(3).
ok tb@ jca@
This commit is contained in:
parent
5eb87a29ca
commit
1dfeccb761
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: pom.c,v 1.25 2016/12/01 20:08:59 fcambus Exp $ */
|
||||
/* $OpenBSD: pom.c,v 1.26 2017/12/23 20:53:07 cheloha Exp $ */
|
||||
/* $NetBSD: pom.c,v 1.6 1996/02/06 22:47:29 jtc Exp $ */
|
||||
|
||||
/*
|
||||
@ -44,7 +44,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <math.h>
|
||||
@ -73,8 +72,6 @@ __dead void badformat(void);
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
struct timeval tp;
|
||||
struct timezone tzp;
|
||||
struct tm *GMT;
|
||||
time_t tmpt;
|
||||
double days, today, tomorrow;
|
||||
@ -89,11 +86,8 @@ main(int argc, char *argv[])
|
||||
strftime(buf, sizeof(buf), "%a %Y %b %e %H:%M:%S (%Z)",
|
||||
localtime(&tmpt));
|
||||
printf("%s: ", buf);
|
||||
} else {
|
||||
if (gettimeofday(&tp,&tzp))
|
||||
err(1, "gettimeofday");
|
||||
tmpt = tp.tv_sec;
|
||||
}
|
||||
} else
|
||||
tmpt = time(NULL);
|
||||
GMT = gmtime(&tmpt);
|
||||
days = (GMT->tm_yday + 1) + ((GMT->tm_hour +
|
||||
(GMT->tm_min / 60.0) + (GMT->tm_sec / 3600.0)) / 24.0);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: pr.c,v 1.40 2017/11/02 09:52:04 jca Exp $ */
|
||||
/* $OpenBSD: pr.c,v 1.41 2017/12/23 20:53:07 cheloha Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991 Keith Muller.
|
||||
@ -34,7 +34,6 @@
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <ctype.h>
|
||||
@ -45,6 +44,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "pr.h"
|
||||
@ -1442,7 +1442,6 @@ FILE *
|
||||
nxtfile(int argc, char *argv[], char **fname, char *buf, int dt)
|
||||
{
|
||||
FILE *inf = NULL;
|
||||
struct timeval tv;
|
||||
struct tm *timeptr = NULL;
|
||||
struct stat statbuf;
|
||||
time_t curtime;
|
||||
@ -1463,14 +1462,7 @@ nxtfile(int argc, char *argv[], char **fname, char *buf, int dt)
|
||||
*fname = FNAME;
|
||||
if (nohead)
|
||||
return(inf);
|
||||
if (gettimeofday(&tv, NULL) < 0) {
|
||||
++errcnt;
|
||||
ferrout("pr: cannot get time of day, %s\n",
|
||||
strerror(errno));
|
||||
eoptind = argc - 1;
|
||||
return(NULL);
|
||||
}
|
||||
curtime = tv.tv_sec;
|
||||
curtime = time(NULL);;
|
||||
timeptr = localtime(&curtime);
|
||||
}
|
||||
for (; eoptind < argc; ++eoptind) {
|
||||
@ -1487,13 +1479,7 @@ nxtfile(int argc, char *argv[], char **fname, char *buf, int dt)
|
||||
++eoptind;
|
||||
if (nohead || (dt && twice))
|
||||
return(inf);
|
||||
if (gettimeofday(&tv, NULL) < 0) {
|
||||
++errcnt;
|
||||
ferrout("pr: cannot get time of day, %s\n",
|
||||
strerror(errno));
|
||||
return(NULL);
|
||||
}
|
||||
curtime = tv.tv_sec;
|
||||
curtime = time(NULL);
|
||||
timeptr = localtime(&curtime);
|
||||
} else {
|
||||
/*
|
||||
@ -1518,13 +1504,7 @@ nxtfile(int argc, char *argv[], char **fname, char *buf, int dt)
|
||||
return(inf);
|
||||
|
||||
if (dt) {
|
||||
if (gettimeofday(&tv, NULL) < 0) {
|
||||
++errcnt;
|
||||
ferrout("pr: cannot get time of day, %s\n",
|
||||
strerror(errno));
|
||||
return(NULL);
|
||||
}
|
||||
curtime = tv.tv_sec;
|
||||
curtime = time(NULL);
|
||||
timeptr = localtime(&curtime);
|
||||
} else {
|
||||
if (fstat(fileno(inf), &statbuf) < 0) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: arp.c,v 1.79 2017/04/19 05:36:12 natano Exp $ */
|
||||
/* $OpenBSD: arp.c,v 1.80 2017/12/23 20:53:07 cheloha Exp $ */
|
||||
/* $NetBSD: arp.c,v 1.12 1995/04/24 13:25:18 cgd Exp $ */
|
||||
|
||||
/*
|
||||
@ -40,7 +40,6 @@
|
||||
#include <sys/file.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/bpf.h>
|
||||
#include <net/if.h>
|
||||
@ -57,6 +56,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <paths.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
@ -297,10 +297,7 @@ set(int argc, char *argv[])
|
||||
doing_proxy = flags = export_only = 0;
|
||||
while (argc-- > 0) {
|
||||
if (strncmp(argv[0], "temp", 4) == 0) {
|
||||
struct timeval now;
|
||||
|
||||
gettimeofday(&now, 0);
|
||||
expire_time = now.tv_sec + 20 * 60;
|
||||
expire_time = time(NULL) + 20 * 60;
|
||||
if (flags & RTF_PERMANENT_ARP) {
|
||||
/* temp or permanent, not both */
|
||||
usage();
|
||||
@ -526,9 +523,9 @@ print_entry(struct sockaddr_dl *sdl, struct sockaddr_inarp *sin,
|
||||
char ifix_buf[IFNAMSIZ], *ifname, *host;
|
||||
struct hostent *hp = NULL;
|
||||
int addrwidth, llwidth, ifwidth ;
|
||||
struct timeval now;
|
||||
time_t now;
|
||||
|
||||
gettimeofday(&now, 0);
|
||||
now = time(NULL);
|
||||
|
||||
if (nflag == 0)
|
||||
hp = gethostbyaddr((caddr_t)&(sin->sin_addr),
|
||||
@ -558,9 +555,9 @@ print_entry(struct sockaddr_dl *sdl, struct sockaddr_inarp *sin,
|
||||
printf(" %-9.9s", "permanent");
|
||||
else if (rtm->rtm_rmx.rmx_expire == 0)
|
||||
printf(" %-9.9s", "static");
|
||||
else if (rtm->rtm_rmx.rmx_expire > now.tv_sec)
|
||||
else if (rtm->rtm_rmx.rmx_expire > now)
|
||||
printf(" %-9.9s",
|
||||
sec2str(rtm->rtm_rmx.rmx_expire - now.tv_sec));
|
||||
sec2str(rtm->rtm_rmx.rmx_expire - now));
|
||||
else
|
||||
printf(" %-9.9s", "expired");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user