From: Rosen Penev Date: Tue, 21 Jul 2020 22:50:37 +0000 (-0700) Subject: ugps: fix 64-bit time_t X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=511a5b3c84fa715ef0305cf26c98619c12a4867a;p=project%2Fugps.git ugps: fix 64-bit time_t The abs function takes a 32-bit int, which can cause truncation. Fixes compilation error: error: absolute value function 'abs' given an argu> if ((sec < 0) || (abs(cur.tv_sec - tv.tv_sec) > MAX_TIME_OFFSET)) { Signed-off-by: Rosen Penev --- diff --git a/nmea.c b/nmea.c index 8df7792..1204c20 100644 --- a/nmea.c +++ b/nmea.c @@ -107,7 +107,7 @@ nmea_rmc_cb(void) gettimeofday(&cur, NULL); - if ((sec < 0) || (abs(cur.tv_sec - sec) > MAX_TIME_OFFSET)) { + if ((sec < 0) || (llabs(cur.tv_sec - sec) > MAX_TIME_OFFSET)) { struct timeval tv = { 0 }; tv.tv_sec = sec; if (++nmea_bad_time > MAX_BAD_TIME) {