From 24742988183dcde580f2ff0832bb5c25e648798e Mon Sep 17 00:00:00 2001 From: cheloha Date: Sat, 23 Dec 2017 20:53:08 +0000 Subject: As we only use the .tv_sec field, simplify gettimeofday(2) -> time(3). ok tb@ jca@ --- usr.bin/pr/pr.c | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) (limited to 'usr.bin/pr') diff --git a/usr.bin/pr/pr.c b/usr.bin/pr/pr.c index 08941e13d16..0342df907aa 100644 --- a/usr.bin/pr/pr.c +++ b/usr.bin/pr/pr.c @@ -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 -#include #include #include @@ -45,6 +44,7 @@ #include #include #include +#include #include #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) { -- cgit v1.2.3