diff options
author | ed <ed@FreeBSD.org> | 2012-09-01 14:45:15 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2012-09-01 14:45:15 +0000 |
commit | 02dcf28b5875df173bef8c14a9ddd3d3ce67c5d4 (patch) | |
tree | 496a0b9a3b14c27d50e1ae3b28265ecf5c2023f2 /bin/date | |
parent | a6edc1e4b7ca5750cf84fb6a6b048b796c0cc77f (diff) | |
download | FreeBSD-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 'bin/date')
-rw-r--r-- | bin/date/date.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/bin/date/date.c b/bin/date/date.c index 1e9f281..58a9afb 100644 --- a/bin/date/date.c +++ b/bin/date/date.c @@ -137,7 +137,7 @@ main(int argc, char *argv[]) * If -d or -t, set the timezone or daylight savings time; this * doesn't belong here; the kernel should not know about either. */ - if (set_timezone && settimeofday((struct timeval *)NULL, &tz)) + if (set_timezone && settimeofday(NULL, &tz) != 0) err(1, "settimeofday (timezone)"); if (!rflag && time(&tval) == -1) @@ -273,14 +273,14 @@ setthetime(const char *fmt, const char *p, int jflag, int nflag) /* set the time */ if (nflag || netsettime(tval)) { utx.ut_type = OLD_TIME; - gettimeofday(&utx.ut_tv, NULL); + (void)gettimeofday(&utx.ut_tv, NULL); pututxline(&utx); tv.tv_sec = tval; tv.tv_usec = 0; - if (settimeofday(&tv, (struct timezone *)NULL)) + if (settimeofday(&tv, NULL) != 0) err(1, "settimeofday (timeval)"); utx.ut_type = NEW_TIME; - gettimeofday(&utx.ut_tv, NULL); + (void)gettimeofday(&utx.ut_tv, NULL); pututxline(&utx); } |