summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SConstruct2
-rw-r--r--driver_evermore.c6
-rw-r--r--driver_nmea2000.c8
-rw-r--r--hex.c12
-rw-r--r--netlib.c7
5 files changed, 19 insertions, 16 deletions
diff --git a/SConstruct b/SConstruct
index 5908cdf0..83589ce8 100644
--- a/SConstruct
+++ b/SConstruct
@@ -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;
diff --git a/hex.c b/hex.c
index 95f4121d..ac1705f3 100644
--- a/hex.c
+++ b/hex.c
@@ -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 @*/
}
diff --git a/netlib.c b/netlib.c
index 4be2660a..36921441 100644
--- a/netlib.c
+++ b/netlib.c
@@ -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);
}
}