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

r8886: Exchange the arguments of timeval_compare, this makes it behave like strcmp.

Volker
This commit is contained in:
Volker Lendecke 2005-08-01 17:31:40 +00:00 committed by Gerald (Jerry) Carter
parent 00ea1f38a3
commit 6f5bd76021
2 changed files with 10 additions and 9 deletions

View File

@ -311,7 +311,8 @@ static struct timed_event *std_event_add_timed(struct event_context *ev, TALLOC_
for (cur_te = std_ev->timed_events; cur_te; cur_te = cur_te->next) { for (cur_te = std_ev->timed_events; cur_te; cur_te = cur_te->next) {
/* if the new event comes before the current one break */ /* if the new event comes before the current one break */
if (!timeval_is_zero(&cur_te->next_event) && if (!timeval_is_zero(&cur_te->next_event) &&
timeval_compare(&cur_te->next_event, &te->next_event) < 0) { timeval_compare(&te->next_event,
&cur_te->next_event) < 0) {
break; break;
} }

View File

@ -497,16 +497,16 @@ struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs)
/* /*
compare two timeval structures. compare two timeval structures.
Return 1 if tv2 > tv1 Return -1 if tv1 < tv2
Return 0 if tv2 == tv1 Return 0 if tv1 == tv2
Return -1 if tv2 < tv1 Return 1 if tv1 > tv2
*/ */
int timeval_compare(const struct timeval *tv1, const struct timeval *tv2) int timeval_compare(const struct timeval *tv1, const struct timeval *tv2)
{ {
if (tv2->tv_sec > tv1->tv_sec) return 1; if (tv1->tv_sec > tv2->tv_sec) return 1;
if (tv2->tv_sec < tv1->tv_sec) return -1; if (tv1->tv_sec < tv2->tv_sec) return -1;
if (tv2->tv_usec > tv1->tv_usec) return 1; if (tv1->tv_usec > tv2->tv_usec) return 1;
if (tv2->tv_usec < tv1->tv_usec) return -1; if (tv1->tv_usec < tv2->tv_usec) return -1;
return 0; return 0;
} }
@ -572,7 +572,7 @@ struct timeval timeval_until(const struct timeval *tv1,
const struct timeval *tv2) const struct timeval *tv2)
{ {
struct timeval t; struct timeval t;
if (timeval_compare(tv2, tv1) >= 0) { if (timeval_compare(tv1, tv2) >= 0) {
return timeval_zero(); return timeval_zero();
} }
t.tv_sec = tv2->tv_sec - tv1->tv_sec; t.tv_sec = tv2->tv_sec - tv1->tv_sec;