Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Feb 2010 13:47:51 +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: r204358 - head/usr.bin/pr
Message-ID:  <201002261347.o1QDlpNT056130@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Fri Feb 26 13:47:51 2010
New Revision: 204358
URL: http://svn.freebsd.org/changeset/base/204358

Log:
  Use time(NULL) instead of gettimeofday(), because we only need tv_sec.

Modified:
  head/usr.bin/pr/pr.c

Modified: head/usr.bin/pr/pr.c
==============================================================================
--- head/usr.bin/pr/pr.c	Fri Feb 26 12:40:01 2010	(r204357)
+++ head/usr.bin/pr/pr.c	Fri Feb 26 13:47:51 2010	(r204358)
@@ -1265,9 +1265,7 @@ FILE *
 nxtfile(int argc, char **argv, const char **fname, char *buf, int dt)
 {
 	FILE *inf = NULL;
-	struct timeval tv;
 	time_t tv_sec;
-	struct timezone tz;
 	struct tm *timeptr = NULL;
 	struct stat statbuf;
 	static int twice = -1;
@@ -1287,14 +1285,13 @@ nxtfile(int argc, char **argv, const cha
 			*fname = fnamedefault;
 		if (nohead)
 			return(inf);
-		if (gettimeofday(&tv, &tz) < 0) {
+		if ((tv_sec = time(NULL)) == -1) {
 			++errcnt;
 			(void)fprintf(err, "pr: cannot get time of day, %s\n",
 				strerror(errno));
 			eoptind = argc - 1;
 			return(NULL);
 		}
-		tv_sec = tv.tv_sec;
 		timeptr = localtime(&tv_sec);
 	}
 	for (; eoptind < argc; ++eoptind) {
@@ -1311,14 +1308,13 @@ nxtfile(int argc, char **argv, const cha
 			++eoptind;
 			if (nohead || (dt && twice))
 				return(inf);
-			if (gettimeofday(&tv, &tz) < 0) {
+			if ((tv_sec = time(NULL)) == -1) {
 				++errcnt;
 				(void)fprintf(err,
 					"pr: cannot get time of day, %s\n",
 					strerror(errno));
 				return(NULL);
 			}
-			tv_sec = tv.tv_sec;
 			timeptr = localtime(&tv_sec);
 		} else {
 			/*
@@ -1343,14 +1339,13 @@ nxtfile(int argc, char **argv, const cha
 				return(inf);
 
 			if (dt) {
-				if (gettimeofday(&tv, &tz) < 0) {
+				if ((tv_sec = time(NULL)) == -1) {
 					++errcnt;
 					(void)fprintf(err,
 					     "pr: cannot get time of day, %s\n",
 					     strerror(errno));
 					return(NULL);
 				}
-				tv_sec = tv.tv_sec;
 				timeptr = localtime(&tv_sec);
 			} else {
 				if (fstat(fileno(inf), &statbuf) < 0) {



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