From 5b4af8cc002773058ad744f9c2f9975284b09224 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 9 Feb 2015 19:19:29 -0500 Subject: cppcheck and Coverity cleanup; all regression tests pass. --- gpsd_json.c | 2 +- gpsdecode.c | 2 +- lcdgps.c | 2 ++ monitor_nmea.c | 2 +- monitor_sirf.c | 2 +- monitor_ubx.c | 2 +- ppsthread.c | 4 ++-- 7 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gpsd_json.c b/gpsd_json.c index 7bb56aff..8807ddce 100644 --- a/gpsd_json.c +++ b/gpsd_json.c @@ -128,7 +128,6 @@ void json_tpv_dump(const struct gps_device_t *session, { const struct gps_data_t *gpsdata = &session->gpsdata; #ifdef TIMING_ENABLE - char ts_str[22]; /* buffer to hold printable timespec */ timestamp_t rtime = timestamp(); #endif /* TIMING_ENABLE */ @@ -188,6 +187,7 @@ void json_tpv_dump(const struct gps_device_t *session, #ifdef PPS_ENABLE /*@-type -formattype@*/ /* splint is confused about struct timespec */ if (session->ppscount) + char ts_str[22]; /* buffer to hold printable timespec */ /* you can not use a double here as you will lose 11 bits * of precision */ (void)timespec_str( &session->ppslast.clock, ts_str, sizeof(ts_str) ); diff --git a/gpsdecode.c b/gpsdecode.c index ece81d57..c64f2d02 100644 --- a/gpsdecode.c +++ b/gpsdecode.c @@ -611,9 +611,9 @@ static void decode(FILE *fpin, FILE*fpout) if (minlength) { for (i = 0; i < (int)(sizeof(minima)/sizeof(minima[0])); i++) { - const struct gps_type_t **dp; /* dump all minima, ignoring comments */ if (i != 1 && minima[i] < MAX_PACKET_LENGTH+1) { + const struct gps_type_t **dp; char *np = "Unknown"; for (dp = gpsd_drivers; *dp; dp++) { if ((*dp)->packet_type == i-1) { diff --git a/lcdgps.c b/lcdgps.c index c30f95a2..e3fa0040 100644 --- a/lcdgps.c +++ b/lcdgps.c @@ -384,6 +384,7 @@ int main(int argc, char *argv[]) localAddr.sin_addr.s_addr = htonl(INADDR_ANY); localAddr.sin_port = htons(0); + /* coverity[uninit_use_in_call] */ rc = bind(sd, (struct sockaddr *) &localAddr, sizeof(localAddr)); if (rc == -1) { printf("%s: cannot bind port TCP %u\n",argv[0],LCDDPORT); @@ -392,6 +393,7 @@ int main(int argc, char *argv[]) } /* connect to server */ + /* coverity[uninit_use_in_call] */ rc = connect(sd, (struct sockaddr *) &servAddr, sizeof(servAddr)); if (rc == -1) { perror("cannot connect "); diff --git a/monitor_nmea.c b/monitor_nmea.c index 6a632006..fb957772 100644 --- a/monitor_nmea.c +++ b/monitor_nmea.c @@ -329,13 +329,13 @@ static void nmea_update(void) if (pps_thread_lastpps(&session, &drift) > 0) { /* NOTE: can not use double here due to precision requirements */ struct timespec timedelta; - char buf[22]; TS_SUB( &timedelta, &drift.clock, &drift.real); if ( 86400 < (long)labs(timedelta.tv_sec) ) { /* more than one day off, overflow */ /* need a bigger field to show it */ (void)mvwprintw(gpgsawin, 4, 13, "> 1 day"); } else { + char buf[22]; (void)timespec_str( &timedelta, buf, sizeof(buf) ); (void)mvwprintw(gpgsawin, 4, 13, "%s", buf); } diff --git a/monitor_sirf.c b/monitor_sirf.c index f99a85ac..b4a59608 100644 --- a/monitor_sirf.c +++ b/monitor_sirf.c @@ -593,13 +593,13 @@ static void sirf_update(void) if (pps_thread_lastpps(&session, &drift) > 0) { /* NOTE: can not use double here due to precision requirements */ struct timespec timedelta; - char buf2[22]; TS_SUB( &timedelta, &drift.clock, &drift.real); if ( 86400 < (long)labs(timedelta.tv_sec) ) { /* more than one day off, overflow */ /* need a bigger field to show it */ (void)mvwprintw(mid7win, 2, 39, "> 1 day"); } else { + char buf2[22]; (void)timespec_str( &timedelta, buf2, sizeof(buf2) ); (void)mvwprintw(mid7win, 4, 39, "%s", buf2); } diff --git a/monitor_ubx.c b/monitor_ubx.c index 8b4101e2..f73a06b2 100644 --- a/monitor_ubx.c +++ b/monitor_ubx.c @@ -260,13 +260,13 @@ static void ubx_update(void) if (pps_thread_lastpps(&session, &drift) > 0) { /* NOTE: can not use double here due to precision requirements */ struct timespec timedelta; - char buf2[22]; TS_SUB( &timedelta, &drift.clock, &drift.real); if ( 86400 < (long)labs(timedelta.tv_sec) ) { /* more than one day off, overflow */ /* need a bigger field to show it */ (void)mvwprintw(ppswin, 1, 13, "> 1 day"); } else { + char buf2[22]; (void)timespec_str( &timedelta, buf2, sizeof(buf2) ); (void)mvwprintw(ppswin, 1, 13, "%s", buf2); } diff --git a/ppsthread.c b/ppsthread.c index be5c92e4..7a441573 100644 --- a/ppsthread.c +++ b/ppsthread.c @@ -600,8 +600,6 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) } if (ok) { - /* pthread error return */ - int pthread_err; /* offset is the skew from expected to observed pulse time */ double offset; /* delay after last fix */ @@ -654,6 +652,8 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) delay); log1 = "timestamp out of range"; } else { + /* pthread error return */ + int pthread_err; /*@-compdef@*/ last_second_used = last_fixtime_real; if (session->thread_report_hook != NULL) -- cgit v1.2.1