From: Volker Lendecke Date: Wed, 13 Mar 2024 15:07:00 +0000 (+0100) Subject: lib: Remove timeval_until() X-Git-Tag: tdb-1.4.11~1375 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3e186b61719cd0e1ec60006d7ea675c01d69c36;p=thirdparty%2Fsamba.git lib: Remove timeval_until() We have the same function in tevent, no need to duplicate code. Signed-off-by: Volker Lendecke Reviewed-by: Andrew Bartlett --- diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c index 0a53770a6bf..c5dd1ed60aa 100644 --- a/ctdb/server/ctdb_daemon.c +++ b/ctdb/server/ctdb_daemon.c @@ -1331,7 +1331,7 @@ static void ctdb_tevent_trace(enum tevent_trace_point tp, switch (tp) { case TEVENT_TRACE_BEFORE_WAIT: - diff = timeval_until(&tevent_after_wait_ts, &now); + diff = tevent_timeval_until(&tevent_after_wait_ts, &now); if (diff.tv_sec > 3) { DEBUG(DEBUG_ERR, ("Handling event took %ld seconds!\n", @@ -1341,7 +1341,7 @@ static void ctdb_tevent_trace(enum tevent_trace_point tp, break; case TEVENT_TRACE_AFTER_WAIT: - diff = timeval_until(&tevent_before_wait_ts, &now); + diff = tevent_timeval_until(&tevent_before_wait_ts, &now); if (diff.tv_sec > 3) { DEBUG(DEBUG_ERR, ("No event for %ld seconds!\n", diff --git a/lib/util/time.c b/lib/util/time.c index a47af20a350..fe2a2b499f5 100644 --- a/lib/util/time.c +++ b/lib/util/time.c @@ -766,29 +766,6 @@ _PUBLIC_ struct timeval timeval_max(const struct timeval *tv1, return *tv2; } -/** - return the difference between two timevals as a timeval - if tv1 comes after tv2, then return a zero timeval - (this is *tv2 - *tv1) -*/ -_PUBLIC_ struct timeval timeval_until(const struct timeval *tv1, - const struct timeval *tv2) -{ - struct timeval t; - if (timeval_compare(tv1, tv2) >= 0) { - return timeval_zero(); - } - t.tv_sec = tv2->tv_sec - tv1->tv_sec; - if (tv1->tv_usec > tv2->tv_usec) { - t.tv_sec--; - t.tv_usec = 1000000 - (tv1->tv_usec - tv2->tv_usec); - } else { - t.tv_usec = tv2->tv_usec - tv1->tv_usec; - } - return t; -} - - /** convert a timeval to a NTTIME */ diff --git a/lib/util/time.h b/lib/util/time.h index bfbd1b811dd..cc4fd98771c 100644 --- a/lib/util/time.h +++ b/lib/util/time.h @@ -317,14 +317,6 @@ struct timeval timeval_min(const struct timeval *tv1, struct timeval timeval_max(const struct timeval *tv1, const struct timeval *tv2); -/** - return the difference between two timevals as a timeval - if tv1 comes after tv2, then return a zero timeval - (this is *tv2 - *tv1) -*/ -struct timeval timeval_until(const struct timeval *tv1, - const struct timeval *tv2); - /** convert a timeval to a NTTIME */ diff --git a/source4/torture/rpc/echo.c b/source4/torture/rpc/echo.c index 93fd408afcd..15ad299535d 100644 --- a/source4/torture/rpc/echo.c +++ b/source4/torture/rpc/echo.c @@ -281,7 +281,8 @@ static bool test_sleep(struct torture_context *tctx, total_done++; done2[i] = true; rcv[i] = timeval_current(); - diff[i] = timeval_until(&snd[i], &rcv[i]); + diff[i] = tevent_timeval_until( + &snd[i], &rcv[i]); rounded_tdiff = (int)(0.5 + diff[i].tv_sec + (1.0e-6*diff[i].tv_usec)); torture_comment(tctx, "rounded_tdiff=%d\n", rounded_tdiff); torture_assert_ntstatus_ok(tctx,