diff options
author | Gary E. Miller <gem@rellim.com> | 2018-09-27 19:55:49 -0700 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2018-09-27 19:57:40 -0700 |
commit | 03b20f848b646c0d37b7357fe2874a6e34975f01 (patch) | |
tree | d7d9c9bd3ba17aae2f0f53fc634709798dc503d7 /cgps.c | |
parent | 478a0c0e9b4e8e1c1136696780094a0a7d3e5488 (diff) | |
download | gpsd-03b20f848b646c0d37b7357fe2874a6e34975f01.tar.gz |
cgps: try to prevent overflow on large error estimates.
Diffstat (limited to 'cgps.c')
-rw-r--r-- | cgps.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -164,11 +164,17 @@ static char *dop_to_str(double dop) static char *ep_to_str(double ep, double factor, char *units) { static char buf[20]; + double val; if (isfinite(ep) == 0) { return " n/a "; } - (void)snprintf(buf, sizeof(buf), "+/-%5.1f %.8s", ep * factor, units); + val = ep * factor; + if ( 100 <= val ) { + (void)snprintf(buf, sizeof(buf), "+/-%5d %.3s", (int)val, units); + } else { + (void)snprintf(buf, sizeof(buf), "+/-%5.1f %.3s", val, units); + } return buf; } @@ -920,7 +926,7 @@ int main(int argc, char *argv[]) altfactor = METERS_TO_FEET; altunits = "ft"; speedfactor = MPS_TO_KNOTS; - speedunits = "knots"; + speedunits = "kts"; break; case metric: altfactor = 1; |