summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SConstruct2
-rw-r--r--driver_nmea2000.c6
-rw-r--r--gps2udp.c22
-rw-r--r--libgpsd_core.c6
-rw-r--r--ntpshm.c4
5 files changed, 25 insertions, 15 deletions
diff --git a/SConstruct b/SConstruct
index 43f13e76..5908cdf0 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 --template gcc --enable=all --inline-suppr --suppress='*:driver_proto.c' --force $SRCDIR")
+ "cppcheck -D__COVERITY__ -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_nmea2000.c b/driver_nmea2000.c
index f9c1ae47..1fc36345 100644
--- a/driver_nmea2000.c
+++ b/driver_nmea2000.c
@@ -1317,15 +1317,21 @@ static void find_pgn(struct can_frame *frame, struct gps_device_t *session)
session->driver.nmea2000.can_msgcnt += 1;
/*@ignore@*//* because the CAN include files choke splint */
source_pgn = (frame->can_id >> 8) & 0x1ffff;
+#ifdef __UNUSED__
source_prio = (frame->can_id >> 26) & 0x7;
+#endif
source_unit = frame->can_id & 0x0ff;
/*@end@*/
if (((source_pgn & 0x0ff00) >> 8) < 240) {
+#ifdef __UNUSED__
daddr = source_pgn & 0x000ff;
+#endif
source_pgn = source_pgn & 0x1ff00;
} else {
+#ifdef __UNUSED__
daddr = 0xff;
+#endif
}
if (session->driver.nmea2000.unit_valid == 0) {
diff --git a/gps2udp.c b/gps2udp.c
index 2d76d12b..9a4d0436 100644
--- a/gps2udp.c
+++ b/gps2udp.c
@@ -80,7 +80,7 @@ static bool aisonly = false;
static int send_udp (char *nmeastring, size_t ind)
{
- char message [255];
+ char message[255];
char *buffer;
int channel;
@@ -88,7 +88,7 @@ static int send_udp (char *nmeastring, size_t ind)
if (ind == 0) {
/* compute message size and add 0x0a 0x0d */
for (ind=0; nmeastring [ind] != '\0'; ind ++) {
- if (ind >= sizeof(message)) {
+ if (ind >= sizeof(message) - 3) {
fprintf(stderr, "gps2udp: too big [%s] \n", nmeastring);
return -1;
}
@@ -129,7 +129,7 @@ static int open_udp(char **hostport)
/* Open and bind udp socket to host */
{
int channel;
- for (channel=0; channel <udpchannel; channel ++)
+ for (channel=0; channel < udpchannel; channel ++)
{
struct hostent *hp;
char *hostname = NULL;
@@ -190,7 +190,6 @@ static void usage(void)
static void connect2gpsd(bool restart)
/* loop until we connect with gpsd */
{
- int status;
unsigned int delay;
if (restart) {
@@ -203,7 +202,7 @@ static void connect2gpsd(bool restart)
/* loop until we reach GPSd */
for (delay = 10; ; delay = delay*2) {
- status = gps_open(gpsd_source.server, gpsd_source.port, &gpsdata);
+ int status = gps_open(gpsd_source.server, gpsd_source.port, &gpsdata);
if (status != 0) {
(void)fprintf(stderr,
"gps2udp [%s] connection failed at %s:%s\n",
@@ -227,7 +226,7 @@ static ssize_t read_gpsd(char *message, size_t len)
{
struct timeval tv;
fd_set fds,master;
- int result, ind;
+ int ind;
char c;
int retry=0;
@@ -237,6 +236,7 @@ static ssize_t read_gpsd(char *message, size_t len)
/* loop until we get some data or an error */
for (ind = 0; ind < (int)len;) {
+ int result;
/* prepare for a blocking read with a 10s timeout */
tv.tv_sec = 10;
tv.tv_usec = 0;
@@ -331,10 +331,12 @@ static unsigned int AISGetInt(unsigned char *bitbytes, unsigned int sp, unsigned
{
unsigned int acc = 0;
unsigned int s0p = sp-1; // to zero base
- unsigned int cp, cx, c0, i;
+ unsigned int i;
for(i=0 ; i<len ; i++)
{
+ unsigned int cp, cx, c0;
+
acc = acc << 1;
cp = (s0p + i) / 6;
cx = (unsigned int)bitbytes[cp]; // what if cp >= byte_length?
@@ -350,7 +352,7 @@ int main(int argc, char **argv)
{
bool daemonize = false;
long count = -1;
- int option, status;
+ int option;
char *udphostport[MAX_UDP_DEST];
flags = WATCH_ENABLE;
@@ -380,7 +382,7 @@ int main(int argc, char **argv)
daemonize = true;
break;
case 'u':
- if (udpchannel > MAX_UDP_DEST) {
+ if (udpchannel >= MAX_UDP_DEST) {
(void)fprintf(stderr,
"gps2udp: too many UDP destinations (max=%d)\n",
MAX_UDP_DEST);
@@ -413,7 +415,7 @@ int main(int argc, char **argv)
/* Open UDP port */
if (udpchannel > 0) {
- status = open_udp(udphostport);
+ int status = open_udp(udphostport);
if (status !=0) exit (1);
}
diff --git a/libgpsd_core.c b/libgpsd_core.c
index 80b24e2b..ce567de0 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -362,7 +362,7 @@ int gpsd_open(struct gps_device_t *session)
return session->gpsdata.gps_fd;
/* otherwise, could be an TCP data feed */
} else if (strncmp(session->gpsdata.dev.path, "tcp://", 6) == 0) {
- char server[strlen(session->gpsdata.dev.path)], *port;
+ char server[strlen(session->gpsdata.dev.path)+1], *port;
socket_t dsock;
(void)strlcpy(server, session->gpsdata.dev.path + 6, sizeof(server));
INVALIDATE_SOCKET(session->gpsdata.gps_fd);
@@ -389,7 +389,7 @@ int gpsd_open(struct gps_device_t *session)
return session->gpsdata.gps_fd;
/* or could be UDP */
} else if (strncmp(session->gpsdata.dev.path, "udp://", 6) == 0) {
- char server[strlen(session->gpsdata.dev.path)], *port;
+ char server[strlen(session->gpsdata.dev.path)+1], *port;
socket_t dsock;
(void)strlcpy(server, session->gpsdata.dev.path + 6, sizeof(server));
INVALIDATE_SOCKET(session->gpsdata.gps_fd);
@@ -419,7 +419,7 @@ int gpsd_open(struct gps_device_t *session)
#ifdef PASSTHROUGH_ENABLE
if (strncmp(session->gpsdata.dev.path, "gpsd://", 7) == 0) {
/*@-branchstate -nullpass@*/
- char server[strlen(session->gpsdata.dev.path)], *port;
+ char server[strlen(session->gpsdata.dev.path)+1], *port;
socket_t dsock;
(void)strlcpy(server, session->gpsdata.dev.path + 7, sizeof(server));
INVALIDATE_SOCKET(session->gpsdata.gps_fd);
diff --git a/ntpshm.c b/ntpshm.c
index a82fbd24..91c1d768 100644
--- a/ntpshm.c
+++ b/ntpshm.c
@@ -298,7 +298,6 @@ struct sock_sample {
double offset;
int pulse;
int leap;
- /* cppcheck-suppress unusedStructMember */
int _pad;
int magic; /* must be SOCK_MAGIC */
};
@@ -355,6 +354,9 @@ static void chrony_send(struct gps_device_t *session, struct timedrift_t *td)
/*@-compdef@*/
sample.offset = timespec_diff_ns(td->real, td->clock) / 1e9;
/*@+compdef@*/
+#ifdef __COVERITY__
+ sample._pad = 0;
+#endif /* __COVERITY__ */
/*@+type@*/
(void)send(session->chronyfd, &sample, sizeof (sample), 0);