[PATCH] ugps: fix 64-bit time_t
Rosen Penev
rosenp at gmail.com
Fri Aug 28 23:21:36 EDT 2020
On Tue, Jul 21, 2020 at 3:50 PM Rosen Penev <rosenp at gmail.com> wrote:
>
> 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)) {
Ping. This is still not applied.
>
> Signed-off-by: Rosen Penev <rosenp at gmail.com>
> ---
> nmea.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> 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) {
> --
> 2.26.2
>
More information about the openwrt-devel
mailing list