summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2015-03-13 08:44:04 -0400
committerEric S. Raymond <esr@thyrsus.com>2015-03-13 08:44:04 -0400
commitdf28d9d7f9eabd2373df031fa2939d0b41ee6caa (patch)
tree71ea48f96eeb2d42457764a0e64c0c109c92ffa7
parentf0a7a853d5eac933f60b562f3b44102296c9e23f (diff)
downloadgpsd-df28d9d7f9eabd2373df031fa2939d0b41ee6caa.tar.gz
splint/cppcheck/coverity prerelease cleanup.
-rw-r--r--compiler.h4
-rw-r--r--gps/fake.py2
-rw-r--r--gpsd.c5
-rw-r--r--gpsd_json.c7
-rw-r--r--libgps_shm.c2
-rw-r--r--libgpsd_core.c5
-rw-r--r--ntpshmwrite.c2
-rw-r--r--ppsthread.c4
-rw-r--r--timehint.c2
-rw-r--r--timespec_str.c2
-rw-r--r--timespec_str.h2
11 files changed, 23 insertions, 14 deletions
diff --git a/compiler.h b/compiler.h
index e33a4899..f0041384 100644
--- a/compiler.h
+++ b/compiler.h
@@ -46,7 +46,9 @@
#ifndef S_SPLINT_S
#ifdef HAVE_STDATOMIC_H
+#ifndef __COVERITY__ /* Coverity is confused by a GNU typedef */
#include <stdatomic.h>
+#endif /* __COVERITY__ */
#endif /* HAVE_STDATOMIC_H */
#endif /* S_SPLINT_S */
@@ -59,7 +61,9 @@ static /*@unused@*/ inline void memory_barrier(void)
{
#ifndef S_SPLINT_S
#ifdef STD_ATOMIC_H
+#ifndef __COVERITY__
atomic_thread_fence(memory_order_seq_cst);
+#endif /* __COVERITY__ */
#elif defined(HAVE_OSATOMIC_H)
OSMemoryBarrier();
#elif defined(__GNUC__)
diff --git a/gps/fake.py b/gps/fake.py
index 3d633fed..d6768626 100644
--- a/gps/fake.py
+++ b/gps/fake.py
@@ -263,7 +263,7 @@ class FakePTY(FakeGPS):
}
(self.fd, self.slave_fd) = pty.openpty()
self.byname = os.ttyname(self.slave_fd)
- os.chmod( self.byname, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IROTH | stat.S_IWOTH );
+ os.chmod( self.byname, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IROTH | stat.S_IWOTH )
(iflag, oflag, cflag, lflag, ispeed, ospeed, cc) = termios.tcgetattr(self.slave_fd)
cc[termios.VMIN] = 1
cflag &= ~(termios.PARENB | termios.PARODD | termios.CRTSCTS)
diff --git a/gpsd.c b/gpsd.c
index 9526ead5..aafb126f 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -1966,7 +1966,7 @@ int main(int argc, char *argv[])
}
/*@+unrecog@*/
- if (pid_file) {
+ if (pid_file != NULL) {
FILE *fp;
if ((fp = fopen(pid_file, "w")) != NULL) {
@@ -1991,7 +1991,8 @@ int main(int argc, char *argv[])
gpsd_log(&context.errout, LOG_ERR,
"command sockets creation failed, netlib errors %d, %d\n",
msocks[0], msocks[1]);
- (void)unlink(pid_file);
+ if (pid_file != NULL)
+ (void)unlink(pid_file);
exit(EXIT_FAILURE);
}
gpsd_log(&context.errout, LOG_INF, "listening on port %s\n", gpsd_service);
diff --git a/gpsd_json.c b/gpsd_json.c
index 4b86df43..c7ceb4d2 100644
--- a/gpsd_json.c
+++ b/gpsd_json.c
@@ -182,13 +182,14 @@ void json_tpv_dump(const struct gps_device_t *session,
str_appendf(reply, replylen, "\"epc\":%.2f,", gpsdata->fix.epc);
#ifdef TIMING_ENABLE
if (policy->timing) {
+ /*@-type -formattype@*/ /* splint is confused about struct timespec */
char rtime_str[TIMESPEC_LEN];
struct timespec rtime_tmp;
- clock_gettime(CLOCK_REALTIME, &rtime_tmp);
- timespec_str(&rtime_tmp, rtime_str, sizeof(rtime_str));
+ /*@i@*/(int)clock_gettime(CLOCK_REALTIME, &rtime_tmp);
+ /*@i1@*/timespec_str(&rtime_tmp, rtime_str, sizeof(rtime_str));
+ /*@-formattype@*/
str_appendf(reply, replylen, "\"rtime\":%s,", rtime_str);
#ifdef PPS_ENABLE
- /*@-type -formattype@*/ /* splint is confused about struct timespec */
if (session->pps_thread.ppsout_count) {
char ts_str[TIMESPEC_LEN];
struct timespec clock_tmp = session->pps_thread.ppsout_last.clock;
diff --git a/libgps_shm.c b/libgps_shm.c
index bc245bea..11ca6514 100644
--- a/libgps_shm.c
+++ b/libgps_shm.c
@@ -78,8 +78,8 @@ bool gps_shm_waiting(const struct gps_data_t *gpsdata, int timeout)
/* timeout is in uSec */
{
volatile struct shmexport_t *shared = (struct shmexport_t *)PRIVATE(gpsdata)->shmseg;
- timestamp_t endtime = timestamp() + (((double)timeout)/1000000);;
volatile bool newdata = false;
+ timestamp_t endtime = timestamp() + (((double)timeout)/1000000);;
/* busy-waiting sucks, but there's not really an alternative */
for (;;) {
diff --git a/libgpsd_core.c b/libgpsd_core.c
index 5923e240..35510668 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -1438,7 +1438,8 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
gps_merge_fix(&session->gpsdata.fix,
session->gpsdata.set, &session->newdata);
#ifndef NOFLOATS_ENABLE
- gpsd_error_model(session, &session->gpsdata.fix, &session->oldfix);
+ /*@i1@*/gpsd_error_model(session,
+ &session->gpsdata.fix, &session->oldfix);
#endif /* NOFLOATS_ENABLE */
/*@+nullderef -nullpass@*/
@@ -1665,7 +1666,7 @@ void ntp_latch(struct gps_device_t *device, struct timedelta_t /*@out@*/*td)
/* this should be an invariant of the way this function is called */
assert(isnan(device->newdata.time)==0);
- /*@i2@*/(void)clock_gettime(CLOCK_REALTIME, &td->clock);
+ (void)clock_gettime(CLOCK_REALTIME, &td->clock);
fix_time = device->newdata.time;
#ifdef TIMEHINT_ENABLE
diff --git a/ntpshmwrite.c b/ntpshmwrite.c
index 6370ee47..217f9514 100644
--- a/ntpshmwrite.c
+++ b/ntpshmwrite.c
@@ -33,11 +33,13 @@ void ntp_write(volatile struct shmTime *shmseg,
* GPS emits leap pending for 3 months prior to insertion
* NTP expects leap pending for only 1 month prior to insertion
* Per http://bugs.ntp.org/1090 */
+ /*@-type@*//* splint is confused about struct timespec */
(void)gmtime_r( &(td->real.tv_sec), &tm);
if ( 5 != tm.tm_mon && 11 != tm.tm_mon ) {
/* Not june, not December, no way */
leap_notify = LEAP_NOWARNING;
}
+ /*@-type@*/
/* we use the shmTime mode 1 protocol
*
diff --git a/ppsthread.c b/ppsthread.c
index c6de2f91..6f3594a5 100644
--- a/ppsthread.c
+++ b/ppsthread.c
@@ -148,8 +148,6 @@ static int init_kernel_pps(volatile struct pps_thread_t *pps_thread)
/* These variables are only needed by Linux to find /dev/ppsN. */
int ldisc = 18; /* the PPS line discipline */
glob_t globbuf;
- size_t i; /* to match type of globbuf.gl_pathc */
- char pps_num = '\0'; /* /dev/pps[pps_num] is our device */
char path[PATH_MAX] = "";
#endif
@@ -172,6 +170,8 @@ static int init_kernel_pps(volatile struct pps_thread_t *pps_thread)
if (strncmp(pps_thread->devicename, "/dev/pps", 8) == 0)
strlcpy(path, pps_thread->devicename, sizeof(path));
else {
+ char pps_num = '\0'; /* /dev/pps[pps_num] is our device */
+ size_t i; /* to match type of globbuf.gl_pathc */
/*
* Otherwise one must make calls to associate a serial port with a
* /dev/ppsN device and then grovel in system data to determine
diff --git a/timehint.c b/timehint.c
index 8e6faa63..7db0d008 100644
--- a/timehint.c
+++ b/timehint.c
@@ -324,7 +324,7 @@ static void chrony_send(struct gps_device_t *session, struct timedelta_t *td)
* GPS emits leap pending for 3 months prior to insertion
* NTP expects leap pending for only 1 month prior to insertion
* Per http://bugs.ntp.org/1090 */
- (void)gmtime_r( &(td->real.tv_sec), &tm);
+ /*@i2@*/(void)gmtime_r( &(td->real.tv_sec), &tm);
if ( 5 != tm.tm_mon && 11 != tm.tm_mon ) {
/* Not june, not December, no way */
leap_notify = LEAP_NOWARNING;
diff --git a/timespec_str.c b/timespec_str.c
index 69e045ee..6adadd7d 100644
--- a/timespec_str.c
+++ b/timespec_str.c
@@ -36,7 +36,7 @@
* So 21 digits like this: "-2147483647.123456789"
*
*/
-void timespec_str(const struct timespec *ts, /*@out@*/char *buf, int buf_size)
+void timespec_str(const struct timespec *ts, /*@out@*/char *buf, size_t buf_size)
{
char sign = ' ';
diff --git a/timespec_str.h b/timespec_str.h
index b644c7d0..50651509 100644
--- a/timespec_str.h
+++ b/timespec_str.h
@@ -8,7 +8,7 @@
#define TIMESPEC_LEN 22 /* required length of a timespec buffer */
-extern void timespec_str(const struct timespec *, /*@out@*/char *, int);
+extern void timespec_str(const struct timespec *, /*@out@*/char *, size_t);
#endif /* GPSD_TIMESPEC_H */