diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2014-08-21 05:03:27 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2014-08-21 05:03:27 -0400 |
commit | 84bf9406e5300602101da1dd8c05c62467cfded0 (patch) | |
tree | 1b50e8c11d2a1ff4edda511f6cd5721c91b67d16 | |
parent | de0863cfdbe13333745e27b8d58dc40fc8bca191 (diff) | |
download | gpsd-84bf9406e5300602101da1dd8c05c62467cfded0.tar.gz |
splint/cppcheck/coverity cleanup.
-rw-r--r-- | SConstruct | 2 | ||||
-rw-r--r-- | gps2udp.c | 8 | ||||
-rw-r--r-- | gpsd.c | 10 | ||||
-rw-r--r-- | gpsd_json.c | 6 | ||||
-rw-r--r-- | gpsmon.c | 2 | ||||
-rw-r--r-- | libgpsmm.cpp | 1 | ||||
-rw-r--r-- | netlib.c | 2 | ||||
-rw-r--r-- | ppsthread.c | 1 |
8 files changed, 22 insertions, 10 deletions
@@ -1457,7 +1457,7 @@ for (target,sources,description,params) in splint_table: # Putting in all these -U flags speeds up cppcheck and allows it to look # at configurations we actually care about. Utility("cppcheck", ["gpsd.h", "packet_names.h"], - "cppcheck -U__UNUSED__ -US_SPLINT_S -U__COVERITY__ -U__future__ -ULIMITED_MAX_CLIENTS -ULIMITED_MAX_DEVICES -UAF_UNSPEC -UINADDR_ANY -UFIXED_PORT_SPEED -UFIXED_STOP_BITS -U_WIN32 -U__CYGWIN__ -UPATH_MAX -UHAVE_STRLCAT -UHAVE_STRLCPY --template gcc --enable=all --inline-suppr --suppress='*:driver_proto.c' --force $SRCDIR") + "cppcheck -U__UNUSED__ -UUSE_QT -US_SPLINT_S -U__COVERITY__ -U__future__ -ULIMITED_MAX_CLIENTS -ULIMITED_MAX_DEVICES -UAF_UNSPEC -UINADDR_ANY -UFIXED_PORT_SPEED -UFIXED_STOP_BITS -U_WIN32 -U__CYGWIN__ -UPATH_MAX -UHAVE_STRLCAT -UHAVE_STRLCPY -UIPTOS_LOWDELAY -UIPV6_TCLASS -UTCP_NODELAY -UTIOCMIWAIT --template gcc --enable=all --inline-suppr --suppress='*:driver_proto.c' --force $SRCDIR") # Experimental check with clang analyzer Utility("scan-build", ["gpsd.h", "packet_names.h"], @@ -106,7 +106,7 @@ static int send_udp (char *nmeastring, size_t ind) buffer[ind] = '\r'; ind++; buffer[ind] = '\0'; - if (!(flags & WATCH_JSON) && buffer[0] == '{') { + if ((flags & WATCH_JSON)==0 && buffer[0] == '{') { /* do not send JSON when not configured to do so */ return 0; } @@ -139,7 +139,7 @@ static int open_udp(char **hostport) { char *hostname = NULL; char *portname = NULL; - char *endptr = '\0'; + char *endptr = NULL; int portnum; struct hostent *hp; @@ -154,11 +154,13 @@ static int open_udp(char **hostport) } errno = 0; - portnum = strtol(portname, &endptr, 10); + portnum = (int)strtol(portname, &endptr, 10); + /*@+charint@*/ if (1 > portnum || 65535 < portnum || '\0' != *endptr || 0 != errno) { (void)fprintf(stderr, "gps2udp: syntax is [-u hostname:port] [%s] is not a valid port number\n",portname); return (-1); } + /*@-charint@*/ sock[channel]= socket(AF_INET, SOCK_DGRAM, 0); if (sock[channel] < 0) { @@ -399,11 +399,13 @@ static socket_t passivesock_af(int af, char *service, char *tcp_or_udp, int qlen /* see PF_INET6 case below */ s = socket(PF_INET, type, proto); if (s > -1 ) { + /*@-unrecog@*/ /* Set packet priority */ - if (setsockopt(s, IPPROTO_IP, IP_TOS, &dscp, sizeof(dscp)) == -1) + if (setsockopt(s, IPPROTO_IP, IP_TOS, &dscp, sizeof(dscp)) == -1) gpsd_report(context.debug, LOG_WARN, "Warning: SETSOCKOPT TOS failed\n"); } + /*@+unrecog@*/ break; #ifdef IPV6_ENABLE @@ -1589,7 +1591,9 @@ static void all_reports(struct gps_device_t *device, gps_mask_t changed) (void)ntpshm_put(device, device->shmIndex, &td); /*@+compdef@*/ device->last_fixtime.real = device->newdata.time; +#ifndef S_SPLINT_S device->last_fixtime.clock = td.clock.tv_sec + td.clock.tv_nsec / 1e9; +#endif /* S_SPLINT_S */ } #endif /* NTPSHM_ENABLE */ @@ -1913,7 +1917,7 @@ int main(int argc, char *argv[]) #ifdef SYSTEMD_ENABLE sd_socket_count = sd_get_socket_count(); - if (sd_socket_count > 0 && control_socket) { + if (sd_socket_count > 0 && control_socket != NULL) { gpsd_report(context.debug, LOG_WARN, "control socket passed on command line ignored\n"); control_socket = NULL; @@ -2129,7 +2133,9 @@ int main(int argc, char *argv[]) #ifdef SOCKET_EXPORT_ENABLE for (i = 0; i < NITEMS(subscribers); i++) { subscribers[i].fd = UNALLOCATED_FD; +#ifndef S_SPLINT_S (void)pthread_mutex_init(&subscribers[i].mutex, NULL); +#endif /* S_SPLINT_S */ } #endif /* SOCKET_EXPORT_ENABLE*/ diff --git a/gpsd_json.c b/gpsd_json.c index 30bcf93d..c76415b2 100644 --- a/gpsd_json.c +++ b/gpsd_json.c @@ -2823,8 +2823,8 @@ void json_aivdm_dump(const struct ais_t *ais, * This is a kluge. */ if (cp->code == 0 - || ais->type8.dac200fid10.hazard >= NITEMS(hazard_types) - || !isascii(ais->type8.dac200fid10.vin[0])) + || (int)ais->type8.dac200fid10.hazard >= NITEMS(hazard_types) + || !isascii((int)ais->type8.dac200fid10.vin[0])) break; (void)snprintf(buf + strlen(buf), buflen - strlen(buf), "\"vin\":\"%s\",\"length\":%u,\"beam\":%u," @@ -2855,7 +2855,7 @@ void json_aivdm_dump(const struct ais_t *ais, * FIXME: AIS struct should have "structured" bit set by driver * This is a kluge. */ - if (ais->type8.dac200fid23.type >= NITEMS(emma_types)) + if ((int)ais->type8.dac200fid23.type >= NITEMS(emma_types)) break; (void)snprintf(buf + strlen(buf), buflen - strlen(buf), "\"start\":\"%4u-%02u-%02uT%02u:%02u\"," @@ -1197,10 +1197,12 @@ int main(int argc, char **argv) } if (serial) { + assert(source.device != NULL); /* clue to splint */ (void) strlcpy(session.gpsdata.dev.path, source.device, sizeof(session.gpsdata.dev.path)); } else { + assert(source.server != NULL); /* clue to splint */ if (strstr(source.server, "//") == 0) (void) strlcpy(session.gpsdata.dev.path, "tcp://", diff --git a/libgpsmm.cpp b/libgpsmm.cpp index 2707e44a..c370208a 100644 --- a/libgpsmm.cpp +++ b/libgpsmm.cpp @@ -83,6 +83,7 @@ void gpsmm::enable_debug(int level, FILE *fp) #endif /* CLIENTDEBUG_ENABLE */ } +// cppcheck-suppress unusedFunction bool gpsmm::is_open(void) { return to_user != NULL; @@ -102,7 +102,7 @@ socket_t netlib_connectsock(int af, const char *host, const char *service, #ifndef S_SPLINT_S freeaddrinfo(result); #endif /* S_SPLINT_S */ - if (ret) + if (ret != 0 || s < 0) return ret; #ifdef IPTOS_LOWDELAY diff --git a/ppsthread.c b/ppsthread.c index ed5c7efd..49883cb3 100644 --- a/ppsthread.c +++ b/ppsthread.c @@ -340,6 +340,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) #endif /* TIOCMIWAIT */ /* ok and log used by KPPS and TIOCMIWAIT */ + // cppcheck-suppress redundantAssignment ok = false; log = NULL; #if defined(HAVE_SYS_TIMEPPS_H) && !defined(S_SPLINT_S) |