This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
Re: [PATCH] Comparing tv_sec in event-loop.c
- To: Eli Zaretskii <eliz at delorie dot com>
- Subject: Re: [PATCH] Comparing tv_sec in event-loop.c
- From: Elena Zannoni <ezannoni at cygnus dot com>
- Date: Mon, 6 Mar 2000 12:07:44 -0500 (EST)
- Cc: gdb-patches at sourceware dot cygnus dot com, ezannoni at cygnus dot com
- References: <200003050841.DAA10174@indy.delorie.com>
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;