diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2010-04-20 13:36:14 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2010-04-20 13:36:14 -0400 |
commit | b7db5552281151cc623f5e03f3c4f3687025ec38 (patch) | |
tree | 461979495e2a3eb536ddf0c12a7b84ec96ce1bf2 | |
parent | d3551eec32b6a4858d00582f61b00803ef340b00 (diff) | |
download | gpsd-b7db5552281151cc623f5e03f3c4f3687025ec38.tar.gz |
Splint and cppcheck cleanup. All regression tests pass.
-rw-r--r-- | driver_evermore.c | 16 | ||||
-rw-r--r-- | driver_garmin.c | 10 | ||||
-rw-r--r-- | driver_navcom.c | 12 | ||||
-rw-r--r-- | driver_sirf.c | 10 | ||||
-rw-r--r-- | driver_tsip.c | 8 | ||||
-rw-r--r-- | driver_ubx.c | 2 | ||||
-rw-r--r-- | driver_zodiac.c | 6 | ||||
-rw-r--r-- | gpsd.c | 2 | ||||
-rw-r--r-- | gpsd.h-tail | 1 | ||||
-rw-r--r-- | libgpsd_core.c | 2 | ||||
-rw-r--r-- | subframe.c | 4 |
11 files changed, 39 insertions, 34 deletions
diff --git a/driver_evermore.c b/driver_evermore.c index c8136e28..407ac6b6 100644 --- a/driver_evermore.c +++ b/driver_evermore.c @@ -183,8 +183,8 @@ gps_mask_t evermore_parse(struct gps_device_t * session, unsigned char *buf, switch (type) { case 0x02: /* Navigation Data Output */ - session->context->gps_week = getleuw(buf2, 2); - session->context->gps_tow = getleul(buf2, 4) * 0.01; + session->context->gps_week = (unsigned short)getleuw(buf2, 2); + session->context->gps_tow = (double)getleul(buf2, 4) * 0.01; /*@ ignore @*//*@ splint is confused @ */ session->newdata.time = gpstime_to_unix(session->context->gps_week, @@ -223,8 +223,8 @@ gps_mask_t evermore_parse(struct gps_device_t * session, unsigned char *buf, return mask | CLEAR_IS | REPORT_IS; case 0x04: /* DOP Data Output */ - session->context->gps_week = getleuw(buf2, 2); - session->context->gps_tow = getleul(buf2, 4) * 0.01; + session->context->gps_week = (unsigned short)getleuw(buf2, 2); + session->context->gps_tow = (double)getleul(buf2, 4) * 0.01; /*@ ignore @*//*@ splint is confused @ */ session->newdata.time = gpstime_to_unix(session->context->gps_week, @@ -267,8 +267,8 @@ gps_mask_t evermore_parse(struct gps_device_t * session, unsigned char *buf, return mask; case 0x06: /* Channel Status Output */ - session->context->gps_week = getleuw(buf2, 2); - session->context->gps_tow = getleul(buf2, 4) * 0.01; + session->context->gps_week = (unsigned short)getleuw(buf2, 2); + session->context->gps_tow = (double)getleul(buf2, 4) * 0.01; /*@ ignore @*//*@ splint is confused @ */ session->gpsdata.skyview_time = gpstime_to_unix(session->context->gps_week, @@ -327,8 +327,8 @@ gps_mask_t evermore_parse(struct gps_device_t * session, unsigned char *buf, case 0x08: /* Measurement Data Output */ /* clock offset is a manufacturer diagnostic */ /* (int)getleuw(buf2, 8); clock offset, 29000..29850 ?? */ - session->context->gps_week = getleuw(buf2, 2); - session->context->gps_tow = getleul(buf2, 4) * 0.01; + session->context->gps_week = (unsigned short)getleuw(buf2, 2); + session->context->gps_tow = (double)getleul(buf2, 4) * 0.01; /*@ ignore @*//*@ splint is confused @ */ session->newdata.time = gpstime_to_unix(session->context->gps_week, diff --git a/driver_garmin.c b/driver_garmin.c index 3988952d..afe931d8 100644 --- a/driver_garmin.c +++ b/driver_garmin.c @@ -813,6 +813,7 @@ static void Build_Send_SER_Packet(struct gps_device_t *session, * * libudev: http://www.kernel.org/pub/linux/utils/kernel/hotplug/libudev/ */ +/*@-compdef -usedef@*/ static bool is_usb_device(const char *path UNUSED, int vendor, int product) { // discover devices @@ -822,13 +823,15 @@ static bool is_usb_device(const char *path UNUSED, int vendor, int product) bool found = false; gpsd_report(LOG_SHOUT, "attempting USB device enumeration.\n"); - libusb_init(NULL); + /*@i2@*/libusb_init(NULL); + /*@-nullpass@*/ if ((cnt = libusb_get_device_list(NULL, &list)) < 0) { gpsd_report(LOG_ERROR, "USB device list call failed.\n"); - libusb_exit(NULL); + /*@i1@*/libusb_exit(NULL); return false; } + /*@+nullpass@*/ for (i = 0; i < cnt; i++) { struct libusb_device_descriptor desc; @@ -858,9 +861,10 @@ static bool is_usb_device(const char *path UNUSED, int vendor, int product) gpsd_report(LOG_SHOUT, "vendor/product match with %04x:%04x %sfound\n", vendor, product, found ? "" : "not "); libusb_free_device_list(list, 1); - libusb_exit(NULL); + /*@i1@*/libusb_exit(NULL); return found; } +/*@-compdef -usedef@*/ #endif /* HAVE_LIBUSB || S_SPLINT_S */ /* diff --git a/driver_navcom.c b/driver_navcom.c index 94ef0b0a..3a8f2618 100644 --- a/driver_navcom.c +++ b/driver_navcom.c @@ -656,7 +656,7 @@ static gps_mask_t handle_0x81(struct gps_device_t *session) 4) | (getub(buf, 82) & 80 ? 0xc000 : 0x0000)); /*@ +predboolothers @*/ char time_str[24]; - session->context->gps_week = wn; + session->context->gps_week = (unsigned short)wn; session->context->gps_tow = (double)(toc * SF_TOC); /* leap second? */ (void)unix_to_iso8601(gpstime_to_unix((int)wn, session->context->gps_tow), @@ -739,8 +739,8 @@ static gps_mask_t handle_0x86(struct gps_device_t *session) //uint8_t pdop = getub(buf, 15); /* Timestamp and PDOP */ - session->context->gps_week = week; - session->context->gps_tow = tow / 1000.0f; + session->context->gps_week = (unsigned short)week; + session->context->gps_tow = (double)tow / 1000.0f; /*@ ignore @*//*@ splint is confused @ */ session->gpsdata.skyview_time = gpstime_to_unix((int)week, session->context->gps_tow) @@ -842,7 +842,7 @@ static gps_mask_t handle_0xb0(struct gps_device_t *session) uint8_t status = getub(buf, 10); char time_str[24]; - session->context->gps_week = week; + session->context->gps_week = (unsigned short)week; session->context->gps_tow = (double)tow / 1000.0; (void)unix_to_iso8601(gpstime_to_unix((int)week, session->context->gps_tow), time_str, sizeof(time_str)); @@ -936,8 +936,8 @@ static gps_mask_t handle_0xb5(struct gps_device_t *session) session->newdata.epv = alt_sd * 1.96; mask |= (HERR_IS | VERR_IS); #endif /* __UNUSED__ */ - session->context->gps_week = week; - session->context->gps_tow = tow / 1000.0f; + session->context->gps_week = (unsigned short)week; + session->context->gps_tow = (double)tow / 1000.0f; /*@ ignore @*//*@ splint is confused @ */ session->newdata.time = gpstime_to_unix((int)week, session->context->gps_tow) diff --git a/driver_sirf.c b/driver_sirf.c index 2d2d676a..5338aea8 100644 --- a/driver_sirf.c +++ b/driver_sirf.c @@ -447,7 +447,7 @@ static gps_mask_t sirf_msg_navdata(struct gps_device_t *session, words[i] = (unsigned int)getbeul(buf, 4 * i + 3); } - gpsd_interpret_subframe_raw(session, words); + (void)gpsd_interpret_subframe_raw(session, words); #ifdef ALLOW_RECONFIGURE if (session->gpsdata.dev.baudrate < 38400) { @@ -470,8 +470,8 @@ static gps_mask_t sirf_msg_svinfo(struct gps_device_t *session, return 0; gpsd_zero_satellites(&session->gpsdata); - session->context->gps_week = getbesw(buf, 1); - session->context->gps_tow = getbeul(buf, 3) * 1e-2; + session->context->gps_week = (unsigned short)getbesw(buf, 1); + session->context->gps_tow = (double)getbeul(buf, 3) * 1e-2; /*@ ignore @*//*@ splint is confused @ */ session->gpsdata.skyview_time = @@ -613,8 +613,8 @@ static gps_mask_t sirf_msg_navsol(struct gps_device_t *session, navtype, session->gpsdata.status, session->newdata.mode); /* byte 20 is HDOP, see below */ /* byte 21 is "mode 2", not clear how to interpret that */ - session->context->gps_week = getbesw(buf, 22); - session->context->gps_tow = getbeul(buf, 24) * 1e-2; + session->context->gps_week = (unsigned short)getbesw(buf, 22); + session->context->gps_tow = (double)getbeul(buf, 24) * 1e-2; /*@ ignore @*//*@ splint is confused @ */ session->newdata.time = gpstime_to_unix(session->context->gps_week, session->context->gps_tow) - diff --git a/driver_tsip.c b/driver_tsip.c index 1e82f18a..52ddae55 100644 --- a/driver_tsip.c +++ b/driver_tsip.c @@ -654,8 +654,8 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session) session->context->leap_seconds = (int)u4; session->context->valid |= LEAP_SECOND_VALID; } - session->context->gps_week = s4; - session->context->gps_tow = ul1 * 1e-3; + session->context->gps_week = (unsigned short)s4; + session->context->gps_tow = (double)ul1 * 1e-3; /*@ ignore @*//*@ splint is confused @ */ session->newdata.time = gpstime_to_unix((int)s4, session->context->gps_tow) @@ -696,8 +696,8 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session) session->context->leap_seconds = (int)u1; session->context->valid |= LEAP_SECOND_VALID; } - session->context->gps_week = s1; - session->context->gps_tow = ul1 * 1e3; + session->context->gps_week = (unsigned short)s1; + session->context->gps_tow = (double)ul1 * 1e3; /*@ ignore @*//*@ splint is confused @ */ session->newdata.time = gpstime_to_unix(session->context->gps_week, diff --git a/driver_ubx.c b/driver_ubx.c index 127f410f..6038b558 100644 --- a/driver_ubx.c +++ b/driver_ubx.c @@ -175,7 +175,7 @@ ubx_msg_nav_timegps(struct gps_device_t *session, unsigned char *buf, tow = (unsigned int)getleul(buf, 0); gw = (unsigned int)getlesw(buf, 8); if (gw > session->context->gps_week) - session->context->gps_week = gw; + session->context->gps_week = (unsigned short)gw; flags = (unsigned int)getub(buf, 11); if ((flags & 0x7) != 0) diff --git a/driver_zodiac.c b/driver_zodiac.c index f2a8d496..50ac8d23 100644 --- a/driver_zodiac.c +++ b/driver_zodiac.c @@ -152,7 +152,7 @@ static gps_mask_t handle1000(struct gps_device_t *session) /* solution_type = getzword(11); */ session->gpsdata.satellites_used = (int)getzword(12); /* polar_navigation = getzword(13); */ - session->context->gps_week = getzword(14); + session->context->gps_week = (unsigned short)getzword(14); /* gps_seconds = getzlong(15); */ /* gps_nanoseconds = getzlong(17); */ unpacked_date.tm_mday = (int)getzword(19); @@ -222,7 +222,7 @@ static gps_mask_t handle1002(struct gps_device_t *session) int gps_seconds = getzlong(11); /* gps_nanoseconds = getzlong(13); */ /*@-charint@*/ - session->context->gps_week = gps_week; + session->context->gps_week = (unsigned short)gps_week; session->gpsdata.satellites_used = 0; memset(session->gpsdata.used, 0, sizeof(session->gpsdata.used)); for (i = 0; i < ZODIAC_CHANNELS; i++) { @@ -240,7 +240,7 @@ static gps_mask_t handle1002(struct gps_device_t *session) break; } } - session->context->gps_week = gps_week; + session->context->gps_week = (unsigned short)gps_week; session->context->gps_tow = (double) gps_seconds; session->gpsdata.skyview_time = gpstime_to_unix(gps_week, session->context->gps_tow); @@ -168,6 +168,8 @@ struct gps_context_t context = { .rtcmbuf = {'\0'}, .rtcmtime = 0, .leap_seconds = LEAP_SECONDS, + .gps_week = 0, + .gps_tow = 0, .century = CENTURY_BASE, #ifdef NTPSHM_ENABLE .enable_ntpshm = false, diff --git a/gpsd.h-tail b/gpsd.h-tail index fb5d7fd3..41af40ae 100644 --- a/gpsd.h-tail +++ b/gpsd.h-tail @@ -541,7 +541,6 @@ extern ssize_t hex_escapes(/*@out@*/char *cooked, const char *raw); extern void ntpd_link_activate(struct gps_device_t *session); extern char /*@observer@*/ *gpsd_id(/*@in@*/struct gps_device_t *); extern void gpsd_position_fix_dump(struct gps_device_t *, /*@out@*/char[], size_t); -extern void gpsd_error_model(struct gps_device_t *, struct gps_fix_t *, struct gps_fix_t *); extern void gpsd_clear_data(struct gps_device_t *); extern socket_t netlib_connectsock(int, const char *, const char *, const char *); extern char /*@observer@*/ *netlib_errstr(const int); diff --git a/libgpsd_core.c b/libgpsd_core.c index b3dd456d..ab36b7f9 100644 --- a/libgpsd_core.c +++ b/libgpsd_core.c @@ -450,7 +450,7 @@ char /*@observer@*/ *gpsd_id( /*@in@ */ struct gps_device_t *session) return (buf); } -void gpsd_error_model(struct gps_device_t *session, +static void gpsd_error_model(struct gps_device_t *session, struct gps_fix_t *fix, struct gps_fix_t *oldfix) /* compute errors and derived quantities */ { @@ -106,7 +106,7 @@ void gpsd_interpret_subframe(struct gps_device_t *session, words[0], words[1], words[2], words[3], words[4], words[5], words[6], words[7], words[8], words[9]); - preamble = (words[0] >> 16) & 0xffL; + preamble = (unsigned int)((words[0] >> 16) & 0xffL); if (preamble == 0x8b) { preamble ^= 0xff; words[0] ^= 0xffffff; @@ -131,7 +131,7 @@ void gpsd_interpret_subframe(struct gps_device_t *session, switch (subframe) { case 1: /* get Week Number WN) from subframe 1 */ - session->context->gps_week = (words[2] & 0xffc000) >> 14; + session->context->gps_week = (unsigned short)((words[2] & 0xffc000) >> 14); gpsd_report(LOG_PROG, "50B: WN: %u\n", session->context->gps_week); break; |