projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'timespec_add_msec_overflow' of https://github.com/sitsofe/fio
[fio.git]
/
time.c
diff --git
a/time.c
b/time.c
index edfe779bc2423876e949be48b11fb3ed354af986..07984190d67a914173e1980f0ed0461b45ea5ee8 100644
(file)
--- a/
time.c
+++ b/
time.c
@@
-8,17
+8,17
@@
static unsigned long ns_granularity;
void timespec_add_msec(struct timespec *ts, unsigned int msec)
{
void timespec_add_msec(struct timespec *ts, unsigned int msec)
{
- u
nsigned long adj_nsec = 1000000
* msec;
+ u
int64_t adj_nsec = 1000000ULL
* msec;
ts->tv_nsec += adj_nsec;
if (adj_nsec >= 1000000000) {
ts->tv_nsec += adj_nsec;
if (adj_nsec >= 1000000000) {
- u
nsigned long adj_sec = adj_nsec / 1000000000UL
;
+ u
int64_t adj_sec = adj_nsec / 1000000000
;
- ts->tv_nsec -=
adj_sec * 1000000000UL
;
+ ts->tv_nsec -=
adj_sec * 1000000000
;
ts->tv_sec += adj_sec;
}
ts->tv_sec += adj_sec;
}
- if (ts->tv_nsec >= 1000000000
UL
){
- ts->tv_nsec -= 1000000000
UL
;
+ if (ts->tv_nsec >= 1000000000){
+ ts->tv_nsec -= 1000000000;
ts->tv_sec++;
}
}
ts->tv_sec++;
}
}