[PATCH] Comparing tv_sec in event-loop.c
Elena Zannoni
ezannoni@cygnus.com
Mon Mar 6 09:07:00 GMT 2000
Thanks,
I have committed this to sourceware.
Elena
Eli Zaretskii writes:
>
> While working on the select-related changes, I've found a case of
> mixing signed and unsigned which could really bite someone. (In
> DJGPP, time_t is unsigned, so the compiler complained.)
>
> Here's the patch:
>
>
> 2000-03-04 Eli Zaretskii <eliz@is.elta.co.il>
>
> * event-loop.c (poll_timers): Don't compare delta.tv_sec with
> zero, since time_t might be unsigned.
>
>
> --- gdb/event-loop.c~0 Mon Feb 21 18:17:16 2000
> +++ gdb/event-loop.c Sat Mar 4 14:38:28 2000
> @@ -1114,8 +1105,11 @@ poll_timers (void)
> }
>
> /* Oops it expired already. Tell select / poll to return
> - immediately. */
> - if (delta.tv_sec < 0)
> + immediately. (Cannot simply test if delta.tv_sec is negative
> + because time_t might be unsigned.) */
> + if (timer_list.first_timer->when.tv_sec < time_now.tv_sec
> + || (timer_list.first_timer->when.tv_sec == time_now.tv_sec
> + && timer_list.first_timer->when.tv_usec < time_now.tv_usec))
> {
> delta.tv_sec = 0;
> delta.tv_usec = 0;
More information about the Gdb-patches
mailing list