lib: Remove timeval_until()
authorVolker Lendecke <vl@samba.org>
Wed, 13 Mar 2024 15:07:00 +0000 (16:07 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 22 Mar 2024 05:03:35 +0000 (05:03 +0000)
We have the same function in tevent, no need to duplicate code.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
ctdb/server/ctdb_daemon.c
lib/util/time.c
lib/util/time.h
source4/torture/rpc/echo.c

index 0a53770a6bf35406a74df6be2cc3662d9af98bbe..c5dd1ed60aabee58516030b7ec143d7b14f396ab 100644 (file)
@@ -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",
index a47af20a35010341c1279cbcca88c7ca76809200..fe2a2b499f5e7b8dc57ba436fbcbc1dd11c96d34 100644 (file)
@@ -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
 */
index bfbd1b811dd3470a0e4fde1d2e2af3d7fdb94f8b..cc4fd98771c6e3e6fd413c045a53cbadadd088e6 100644 (file)
@@ -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
 */
index 93fd408afcd0a151a7fcf9aea08403cf2880d258..15ad299535dff9f388d30195d8cfdb780fed7bff 100644 (file)
@@ -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,