diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2013-11-06 14:13:06 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2013-11-06 14:13:06 -0500 |
commit | 6a70ad85340b25b5e3a224d61e4cee7277333969 (patch) | |
tree | fa7ec24ea268fb1fd5d6f611b8931320681bb87b | |
parent | a7280f885cdc98b06c505a8ea4e4db9bd712ca36 (diff) | |
download | gpsd-6a70ad85340b25b5e3a224d61e4cee7277333969.tar.gz |
cppcheck and Coverity cleanup (not yet complete).
All regression tests pass. PPS is live.
-rw-r--r-- | SConstruct | 2 | ||||
-rw-r--r-- | driver_evermore.c | 6 | ||||
-rw-r--r-- | driver_nmea2000.c | 8 | ||||
-rw-r--r-- | hex.c | 12 | ||||
-rw-r--r-- | netlib.c | 7 |
5 files changed, 19 insertions, 16 deletions
@@ -1386,7 +1386,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 -D__COVERITY__ -U__UNUSED__ --template gcc --enable=all --inline-suppr --suppress='*:driver_proto.c' --force $SRCDIR") + "cppcheck -U__UNUSED__ --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/driver_evermore.c b/driver_evermore.c index 238a82f9..681d61b5 100644 --- a/driver_evermore.c +++ b/driver_evermore.c @@ -393,12 +393,14 @@ static gps_mask_t evermore_parse_input(struct gps_device_t *session) st = evermore_parse(session, session->packet.outbuffer, session->packet.outbuflen); return st; + } #ifdef NMEA_ENABLE - } else if (session->packet.type == NMEA_PACKET) { + else if (session->packet.type == NMEA_PACKET) { st = nmea_parse((char *)session->packet.outbuffer, session); return st; + } #endif /* NMEA_ENABLE */ - } else + else return 0; } diff --git a/driver_nmea2000.c b/driver_nmea2000.c index 1fc36345..a0a1db38 100644 --- a/driver_nmea2000.c +++ b/driver_nmea2000.c @@ -1288,8 +1288,10 @@ static void find_pgn(struct can_frame *frame, struct gps_device_t *session) /*@ignore@*//* because the CAN include files choke splint */ if (frame->can_id & 0x80000000) { // cppcheck-suppress unreadVariable - unsigned int source_prio UNUSED; - unsigned int daddr UNUSED; +#ifdef __UNUSED__ + unsigned int source_prio; + unsigned int daddr; +#endif // cppcheck-suppress unreadVariable unsigned int source_pgn; unsigned int source_unit; @@ -1523,7 +1525,7 @@ static gps_mask_t nmea2000_parse_input(struct gps_device_t *session) int nmea2000_open(struct gps_device_t *session) { - char interface_name[strlen(session->gpsdata.dev.path)]; + char interface_name[strlen(session->gpsdata.dev.path)+1]; socket_t sock; int status; int unit_number; @@ -87,20 +87,22 @@ static int hex2bin(const char *s) int gpsd_hexpack( /*@in@*/ const char *src, /*@out@ */ char *dst, size_t len) /* hex2bin source string to destination - destination can be same as source */ { - int i, k, l; + int i, j; /*@ -mustdefine @*/ - l = (int)(strlen(src) / 2); - if ((l < 1) || ((size_t) l > len)) + j = (int)(strlen(src) / 2); + if ((j < 1) || ((size_t) j > len)) return -2; - for (i = 0; i < l; i++) + for (i = 0; i < j; i++) { + int k; if ((k = hex2bin(src + i * 2)) != -1) dst[i] = (char)(k & 0xff); else return -1; + } (void)memset(dst + i, '\0', (size_t) (len - i)); - return l; + return j; /*@ +mustdefine @*/ } @@ -30,10 +30,9 @@ socket_t netlib_connectsock(int af, const char *host, const char *service, struct addrinfo hints; struct addrinfo *result, *rp; int ret, type, proto, one = 1; - socket_t s = -1; + socket_t s; bool bind_me; - /* cppcheck-suppress redundantAssignment */ INVALIDATE_SOCKET(s); /*@-type@*/ ppe = getprotobyname(protocol); @@ -79,8 +78,6 @@ socket_t netlib_connectsock(int af, const char *host, const char *service, else if (setsockopt (s, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one)) == -1) { - if (s > -1) - (void)close(s); ret = NL_NOSOCKOPT; } else { if (bind_me) { @@ -96,7 +93,7 @@ socket_t netlib_connectsock(int af, const char *host, const char *service, } } - if (s > -1) { + if (!BAD_SOCKET(s)) { (void)close(s); } } |