diff options
author | Gary E. Miller <gem@rellim.com> | 2015-06-03 16:19:42 -0700 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2015-06-03 16:19:42 -0700 |
commit | ebb1d9da881c31db7ef2db6ae017daa1238134fa (patch) | |
tree | 937ae4b5cfa052c6e2b0c1bb7228c97382a77e58 /ntpshmmon.c | |
parent | 7a04ef5ac5e96fb3ae989a98586776273215c953 (diff) | |
download | gpsd-ebb1d9da881c31db7ef2db6ae017daa1238134fa.tar.gz |
Fix overflow issue on 32 bit binaries.
Timespec is a 62 bit number, it does not fit in the 32 bits of
a long. Use 'long long' instead. 'long long' is always at least
64 bits long and is the same as a native int when compiled as 64 bit.
Note that many 64 bit OS still run 32 bit binaries, and many small
devices like RasPi's are 32 bit.
Diffstat (limited to 'ntpshmmon.c')
-rw-r--r-- | ntpshmmon.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/ntpshmmon.c b/ntpshmmon.c index a212fe82..56f90aa6 100644 --- a/ntpshmmon.c +++ b/ntpshmmon.c @@ -19,7 +19,7 @@ /* difference between timespecs in nanoseconds */ /* int is too small, 32 bit long is too small, avoid floats */ /* MUST be long long to maintain precision on 32 bit code */ -#define timespec_diff_ns(x, y) (long long)(((x).tv_sec-(y).tv_sec)*1000000000+(x).tv_nsec-(y).tv_nsec) +#define timespec_diff_ns(x, y) (long long)(((x).tv_sec-(y).tv_sec)*1000000000LL+(x).tv_nsec-(y).tv_nsec) static struct shmTime *segments[NTPSEGMENTS + 1]; static struct timespec tick[NTPSEGMENTS + 1]; |