* [PATCH] fix potential 32bits truncation for result of timespec/timeval_compare()
@ 2012-06-21 6:53 Li Yu
0 siblings, 0 replies; only message in thread
From: Li Yu @ 2012-06-21 6:53 UTC (permalink / raw)
To: Linux Kernel Mailing List
The tv_nsec field of timespec struct and tv_usec field of timeval
struct are defined as long type, but two comparison API return int
type of result value, this may result in wrong result.
This simple patch fixed it, thanks
Signed-off-by: Li Yu <bingtian.ly@taobao.com>
diff --git a/include/linux/time.h b/include/linux/time.h
index 179f4d6..be381f6 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -53,7 +53,7 @@ static inline int timespec_equal(const struct timespec *a,
* lhs == rhs: return 0
* lhs > rhs: return >0
*/
-static inline int timespec_compare(const struct timespec *lhs, const
struct timespec *rhs)
+static inline long timespec_compare(const struct timespec *lhs, const
struct timespec *rhs)
{
if (lhs->tv_sec < rhs->tv_sec)
return -1;
@@ -62,7 +62,7 @@ static inline int timespec_compare(const struct
timespec *lhs, const struct time
return lhs->tv_nsec - rhs->tv_nsec;
}
-static inline int timeval_compare(const struct timeval *lhs, const
struct timeval *rhs)
+static inline long timeval_compare(const struct timeval *lhs, const
struct timeval *rhs)
{
if (lhs->tv_sec < rhs->tv_sec)
return -1;
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2012-06-21 6:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-21 6:53 [PATCH] fix potential 32bits truncation for result of timespec/timeval_compare() Li Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox