From 938d271e688decf266675c8b640a71ab967af4d5 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 3 Feb 2011 08:22:34 -0500 Subject: Partial splint and warning cleanup. All regression tests pass. --- .splintrc | 8 +++---- driver_geostar.c | 2 +- driver_navcom.c | 12 +++++----- driver_nmea.c | 2 +- driver_superstar2.c | 4 ++-- driver_tsip.c | 4 ++-- gps.h | 66 ++++++++++++++++++++++++++++------------------------- gpsd.h-tail | 62 ++++++++++++++++++++++++------------------------- gpsd_json.c | 10 ++++---- monitor_sirf.c | 2 +- 10 files changed, 88 insertions(+), 84 deletions(-) diff --git a/.splintrc b/.splintrc index a0d561e3..6db774d0 100644 --- a/.splintrc +++ b/.splintrc @@ -11,13 +11,11 @@ -abstract -Dint8_t=char --Du_int8_t=uchar +-Duint8_t=uchar -Dint16_t=short --Du_int16_t=ushort +-Duint16_t=ushort -Dint32_t=int --Du_int32_t=uint --Dint64_t=long --Du_int64_t=ulong +-Duint32_t=uint -Din_addr_t=int -Dcaddr_t=short -Disgps30bits_t=uint diff --git a/driver_geostar.c b/driver_geostar.c index 42ef3ed9..b75c7521 100644 --- a/driver_geostar.c +++ b/driver_geostar.c @@ -202,7 +202,7 @@ static gps_mask_t geostar_analyze(struct gps_device_t *session) ul1 = getleu32(buf, OFFSET(29)); /* status */ - if (ul1 != (uint8_t) 0) { + if (ul1 != 0) { session->gpsdata.status = STATUS_NO_FIX; mask |= STATUS_IS; } else { diff --git a/driver_navcom.c b/driver_navcom.c index d4038155..48afe8c4 100644 --- a/driver_navcom.c +++ b/driver_navcom.c @@ -430,9 +430,9 @@ static gps_mask_t handle_0xb1(struct gps_device_t *session) session->gpsdata.status = STATUS_NO_FIX; session->newdata.mode = MODE_NO_FIX; } else { - session->newdata.mode = (nav_mode & 0x40 ? MODE_3D : MODE_2D); + session->newdata.mode = ((nav_mode & 0x40)!=0 ? MODE_3D : MODE_2D); session->gpsdata.status = - (nav_mode & 0x03 ? STATUS_DGPS_FIX : STATUS_FIX); + ((nav_mode & 0x03)!=0 ? STATUS_DGPS_FIX : STATUS_FIX); } /* Height Data */ @@ -489,13 +489,13 @@ static gps_mask_t handle_0xb1(struct gps_device_t *session) session->gpsdata.dop.vdop = vdop / 10.0; if (tdop != DOP_UNDEFINED) session->gpsdata.dop.tdop = tdop / 10.0; - /*@ +type @*/ gpsd_report(LOG_PROG, "Navcom: received packet type 0xb1 (PVT Report)\n"); gpsd_report(LOG_IO, "Navcom: navigation mode %s (0x%02x) - %s - %s\n", - (-nav_mode & 0x80 ? "invalid" : "valid"), nav_mode, - (nav_mode & 0x40 ? "3D" : "2D"), - (nav_mode & 0x03 ? "DGPS" : "GPS")); + ((-nav_mode & 0x80)!='\0' ? "invalid" : "valid"), nav_mode, + ((nav_mode & 0x40)!='\0' ? "3D" : "2D"), + ((nav_mode & 0x03)!='\0' ? "DGPS" : "GPS")); + /*@ +type @*/ gpsd_report(LOG_IO, "Navcom: latitude = %f, longitude = %f, altitude = %f, geoid = %f\n", session->newdata.latitude, session->newdata.longitude, diff --git a/driver_nmea.c b/driver_nmea.c index 8b481690..7a7ac55d 100644 --- a/driver_nmea.c +++ b/driver_nmea.c @@ -431,7 +431,7 @@ static gps_mask_t processGPGST(int count, char *field[], struct gps_device_t *se return 0; } -#define PARSE_FIELD(n) (*field[n] ? atof(field[n]) : NAN) +#define PARSE_FIELD(n) (*field[n]!='\0' ? atof(field[n]) : NAN) session->gpsdata.gst.utctime = PARSE_FIELD(1); session->gpsdata.gst.rms_deviation = PARSE_FIELD(2); session->gpsdata.gst.smajor_deviation = PARSE_FIELD(3); diff --git a/driver_superstar2.c b/driver_superstar2.c index fd8e2c1b..4c013fdb 100644 --- a/driver_superstar2.c +++ b/driver_superstar2.c @@ -111,8 +111,8 @@ superstar2_msg_navsol_lla(struct gps_device_t *session, mask |= LATLON_IS | ALTITUDE_IS | SPEED_IS | TRACK_IS | CLIMB_IS; session->gpsdata.satellites_used = (int)getub(buf, 71) & 0x0f; - /*@i3@*/ session->gpsdata.dop.hdop = getleu16(buf, 66) * 0.1; - /*@i3@*/ session->gpsdata.dop.vdop = getleu16(buf, 68) * 0.1; + /*@i2@*/ session->gpsdata.dop.hdop = getleu16(buf, 66) * 0.1; + /*@i2@*/ session->gpsdata.dop.vdop = getleu16(buf, 68) * 0.1; /* other DOP if available */ mask |= DOP_IS | USED_IS; diff --git a/driver_tsip.c b/driver_tsip.c index 4c0f12cf..2586d86f 100644 --- a/driver_tsip.c +++ b/driver_tsip.c @@ -625,7 +625,7 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session) if ((session->newdata.track = atan2(d1, d2) * RAD_2_DEG) < 0) session->newdata.track += 360.0; session->newdata.latitude = sl1 * SEMI_2_DEG; - /*@i1@*/ session->newdata.longitude = ul2 * SEMI_2_DEG; + session->newdata.longitude = ul2 * SEMI_2_DEG; if (session->newdata.longitude > 180.0) session->newdata.longitude -= 360.0; session->gpsdata.separation = @@ -701,7 +701,7 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session) session->newdata.mode = MODE_3D; } session->newdata.latitude = sl1 * SEMI_2_DEG; - /*@i1@*/ session->newdata.longitude = ul2 * SEMI_2_DEG; + session->newdata.longitude = ul2 * SEMI_2_DEG; if (session->newdata.longitude > 180.0) session->newdata.longitude -= 360.0; session->gpsdata.separation = diff --git a/gps.h b/gps.h index da621138..4be52a65 100644 --- a/gps.h +++ b/gps.h @@ -789,7 +789,11 @@ struct subframe_t { }; }; -typedef /*@unsignedintegraltype@*/ uint64_t gps_mask_t; +#ifndef S_SPLINT_S +typedef uint64_t gps_mask_t; +#else +typedef /*@unsignedintegraltype@*/ unsigned long long gps_mask_t; +#endif /* S_SPLINT_S */ /* * Is an MMSI number that of an auxiliary associated with a mother ship? @@ -1296,36 +1300,36 @@ typedef int socket_t; struct gps_data_t { gps_mask_t set; /* has field been set since this was last cleared? */ -#define ONLINE_SET (1<<1) -#define TIME_SET (1<<2) -#define TIMERR_SET (1<<3) -#define LATLON_SET (1<<4) -#define ALTITUDE_SET (1<<5) -#define SPEED_SET (1<<6) -#define TRACK_SET (1<<7) -#define CLIMB_SET (1<<8) -#define STATUS_SET (1<<9) -#define MODE_SET (1<<10) -#define DOP_SET (1<<11) -#define HERR_SET (1<<12) -#define VERR_SET (1<<13) -#define ATTITUDE_SET (1<<14) -#define SATELLITE_SET (1<<15) -#define SPEEDERR_SET (1<<16) -#define TRACKERR_SET (1<<17) -#define CLIMBERR_SET (1<<18) -#define DEVICE_SET (1<<19) -#define DEVICELIST_SET (1<<20) -#define DEVICEID_SET (1<<21) -#define RTCM2_SET (1<<22) -#define RTCM3_SET (1<<23) -#define AIS_SET (1<<24) -#define PACKET_SET (1<<25) -#define SUBFRAME_SET (1<<26) -#define GST_SET (1<<27) -#define VERSION_SET (1<<28) -#define POLICY_SET (1<<29) -#define ERROR_SET (1<<30) +#define ONLINE_SET (1<<1llu) +#define TIME_SET (1<<2llu) +#define TIMERR_SET (1<<3llu) +#define LATLON_SET (1<<4llu) +#define ALTITUDE_SET (1<<5llu) +#define SPEED_SET (1<<6llu) +#define TRACK_SET (1<<7llu) +#define CLIMB_SET (1<<8llu) +#define STATUS_SET (1<<9llu) +#define MODE_SET (1<<10llu) +#define DOP_SET (1<<11llu) +#define HERR_SET (1<<12llu) +#define VERR_SET (1<<13llu) +#define ATTITUDE_SET (1<<14llu) +#define SATELLITE_SET (1<<15llu) +#define SPEEDERR_SET (1<<16llu) +#define TRACKERR_SET (1<<17llu) +#define CLIMBERR_SET (1<<18llu) +#define DEVICE_SET (1<<19llu) +#define DEVICELIST_SET (1<<20llu) +#define DEVICEID_SET (1<<21llu) +#define RTCM2_SET (1<<22llu) +#define RTCM3_SET (1<<23llu) +#define AIS_SET (1<<24llu) +#define PACKET_SET (1<<25llu) +#define SUBFRAME_SET (1<<26llu) +#define GST_SET (1<<27llu) +#define VERSION_SET (1<<28llu) +#define POLICY_SET (1<<29llu) +#define ERROR_SET (1<<30llu) double online; /* NZ if GPS is on line, 0 if not. * * Note: gpsd clears this time when sentences diff --git a/gpsd.h-tail b/gpsd.h-tail index c62d366b..d2c3bfba 100644 --- a/gpsd.h-tail +++ b/gpsd.h-tail @@ -233,37 +233,37 @@ typedef enum { event_reactivate, } event_t; -#define ONLINE_IS 0x00000001u -#define TIME_IS 0x00000002u -#define TIMERR_IS 0x00000004u -#define LATLON_IS 0x00000008u -#define ALTITUDE_IS 0x00000010u -#define SPEED_IS 0x00000020u -#define TRACK_IS 0x00000040u -#define CLIMB_IS 0x00000080u -#define STATUS_IS 0x00000100u -#define MODE_IS 0x00000200u -#define DOP_IS 0x00000400u -#define HERR_IS 0x00000800u -#define VERR_IS 0x00001000u -#define PERR_IS 0x00002000u -#define SATELLITE_IS 0x00004000u -#define RAW_IS 0x00008000u -#define USED_IS 0x00010000u -#define SPEEDERR_IS 0x00020000u -#define DRIVER_IS 0x00040000u -#define DEVICEID_IS 0x00100000u -#define ERROR_IS 0x00200000u -#define RTCM2_IS 0x00400000u -#define RTCM3_IS 0x00800000u -#define AIS_IS 0x01000000u -#define ATT_IS 0x02000000u -#define SUBFRAME_IS 0x04000000u -#define PACKET_IS 0x10000000u -#define CLEAR_IS 0x20000000u /* sentence starts a reporting cycle */ -#define REPORT_IS 0x40000000u /* sentence ends a reporting cycle */ -#define NOISE_IS 0x80000000u /* sentence contains pseudorange noise information */ -#define NODATA_IS 0x8000000000000000llu /* no data read from fd */ +#define ONLINE_IS ((gps_mask_t)(1<<1)) +#define TIME_IS ((gps_mask_t)(1<<2)) +#define TIMERR_IS ((gps_mask_t)(1<<3)) +#define LATLON_IS ((gps_mask_t)(1<<4)) +#define ALTITUDE_IS ((gps_mask_t)(1<<5)) +#define SPEED_IS ((gps_mask_t)(1<<6)) +#define TRACK_IS ((gps_mask_t)(1<<7)) +#define CLIMB_IS ((gps_mask_t)(1<<8)) +#define STATUS_IS ((gps_mask_t)(1<<9)) +#define MODE_IS ((gps_mask_t)(1<<10)) +#define DOP_IS ((gps_mask_t)(1<<11)) +#define HERR_IS ((gps_mask_t)(1<<12)) +#define VERR_IS ((gps_mask_t)(1<<13)) +#define PERR_IS ((gps_mask_t)(1<<14)) +#define SATELLITE_IS ((gps_mask_t)(1<<15)) +#define RAW_IS ((gps_mask_t)(1<<16)) +#define USED_IS ((gps_mask_t)(1<<17)) +#define SPEEDERR_IS ((gps_mask_t)(1<<18)) +#define DRIVER_IS ((gps_mask_t)(1<<19)) +#define DEVICEID_IS ((gps_mask_t)(1<<20)) +#define ERROR_IS ((gps_mask_t)(1<<21)) +#define RTCM2_IS ((gps_mask_t)(1<<22)) +#define RTCM3_IS ((gps_mask_t)(1<<23)) +#define AIS_IS ((gps_mask_t)(1<<24)) +#define ATT_IS ((gps_mask_t)(1<<25)) +#define SUBFRAME_IS ((gps_mask_t)(1<<26)) +#define PACKET_IS ((gps_mask_t)(1<<27)) +#define CLEAR_IS ((gps_mask_t)(1<<28)) /* starts a reporting cycle */ +#define REPORT_IS ((gps_mask_t)(1<<29)) /* ends a reporting cycle */ +#define NOISE_IS ((gps_mask_t)(1<<30)) +#define NODATA_IS ((gps_mask_t)(1<<31)) /* no data read from fd */ #define DATA_IS ~(ONLINE_IS|PACKET_IS|CLEAR_IS|REPORT_IS) typedef /*@unsignedintegraltype@*/ unsigned int driver_mask_t; diff --git a/gpsd_json.c b/gpsd_json.c index 7df12791..7a7ca8ad 100644 --- a/gpsd_json.c +++ b/gpsd_json.c @@ -418,7 +418,8 @@ void json_subframe_dump(const struct subframe_t *subframe, bool scaled, (unsigned int)subframe->subframe_num, JSON_BOOL(scaled)); len = strlen(buf); - + + /*@-type@*/ if ( 1 == subframe->subframe_num ) { if (scaled) { (void)snprintf(buf + len, buflen - len, @@ -682,13 +683,13 @@ void json_subframe_dump(const struct subframe_t *subframe, bool scaled, /* subframe5, page 25 */ (void)snprintf(buf + len, buflen - len, ",\"HEALTH2\":{\"toa\":%lu,\"WNa\":%u,", - (unsigned long)subframe->sub5_25.l_toa, - subframe->sub5_25.WNa); + (unsigned long)subframe->sub5_25.l_toa, + (unsigned int)subframe->sub5_25.WNa); /* 1-index loop to construct json */ for(i = 1 ; i <= 24; i++){ len = strlen(buf); (void)snprintf(buf + len, buflen - len, - "\"SV%d\":%d,", i, subframe->sub5_25.sv[i]); + "\"SV%d\":%d,", i, (int)subframe->sub5_25.sv[i]); } len = strlen(buf)-1; buf[len] = '\0'; @@ -697,6 +698,7 @@ void json_subframe_dump(const struct subframe_t *subframe, bool scaled, /*@-matchanyintegral@*/ } } + /*@+type@*/ (void)strlcat(buf, "}\r\n", buflen); /*@+compdef@*/ } diff --git a/monitor_sirf.c b/monitor_sirf.c index e29c3cdb..4511ed6e 100644 --- a/monitor_sirf.c +++ b/monitor_sirf.c @@ -526,9 +526,9 @@ static void sirf_update(void) total 3 x 12 = 36 bytes ******************************************************************/ dgps = getub(buf, 1); + /*@ -type @*/ display(mid27win, 1, 1, "%8s = ", (CHECK_RANGE(dgpsvec, dgps) ? dgpsvec[dgps] : "???")); - /*@ -type @*/ (void)wmove(mid27win, 1, 12); for (i = 0; i < MAXSATS; i++) if (getub(buf, 16 + 3 * i) != '\0') -- cgit v1.2.1