summaryrefslogtreecommitdiff
path: root/ppsthread.c
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2015-06-03 16:19:42 -0700
committerGary E. Miller <gem@rellim.com>2015-06-03 16:19:42 -0700
commitebb1d9da881c31db7ef2db6ae017daa1238134fa (patch)
tree937ae4b5cfa052c6e2b0c1bb7228c97382a77e58 /ppsthread.c
parent7a04ef5ac5e96fb3ae989a98586776273215c953 (diff)
downloadgpsd-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 'ppsthread.c')
-rw-r--r--ppsthread.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/ppsthread.c b/ppsthread.c
index 5fae444d..00819cf4 100644
--- a/ppsthread.c
+++ b/ppsthread.c
@@ -619,7 +619,7 @@ static void *gpsd_ppsmonitor(void *arg)
volatile struct timedelta_t last_fixtime = {{0, 0}, {0, 0}};
struct timespec clock_ts = {0, 0};
time_t last_second_used = 0;
- long cycle = 0, duration = 0;
+ long long cycle = 0, duration = 0;
/* state is the last state of the tty control signals */
int state = 0;
/* count of how many cycles unchanged data */
@@ -631,8 +631,8 @@ static void *gpsd_ppsmonitor(void *arg)
#if defined(TIOCMIWAIT)
int edge_tio = 0;
- long cycle_tio = 0;
- long duration_tio = 0;
+ long long cycle_tio = 0;
+ long long duration_tio = 0;
int state_tio = 0;
int state_last_tio = 0;
struct timespec clock_ts_tio = {0, 0};
@@ -641,7 +641,7 @@ static void *gpsd_ppsmonitor(void *arg)
#endif /* TIOCMIWAIT */
#if defined(HAVE_SYS_TIMEPPS_H)
- long cycle_kpps = 0, duration_kpps = 0;
+ long long cycle_kpps = 0, duration_kpps = 0;
/* kpps_pulse stores the time of the last two edges */
struct timespec pulse_kpps[2] = { {0, 0}, {0, 0} };
#endif /* defined(HAVE_SYS_TIMEPPS_H) */