1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-11 16:58:40 +03:00

lib: Remove timeval_until()

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>
This commit is contained in:
Volker Lendecke 2024-03-13 16:07:00 +01:00 committed by Andrew Bartlett
parent 842e737843
commit a3e186b617
4 changed files with 4 additions and 34 deletions

View 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",

View 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
*/

View 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
*/

View 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,