summaryrefslogtreecommitdiff
path: root/usr.bin/dig
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2020-02-13 08:19:13 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2020-02-13 08:19:13 +0000
commitaca6aeff4d9c85779b080fd00d78d1fc22795a2d (patch)
tree2849de2e0597b200fecb9e1dbf9514ea1958a79c /usr.bin/dig
parentffb71c28d76aa0c077c14342631595dce515f737 (diff)
trust gettimeofday doing the right thing
Diffstat (limited to 'usr.bin/dig')
-rw-r--r--usr.bin/dig/lib/isc/unix/stdtime.c41
-rw-r--r--usr.bin/dig/lib/isc/unix/time.c49
2 files changed, 2 insertions, 88 deletions
diff --git a/usr.bin/dig/lib/isc/unix/stdtime.c b/usr.bin/dig/lib/isc/unix/stdtime.c
index b2a172f87a6..2f9d94c50f6 100644
--- a/usr.bin/dig/lib/isc/unix/stdtime.c
+++ b/usr.bin/dig/lib/isc/unix/stdtime.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: stdtime.c,v 1.2 2020/02/11 23:26:12 jsg Exp $ */
+/* $Id: stdtime.c,v 1.3 2020/02/13 08:19:12 florian Exp $ */
/*! \file */
@@ -28,38 +28,6 @@
#include <isc/stdtime.h>
#include <isc/util.h>
-#ifndef ISC_FIX_TV_USEC
-#define ISC_FIX_TV_USEC 1
-#endif
-
-#define US_PER_S 1000000
-
-#if ISC_FIX_TV_USEC
-static inline void
-fix_tv_usec(struct timeval *tv) {
- isc_boolean_t fixed = ISC_FALSE;
-
- if (tv->tv_usec < 0) {
- fixed = ISC_TRUE;
- do {
- tv->tv_sec -= 1;
- tv->tv_usec += US_PER_S;
- } while (tv->tv_usec < 0);
- } else if (tv->tv_usec >= US_PER_S) {
- fixed = ISC_TRUE;
- do {
- tv->tv_sec += 1;
- tv->tv_usec -= US_PER_S;
- } while (tv->tv_usec >=US_PER_S);
- }
- /*
- * Call syslog directly as we are called from the logging functions.
- */
- if (fixed)
- (void)syslog(LOG_ERR, "gettimeofday returned bad tv_usec: corrected");
-}
-#endif
-
void
isc_stdtime_get(isc_stdtime_t *t) {
struct timeval tv;
@@ -73,12 +41,5 @@ isc_stdtime_get(isc_stdtime_t *t) {
RUNTIME_CHECK(gettimeofday(&tv, NULL) != -1);
-#if ISC_FIX_TV_USEC
- fix_tv_usec(&tv);
- INSIST(tv.tv_usec >= 0);
-#else
- INSIST(tv.tv_usec >= 0 && tv.tv_usec < US_PER_S);
-#endif
-
*t = (unsigned int)tv.tv_sec;
}
diff --git a/usr.bin/dig/lib/isc/unix/time.c b/usr.bin/dig/lib/isc/unix/time.c
index f0f65a9b54c..6de63f3820d 100644
--- a/usr.bin/dig/lib/isc/unix/time.c
+++ b/usr.bin/dig/lib/isc/unix/time.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: time.c,v 1.3 2020/02/12 13:05:04 jsg Exp $ */
+/* $Id: time.c,v 1.4 2020/02/13 08:19:12 florian Exp $ */
/*! \file */
@@ -38,7 +38,6 @@
#define NS_PER_S 1000000000 /*%< Nanoseconds per second. */
#define NS_PER_US 1000 /*%< Nanoseconds per microsecond. */
-#define US_PER_S 1000000 /*%< Microseconds per second. */
/*
* All of the INSIST()s checks of nanoseconds < NS_PER_S are for
@@ -47,10 +46,6 @@
* need an initialized type.
*/
-#ifndef ISC_FIX_TV_USEC
-#define ISC_FIX_TV_USEC 1
-#endif
-
/*%
*** Intervals
***/
@@ -58,32 +53,6 @@
static const interval_t zero_interval = { 0, 0 };
const interval_t * const interval_zero = &zero_interval;
-#if ISC_FIX_TV_USEC
-static inline void
-fix_tv_usec(struct timeval *tv) {
- isc_boolean_t fixed = ISC_FALSE;
-
- if (tv->tv_usec < 0) {
- fixed = ISC_TRUE;
- do {
- tv->tv_sec -= 1;
- tv->tv_usec += US_PER_S;
- } while (tv->tv_usec < 0);
- } else if (tv->tv_usec >= US_PER_S) {
- fixed = ISC_TRUE;
- do {
- tv->tv_sec += 1;
- tv->tv_usec -= US_PER_S;
- } while (tv->tv_usec >=US_PER_S);
- }
- /*
- * Call syslog directly as was are called from the logging functions.
- */
- if (fixed)
- (void)syslog(LOG_ERR, "gettimeofday returned bad tv_usec: corrected");
-}
-#endif
-
void
interval_set(interval_t *i,
unsigned int seconds, unsigned int nanoseconds)
@@ -157,22 +126,6 @@ isc_time_now(isc_time_t *t) {
}
/*
- * Does POSIX guarantee the signedness of tv_sec and tv_usec? If not,
- * then this test will generate warnings for platforms on which it is
- * unsigned. In any event, the chances of any of these problems
- * happening are pretty much zero, but since the libisc library ensures
- * certain things to be true ...
- */
-#if ISC_FIX_TV_USEC
- fix_tv_usec(&tv);
- if (tv.tv_sec < 0)
- return (ISC_R_UNEXPECTED);
-#else
- if (tv.tv_sec < 0 || tv.tv_usec < 0 || tv.tv_usec >= US_PER_S)
- return (ISC_R_UNEXPECTED);
-#endif
-
- /*
* Ensure the tv_sec value fits in t->seconds.
*/
if (sizeof(tv.tv_sec) > sizeof(t->seconds) &&