]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: time: adapt the type of TV_ETERNITY to the local system
authorWilly Tarreau <w@1wt.eu>
Fri, 13 Dec 2013 08:22:23 +0000 (09:22 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 13 Dec 2013 08:22:23 +0000 (09:22 +0100)
Some systems use different types for tv_sec/tv_usec, some are
signed others not. From time to time new warnings are reported
about implicit casts being done.

This patch ensures that TV_ETERNITY is cast to the appropriate
type in assignments and conversions.

include/common/time.h

index 5d86ad53ed04199927c1166f2db5433075d890f2..8be47188a697509582e63733ff4cdc12db64636e 100644 (file)
@@ -108,7 +108,8 @@ REGPRM2 void tv_update_date(int max_wait, int interrupted);
  */
 REGPRM1 static inline struct timeval *tv_eternity(struct timeval *tv)
 {
-       tv->tv_sec = tv->tv_usec = TV_ETERNITY;
+       tv->tv_sec  = (typeof(tv->tv_sec))TV_ETERNITY;
+       tv->tv_usec = (typeof(tv->tv_usec))TV_ETERNITY;
        return tv;
 }
 
@@ -124,12 +125,12 @@ REGPRM1 static inline struct timeval *tv_zero(struct timeval *tv) {
 /*
  * returns non null if tv is [eternity], otherwise 0.
  */
-#define tv_iseternity(tv)       ((tv)->tv_usec == TV_ETERNITY)
+#define tv_iseternity(tv)       ((tv)->tv_usec == (typeof((tv)->tv_usec))TV_ETERNITY)
 
 /*
  * returns 0 if tv is [eternity], otherwise non-zero.
  */
-#define tv_isset(tv)       ((tv)->tv_usec != TV_ETERNITY)
+#define tv_isset(tv)       ((tv)->tv_usec != (typeof((tv)->tv_usec))TV_ETERNITY)
 
 /*
  * returns non null if tv is [0], otherwise 0.