summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/lock/lock.c33
-rw-r--r--usr.bin/mail/util.c2
-rw-r--r--usr.bin/systat/ifstat.c3
-rw-r--r--usr.bin/time/time.c6
4 files changed, 20 insertions, 24 deletions
diff --git a/usr.bin/lock/lock.c b/usr.bin/lock/lock.c
index 3f23a98..0382e83 100644
--- a/usr.bin/lock/lock.c
+++ b/usr.bin/lock/lock.c
@@ -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);
}
}
diff --git a/usr.bin/mail/util.c b/usr.bin/mail/util.c
index c90fe90..4e3a0f6 100644
--- a/usr.bin/mail/util.c
+++ b/usr.bin/mail/util.c
@@ -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);
diff --git a/usr.bin/systat/ifstat.c b/usr.bin/systat/ifstat.c
index fc853b0..3e45499 100644
--- a/usr.bin/systat/ifstat.c
+++ b/usr.bin/systat/ifstat.c
@@ -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;
diff --git a/usr.bin/time/time.c b/usr.bin/time/time.c
index 2cb7f13..ebee542 100644
--- a/usr.bin/time/time.c
+++ b/usr.bin/time/time.c
@@ -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);
}
OpenPOWER on IntegriCloud