[PATCH 1/4] stat: fix portability problem in stat_time_t declaration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Assure stat_time_t is 64 bit on all architectures.
long is not 64 bit on 32 bit systems so use uint64_t intead.
Also avoid 32 bit overflows for such architectures.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/stat.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/server/stat.h b/server/stat.h
index 3c980d0..da432eb 100644
--- a/server/stat.h
+++ b/server/stat.h
@@ -43,14 +43,14 @@ void stat_remove_counter(uint64_t *counter);
 #define stat_inc_counter(c, v)
 #endif /* RED_STATISTICS */
 
-typedef unsigned long stat_time_t;
+typedef uint64_t stat_time_t;
 
 static inline stat_time_t stat_now(clockid_t clock_id)
 {
     struct timespec ts;
 
     clock_gettime(clock_id, &ts);
-    return ts.tv_nsec + ts.tv_sec * 1000 * 1000 * 1000;
+    return ts.tv_nsec + (uint64_t) ts.tv_sec * (1000 * 1000 * 1000);
 }
 
 static inline double stat_cpu_time_to_sec(stat_time_t time)
-- 
2.4.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]