summaryrefslogtreecommitdiffstats
path: root/usr.bin/dig/lib
diff options
context:
space:
mode:
authorflorian <florian@openbsd.org>2020-02-16 21:08:59 +0000
committerflorian <florian@openbsd.org>2020-02-16 21:08:59 +0000
commitffbbf1a1ba5c66ebfe3fd67d17dc177d3d89b6a0 (patch)
treed20590b42a47b49932ecfeffff6a768a6b181bc1 /usr.bin/dig/lib
parentunravel isc_time_compare (diff)
downloadwireguard-openbsd-ffbbf1a1ba5c66ebfe3fd67d17dc177d3d89b6a0.tar.xz
wireguard-openbsd-ffbbf1a1ba5c66ebfe3fd67d17dc177d3d89b6a0.zip
unravel isc_time_add and isc_time_subtract
OK millert
Diffstat (limited to 'usr.bin/dig/lib')
-rw-r--r--usr.bin/dig/lib/isc/include/isc/timer.h8
-rw-r--r--usr.bin/dig/lib/isc/log.c14
-rw-r--r--usr.bin/dig/lib/isc/timer.c31
-rw-r--r--usr.bin/dig/lib/isc/unix/include/isc/time.h29
-rw-r--r--usr.bin/dig/lib/isc/unix/time.c23
5 files changed, 17 insertions, 88 deletions
diff --git a/usr.bin/dig/lib/isc/include/isc/timer.h b/usr.bin/dig/lib/isc/include/isc/timer.h
index 4941038ba65..1dc618598e1 100644
--- a/usr.bin/dig/lib/isc/include/isc/timer.h
+++ b/usr.bin/dig/lib/isc/include/isc/timer.h
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: timer.h,v 1.8 2020/02/16 18:05:09 florian Exp $ */
+/* $Id: timer.h,v 1.9 2020/02/16 21:08:59 florian Exp $ */
#ifndef ISC_TIMER_H
#define ISC_TIMER_H 1
@@ -228,7 +228,7 @@ isc_timer_reset(isc_timer_t *timer,
*\li Unexpected error
*/
-isc_result_t
+void
isc_timer_touch(isc_timer_t *timer);
/*%<
* Set the last-touched time of 'timer' to the current time.
@@ -243,10 +243,6 @@ isc_timer_touch(isc_timer_t *timer);
* timer's interval if 'timer' is a once timer with a non-zero
* interval.
*
- * Returns:
- *
- *\li Success
- *\li Unexpected error
*/
void
diff --git a/usr.bin/dig/lib/isc/log.c b/usr.bin/dig/lib/isc/log.c
index afdc560064e..00762a6d894 100644
--- a/usr.bin/dig/lib/isc/log.c
+++ b/usr.bin/dig/lib/isc/log.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: log.c,v 1.10 2020/02/16 21:08:15 florian Exp $ */
+/* $Id: log.c,v 1.11 2020/02/16 21:08:59 florian Exp $ */
/*! \file
* \author Principal Authors: DCL */
@@ -988,16 +988,8 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
* range.
*/
TIME_NOW(&oldest);
- if (isc_time_subtract(&oldest, &interval,
- &oldest)
- != ISC_R_SUCCESS)
- /*
- * Can't effectively do the checking
- * without having a valid time.
- */
- message = NULL;
- else
- message = ISC_LIST_HEAD(lctx->messages);
+ timespecsub(&oldest, &interval, &oldest);
+ message = ISC_LIST_HEAD(lctx->messages);
while (message != NULL) {
if (timespeccmp(&message->time,
diff --git a/usr.bin/dig/lib/isc/timer.c b/usr.bin/dig/lib/isc/timer.c
index 46ce142a111..8c4bf3a04d4 100644
--- a/usr.bin/dig/lib/isc/timer.c
+++ b/usr.bin/dig/lib/isc/timer.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: timer.c,v 1.16 2020/02/16 21:08:15 florian Exp $ */
+/* $Id: timer.c,v 1.17 2020/02/16 21:08:59 florian Exp $ */
/*! \file */
@@ -80,7 +80,7 @@ isc__timer_create(isc_timermgr_t *manager, const struct timespec *interval,
isc_result_t
isc__timer_reset(isc_timer_t *timer, const struct timespec *interval,
isc_boolean_t purge);
-isc_result_t
+void
isc__timer_touch(isc_timer_t *timer);
void
isc__timer_attach(isc_timer_t *timer0, isc_timer_t **timerp);
@@ -227,13 +227,8 @@ isc__timer_create(isc_timermgr_t *manager0, const struct timespec *interval,
timer->manager = manager;
timer->references = 1;
- if (timespecisset(interval)) {
- result = isc_time_add(&now, interval, &timer->idle);
- if (result != ISC_R_SUCCESS) {
- free(timer);
- return (result);
- }
- }
+ if (timespecisset(interval))
+ timespecadd(&now, interval, &timer->idle);
timer->interval = *interval;
timer->task = NULL;
@@ -306,23 +301,19 @@ isc__timer_reset(isc_timer_t *timer0, const struct timespec *interval,
NULL);
timer->interval = *interval;
if (timespecisset(interval)) {
- result = isc_time_add(&now, interval, &timer->idle);
+ timespecadd(&now, interval, &timer->idle);
} else {
timespecclear(&timer->idle);
- result = ISC_R_SUCCESS;
}
- if (result == ISC_R_SUCCESS) {
- result = schedule(timer, &now, ISC_TRUE);
- }
+ result = schedule(timer, &now, ISC_TRUE);
return (result);
}
-isc_result_t
+void
isc__timer_touch(isc_timer_t *timer0) {
isc__timer_t *timer = (isc__timer_t *)timer0;
- isc_result_t result;
struct timespec now;
/*
@@ -332,9 +323,7 @@ isc__timer_touch(isc_timer_t *timer0) {
REQUIRE(VALID_TIMER(timer));
TIME_NOW(&now);
- result = isc_time_add(&now, &timer->interval, &timer->idle);
-
- return (result);
+ timespecadd(&now, &timer->interval, &timer->idle);
}
void
@@ -623,9 +612,9 @@ isc_timer_reset(isc_timer_t *timer, const struct timespec *interval,
return (isc__timer_reset(timer, interval, purge));
}
-isc_result_t
+void
isc_timer_touch(isc_timer_t *timer) {
REQUIRE(ISCAPI_TIMER_VALID(timer));
- return (isc__timer_touch(timer));
+ isc__timer_touch(timer);
}
diff --git a/usr.bin/dig/lib/isc/unix/include/isc/time.h b/usr.bin/dig/lib/isc/unix/include/isc/time.h
index 686d54ed3ea..dda34713ae4 100644
--- a/usr.bin/dig/lib/isc/unix/include/isc/time.h
+++ b/usr.bin/dig/lib/isc/unix/include/isc/time.h
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: time.h,v 1.10 2020/02/16 21:08:15 florian Exp $ */
+/* $Id: time.h,v 1.11 2020/02/16 21:08:59 florian Exp $ */
#ifndef ISC_TIME_H
#define ISC_TIME_H 1
@@ -52,33 +52,6 @@ isc_time_now(struct timespec *t);
* Getting the time from the system failed.
*/
-isc_result_t
-isc_time_add(const struct timespec *t, const struct timespec *i, struct timespec *result);
-/*%<
- * Add 'i' to 't', storing the result in 'result'.
- *
- * Requires:
- *
- *\li 't', 'i', and 'result' are valid pointers.
- *
- * Returns:
- *\li Success
- */
-
-isc_result_t
-isc_time_subtract(const struct timespec *t, const struct timespec *i,
- struct timespec *result);
-/*%<
- * Subtract 'i' from 't', storing the result in 'result'.
- *
- * Requires:
- *
- *\li 't', 'i', and 'result' are valid pointers.
- *
- * Returns:
- *\li Success
- */
-
uint64_t
isc_time_microdiff(const struct timespec *t1, const struct timespec *t2);
/*%<
diff --git a/usr.bin/dig/lib/isc/unix/time.c b/usr.bin/dig/lib/isc/unix/time.c
index 4d63835291c..a0f60d032fd 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.13 2020/02/16 21:08:15 florian Exp $ */
+/* $Id: time.c,v 1.14 2020/02/16 21:08:59 florian Exp $ */
/*! \file */
@@ -58,27 +58,6 @@ isc_time_now(struct timespec *t) {
return (ISC_R_SUCCESS);
}
-isc_result_t
-isc_time_add(const struct timespec *t, const struct timespec *i, struct timespec *result)
-{
- REQUIRE(t != NULL && i != NULL && result != NULL);
- INSIST(t->tv_nsec < NS_PER_S && i->tv_nsec < NS_PER_S);
-
- timespecadd(t, i, result);
- return (ISC_R_SUCCESS);
-}
-
-isc_result_t
-isc_time_subtract(const struct timespec *t, const struct timespec *i,
- struct timespec *result)
-{
- REQUIRE(t != NULL && i != NULL && result != NULL);
- INSIST(t->tv_nsec < NS_PER_S && i->tv_nsec < NS_PER_S);
-
- timespecsub(t, i, result);
- return (ISC_R_SUCCESS);
-}
-
uint64_t
isc_time_microdiff(const struct timespec *t1, const struct timespec *t2) {
struct timespec res;