summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2014-08-21 05:03:27 -0400
committerEric S. Raymond <esr@thyrsus.com>2014-08-21 05:03:27 -0400
commit84bf9406e5300602101da1dd8c05c62467cfded0 (patch)
tree1b50e8c11d2a1ff4edda511f6cd5721c91b67d16
parentde0863cfdbe13333745e27b8d58dc40fc8bca191 (diff)
downloadgpsd-84bf9406e5300602101da1dd8c05c62467cfded0.tar.gz
splint/cppcheck/coverity cleanup.
-rw-r--r--SConstruct2
-rw-r--r--gps2udp.c8
-rw-r--r--gpsd.c10
-rw-r--r--gpsd_json.c6
-rw-r--r--gpsmon.c2
-rw-r--r--libgpsmm.cpp1
-rw-r--r--netlib.c2
-rw-r--r--ppsthread.c1
8 files changed, 22 insertions, 10 deletions
diff --git a/SConstruct b/SConstruct
index 80c95f62..980b6f2d 100644
--- a/SConstruct
+++ b/SConstruct
@@ -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"],
diff --git a/gps2udp.c b/gps2udp.c
index 4eb8b48f..dbb6a16d 100644
--- a/gps2udp.c
+++ b/gps2udp.c
@@ -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) {
diff --git a/gpsd.c b/gpsd.c
index d82539fb..e1e0a7f9 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -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\","
diff --git a/gpsmon.c b/gpsmon.c
index 23cad0e8..3e8a7beb 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -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;
diff --git a/netlib.c b/netlib.c
index 51b24e78..bf9e3e44 100644
--- a/netlib.c
+++ b/netlib.c
@@ -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)