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 /usr.sbin/inetd/builtins.c | |
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 'usr.sbin/inetd/builtins.c')
-rw-r--r-- | usr.sbin/inetd/builtins.c | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/usr.sbin/inetd/builtins.c b/usr.sbin/inetd/builtins.c index 974e54f..3ccdab0 100644 --- a/usr.sbin/inetd/builtins.c +++ b/usr.sbin/inetd/builtins.c @@ -691,15 +691,9 @@ printit: uint32_t machtime(void) { - struct timeval tv; - if (gettimeofday(&tv, (struct timezone *)NULL) < 0) { - if (debug) - warnx("unable to get time of day"); - return (0L); - } #define OFFSET ((uint32_t)25567 * 24*60*60) - return (htonl((uint32_t)(tv.tv_sec + OFFSET))); + return (htonl((uint32_t)(time(NULL) + OFFSET))); #undef OFFSET } |