From b78d86b400d6e7070cbeb0efd39194248232257c Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 17 May 2012 03:07:46 -0400 Subject: Clean up from cppcheck warnings. All regression tests pass. --- SConstruct | 2 +- gpsctl.c | 7 ++++--- isgps.c | 4 ++-- lcdgps.c | 4 ++-- pseudonmea.c | 7 ++++--- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/SConstruct b/SConstruct index 95e5b684..36ca8e56 100644 --- a/SConstruct +++ b/SConstruct @@ -1282,7 +1282,7 @@ for (target,sources,description,params) in splint_table: env.Alias('splint',Splint(target,sources,description,params)) Utility("cppcheck", ["gpsd.h", "packet_names.h"], - "cppcheck --template gcc --enable=all --inline-suppr --force $SRCDIR") + "cppcheck --template gcc --enable=all --inline-suppr --suppress='*:driver_proto.c' --force $SRCDIR") # Sanity-check Python code. TODO: add xgps for the complete set. Utility("pychecker", ["jsongen.py", "maskaudit.py"], diff --git a/gpsctl.c b/gpsctl.c index 2158f743..e84dbd0b 100644 --- a/gpsctl.c +++ b/gpsctl.c @@ -259,7 +259,7 @@ static char /*@observer@*/ *gpsd_id( /*@in@ */ struct gps_device_t *session) int main(int argc, char **argv) { - int option, status, devcount; + int option, status; char *device = NULL, *devtype = NULL; char *speed = NULL, *control = NULL, *rate = NULL; bool to_binary = false, to_nmea = false, reset = false; @@ -398,7 +398,7 @@ int main(int argc, char **argv) } } - if ((int)to_nmea + (int)to_binary + (int)reset > 1) { + if (((int)to_nmea + (int)to_binary + (int)reset) > 1) { gpsd_report(LOG_ERROR, "make up your mind, would you?\n"); exit(0); } @@ -419,7 +419,7 @@ int main(int argc, char **argv) /*@-nullpass@*/ if (!lowlevel) { - int i; + int i, devcount; /* what devices have we available? */ if (!gps_query(&gpsdata, DEVICELIST_SET, (int)timeout, "?DEVICES;\n")) { @@ -444,6 +444,7 @@ int main(int argc, char **argv) device = gpsdata.dev.path; i = 0; } else { + int devcount; assert(device != NULL); for (i = 0; i < gpsdata.devices.ndevices; i++) if (strcmp(device, gpsdata.devices.list[i].path) == 0) { diff --git a/isgps.c b/isgps.c index 27cf92e1..9d465479 100644 --- a/isgps.c +++ b/isgps.c @@ -180,8 +180,6 @@ enum isgpsstat_t isgps_decode(struct gps_packet_t *session, bool(*length_check) (struct gps_packet_t *), size_t maxlen, unsigned int c) { - enum isgpsstat_t res; - /* ASCII characters 64-127, @ through DEL */ if ((c & MAG_TAG_MASK) != MAG_TAG_DATA) { gpsd_report(ISGPS_ERRLEVEL_BASE + 1, @@ -222,6 +220,8 @@ enum isgpsstat_t isgps_decode(struct gps_packet_t *session, } /* end while */ } if (session->isgps.locked) { + enum isgpsstat_t res; + res = ISGPS_SYNC; if (session->isgps.curr_offset > 0) { diff --git a/lcdgps.c b/lcdgps.c index 52bc1fab..4a768055 100644 --- a/lcdgps.c +++ b/lcdgps.c @@ -180,15 +180,14 @@ static enum deg_str_type deg_type = deg_dd; static void update_lcd(struct gps_data_t *gpsdata) { char tmpbuf[255]; - int n; char *s, *gridsquare; - int track; /* Get our location in Maidenhead. */ gridsquare = maidenhead(gpsdata->fix.latitude,gpsdata->fix.longitude); /* Fill in the latitude and longitude. */ if (gpsdata->fix.mode >= MODE_2D) { + int track; s = deg_to_str(deg_type, fabs(gpsdata->fix.latitude)); snprintf(tmpbuf, 254, "widget_set gpsd one 1 1 {Lat: %s %c}\n", s, (gpsdata->fix.latitude < 0) ? 'S' : 'N'); @@ -217,6 +216,7 @@ static void update_lcd(struct gps_data_t *gpsdata) /* Fill in the altitude and fix status. */ if (gpsdata->fix.mode == MODE_3D) { + int n; for(n=0;nfix.climb; avgclimb=0.0; diff --git a/pseudonmea.c b/pseudonmea.c index f84dc010..0847df88 100644 --- a/pseudonmea.c +++ b/pseudonmea.c @@ -163,11 +163,12 @@ static void gpsd_binary_satellite_dump(struct gps_device_t *session, static void gpsd_binary_quality_dump(struct gps_device_t *session, char bufp[], size_t len) { - int i, j; char *bufp2 = bufp; bool used_valid = (session->gpsdata.set & USED_IS) != 0; if (session->device_type != NULL && (session->gpsdata.set & MODE_SET) != 0) { + int i, j; + (void)snprintf(bufp, len - strlen(bufp), "$GPGSA,%c,%d,", 'A', session->gpsdata.fix.mode); j = 0; @@ -224,11 +225,11 @@ static void gpsd_binary_time_dump(struct gps_device_t *session, char bufp[], size_t len) { struct tm tm; - double integral, fractional; + double integral; time_t integral_time; if (session->newdata.mode > MODE_NO_FIX) { - fractional = modf(session->newdata.time, &integral); + double fractional = modf(session->newdata.time, &integral); integral_time = (time_t) integral; (void)gmtime_r(&integral_time, &tm); /* -- cgit v1.2.1