This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [PATCH] Comparing tv_sec in event-loop.c



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;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]