2008-08-25 pmccurdy * Make all time values signed longs instead of a mix of signed and unsigned, to avoid compiler complaints. * check_timeout() tries to use some unsigned long variables to perform some intermediate calculations, then has to cast back to signed long. As it happens, there's no real chance of overflowing a signed long (it'll only happen if the current time is within 49.7 days of rolling over, at which point you're already pretty doomed), so we can make the calculations a bit simpler, and also avoid the mixed-signedness arithmetic we'd otherwise need to do. diff -rpuN --exclude .depend --exclude '*~' --exclude '*.orig' --exclude '*.rej' --exclude '*.l[oa]' --exclude '*.lai' --exclude '*.o' --exclude .deps --exclude .libs --exclude Makefile --exclude 'stamp-*' --exclude messagebus --exclude rc.messagebus --exclude session.conf --exclude system.conf --exclude config.h --exclude config.log --exclude config.status --exclude dbus-1.pc --exclude Doxyfile --exclude libtool --exclude data ../.build_orig/dbus/dbus/dbus-mainloop.c dbus/dbus/dbus-mainloop.c --- ../.build_orig/dbus/dbus/dbus-mainloop.c 2008-05-08 10:17:26.000000000 -0400 +++ dbus/dbus/dbus-mainloop.c 2008-08-25 03:12:39.000000000 -0400 @@ -90,8 +90,8 @@ typedef struct Callback callback; DBusTimeout *timeout; DBusTimeoutFunction function; - unsigned long last_tv_sec; - unsigned long last_tv_usec; + long last_tv_sec; + long last_tv_usec; } TimeoutCallback; #define WATCH_CALLBACK(callback) ((WatchCallback*)callback) @@ -370,15 +370,15 @@ _dbus_loop_remove_timeout (DBusLoop * to do this. */ static dbus_bool_t -check_timeout (unsigned long tv_sec, - unsigned long tv_usec, +check_timeout (long tv_sec, + long tv_usec, TimeoutCallback *tcb, int *timeout) { long sec_remaining; long msec_remaining; - unsigned long expiration_tv_sec; - unsigned long expiration_tv_usec; + long expiration_tv_sec; + long expiration_tv_usec; long interval_seconds; long interval_milliseconds; int interval; @@ -399,10 +399,7 @@ check_timeout (unsigned long tv_sec, } sec_remaining = expiration_tv_sec - tv_sec; - /* need to force this to be signed, as it is intended to sometimes - * produce a negative result - */ - msec_remaining = ((long) expiration_tv_usec - (long) tv_usec) / 1000L; + msec_remaining = (expiration_tv_usec - tv_usec) / 1000L; #if MAINLOOP_SPEW _dbus_verbose ("Interval is %ld seconds %ld msecs\n", @@ -640,8 +637,8 @@ _dbus_loop_iterate (DBusLoop *loop, timeout = -1; if (loop->timeout_count > 0) { - unsigned long tv_sec; - unsigned long tv_usec; + long tv_sec; + long tv_usec; _dbus_get_current_time (&tv_sec, &tv_usec); @@ -710,8 +707,8 @@ _dbus_loop_iterate (DBusLoop *loop, if (loop->timeout_count > 0) { - unsigned long tv_sec; - unsigned long tv_usec; + long tv_sec; + long tv_usec; _dbus_get_current_time (&tv_sec, &tv_usec);