diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2012-05-18 04:44:01 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2012-05-18 04:44:01 -0400 |
commit | 7ee2bf88e99f0ffa027c5839e5ae85d55752ac1b (patch) | |
tree | 8a224b5479e288537d51d0f044df7e8cd532b574 | |
parent | c46e369a26bb693e744206979ee9d8674c27f1da (diff) | |
download | gpsd-7ee2bf88e99f0ffa027c5839e5ae85d55752ac1b.tar.gz |
More cppcheck warning fixups. All regression tests pass.
-rw-r--r-- | bits.c | 3 | ||||
-rw-r--r-- | driver_italk.c | 1 | ||||
-rw-r--r-- | driver_navcom.c | 3 | ||||
-rw-r--r-- | driver_nmea0183.c | 4 | ||||
-rw-r--r-- | driver_nmea2000.c | 18 | ||||
-rw-r--r-- | gpsctl.c | 1 | ||||
-rw-r--r-- | gpsd.c | 2 | ||||
-rw-r--r-- | libgps_sock.c | 3 | ||||
-rw-r--r-- | libgpsmm.h | 2 | ||||
-rw-r--r-- | monitor_garmin.c | 2 | ||||
-rw-r--r-- | serial.c | 1 |
11 files changed, 28 insertions, 12 deletions
@@ -74,6 +74,7 @@ int64_t sbits(char buf[], unsigned int start, unsigned int width, bool le) } #ifdef __UNUSED__ +// cppcheck-suppress unusedFunction u_int16_t swap_u16(u_int16_t i) /* byte-swap a 16-bit unsigned int */ { @@ -85,6 +86,7 @@ u_int16_t swap_u16(u_int16_t i) return (c1 << 8) + c2; } +// cppcheck-suppress unusedFunction u_int32_t swap_u32(u_int32_t i) /* byte-swap a 32-bit unsigned int */ { @@ -98,6 +100,7 @@ u_int32_t swap_u32(u_int32_t i) return ((u_int32_t)c1 << 24) + ((u_int32_t)c2 << 16) + ((u_int32_t)c3 << 8) + c4; } +// cppcheck-suppress unusedFunction u_int64_t swap_u64(u_int64_t i) /* byte-swap a 64-bit unsigned int */ { diff --git a/driver_italk.c b/driver_italk.c index 2ac0a532..0fdf863b 100644 --- a/driver_italk.c +++ b/driver_italk.c @@ -392,6 +392,7 @@ static gps_mask_t italk_parse_input(struct gps_device_t *session) } #ifdef __future__ +// cppcheck-suppress unusedFunction static void italk_ping(struct gps_device_t *session) /* send a "ping". it may help us detect an itrax more quickly */ { diff --git a/driver_navcom.c b/driver_navcom.c index ac5adf07..655c745c 100644 --- a/driver_navcom.c +++ b/driver_navcom.c @@ -110,8 +110,9 @@ static void navcom_cmd_0x20(struct gps_device_t *session, uint8_t block_id, } /*@ unused @*/ -/* Changes the LED settings in the receiver */ +// cppcheck-suppress unusedFunction static void UNUSED navcom_cmd_0x3f(struct gps_device_t *session) +/* Changes the LED settings in the receiver */ { unsigned char msg[12]; putbyte(msg, 0, 0x02); diff --git a/driver_nmea0183.c b/driver_nmea0183.c index 5e6c84dd..3494cef8 100644 --- a/driver_nmea0183.c +++ b/driver_nmea0183.c @@ -22,10 +22,11 @@ static void do_lat_lon(char *field[], struct gps_fix_t *out) /* process a pair of latitude/longitude fields starting at field index BEGIN */ { - double lat, lon, d, m; + double d, m; char str[20], *p; if (*(p = field[0]) != '\0') { + double lat; (void)strlcpy(str, p, sizeof(str)); lat = atof(str); m = 100.0 * modf(lat / 100.0, &d); @@ -36,6 +37,7 @@ static void do_lat_lon(char *field[], struct gps_fix_t *out) out->latitude = lat; } if (*(p = field[2]) != '\0') { + double lon; (void)strlcpy(str, p, sizeof(str)); lon = atof(str); m = 100.0 * modf(lon / 100.0, &d); diff --git a/driver_nmea2000.c b/driver_nmea2000.c index 1a503d21..1db66860 100644 --- a/driver_nmea2000.c +++ b/driver_nmea2000.c @@ -46,11 +46,11 @@ FILE *logFile = NULL; static int print_data(unsigned char *buffer, int len, PGN *pgn) { - int l1, l2, ptr; - char bu[128]; - /*@-bufferoverflowhigh@*/ if ((libgps_debuglevel >= LOG_IO) != 0) { + int l1, l2, ptr; + char bu[128]; + ptr = 0; l2 = sprintf(&bu[ptr], "got data:%6u:%3d: ", pgn->pgn, len); ptr += l2; @@ -463,17 +463,18 @@ static /*@null@*/ PGN *search_pgnlist(unsigned int pgn, PGN *pgnlist) static void find_pgn(struct can_frame *frame, struct gps_device_t *session) { PGN *work; - unsigned int daddr UNUSED; - unsigned int source_pgn; - unsigned int source_prio UNUSED; - unsigned int source_unit; session->driver.nmea2000.workpgn = NULL; /*@ignore@*//* because the CAN include files choke splint */ #if LOG_FILE if (frame->can_id & 0x80000000) { - int l1; + // cppcheck-suppress unreadVariable + unsigned int source_prio UNUSED; + unsigned int source_pgn; + unsigned int source_unit; + // cppcheck-suppress unreadVariable + unsigned int daddr UNUSED; if (logFile != NULL) { struct timespec msgTime; @@ -485,6 +486,7 @@ static void find_pgn(struct can_frame *frame, struct gps_device_t *session) (unsigned int)msgTime.tv_nsec/1000, frame->can_id & 0x1ffffff); if ((frame->can_dlc & 0x0f) > 0) { + int l1; for(l1=0;l1<(frame->can_dlc & 0x0f);l1++) { fprintf(logFile, "%02x", frame->data[l1]); } @@ -444,7 +444,6 @@ 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) { @@ -1755,7 +1755,7 @@ static void netgnss_autoconnect(struct gps_context_t *context, char *cp = strchr(buf, '#'); if (cp != NULL) *cp = '\0'; - if (sscanf(buf, "%lf %lf %256s", &hold.lat, &hold.lon, hold.server) == + if (sscanf(buf, "%32lf %32lf %256s", &hold.lat, &hold.lon, hold.server) == 3) { hold.dist = earth_distance(lat, lon, hold.lat, hold.lon); tp = NULL; diff --git a/libgps_sock.c b/libgps_sock.c index 9612a6e9..ea3a4b39 100644 --- a/libgps_sock.c +++ b/libgps_sock.c @@ -391,6 +391,7 @@ int gps_unpack(char *buf, struct gps_data_t *gpsdata) if (sp[2] == '?') gpsdata->online = (timestamp_t)-1; else { + // cppcheck-suppress invalidscanf (void)sscanf(sp, "X=%lf", &gpsdata->online); gpsdata->set |= ONLINE_SET; } @@ -403,6 +404,7 @@ int gps_unpack(char *buf, struct gps_data_t *gpsdata) double f4; char tag[MAXTAGLEN + 1], timestamp[21]; + // cppcheck-suppress invalidscanf (void)sscanf(sp, "Y=%8s %20s %d ", tag, timestamp, &gpsdata->satellites_visible); @@ -419,6 +421,7 @@ int gps_unpack(char *buf, struct gps_data_t *gpsdata) if ((sp != NULL) && ((sp = strchr(sp, ':')) != NULL)) { sp++; + // cppcheck-suppress invalidscanf (void)sscanf(sp, "%d %d %d %lf %d", &i1, &i2, &i3, &f4, &i5); gpsdata->PRN[j] = i1; @@ -26,10 +26,12 @@ class gpsmm { class LIBQGPSMMSHARED_EXPORT gpsmm { #endif public: + // cppcheck-suppress uninitVar gpsmm(const char *host, const char *port) : to_user(0) { gps_inner_open(host, port); } #ifdef __UNUSED__ + // cppcheck-suppress uninitVar gpsmm(void) : to_user(0) { gps_inner_open("localhost", DEFAULT_GPSD_PORT); diff --git a/monitor_garmin.c b/monitor_garmin.c index dbea8e94..5f0fbf61 100644 --- a/monitor_garmin.c +++ b/monitor_garmin.c @@ -58,6 +58,7 @@ typedef struct typedef struct { uint32_t cycles; + // cppcheck-suppress unusedStructMember double pr; uint16_t phase; int8_t slp_dtct; @@ -67,6 +68,7 @@ typedef struct } cpo_rcv_sv_data; typedef struct { + // cppcheck-suppress unusedStructMember double rcvr_tow; int16_t rcvr_wn; cpo_rcv_sv_data sv[GARMIN_CHANNELS]; @@ -546,6 +546,7 @@ bool gpsd_next_hunt_setting(struct gps_device_t * session) #endif /* FIXED_STOP_BITS */ } #endif /* FIXED_PORT_SPEED */ + // cppcheck-suppress unreachableCode gpsd_set_speed(session, #ifdef FIXED_PORT_SPEED FIXED_PORT_SPEED, |