Skip to content

Commit

Permalink
avoid integer overflow in gethrtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Aliaksey Kandratsenka committed Aug 26, 2010
1 parent 3bf2266 commit 485433b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions timer.c
Expand Up @@ -32,15 +32,15 @@ hrtime_t gethrtime() {
return (-1ULL);
}

ret = ts.tv_sec * 1000000000;
ret = (hrtime_t)ts.tv_sec * 1000000000;
ret += ts.tv_nsec;
#elif HAVE_GETTIMEOFDAY
struct timeval tv;
if (gettimeofday(&tv, NULL) == -1) {
return (-1ULL);
}

ret = tv.tv_sec * 1000000000;
ret = (hrtime_t)tv.tv_sec * 1000000000;
ret += tv.tv_usec * 1000;
#endif

Expand Down

0 comments on commit 485433b

Please sign in to comment.