summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2013-11-05 18:56:24 -0500
committerEric S. Raymond <esr@thyrsus.com>2013-11-05 18:56:24 -0500
commit209144664fa758bc27f334a32b76fab9813c6f97 (patch)
tree2a6b405315d4ac7498a8a698ad4330cb06cf90cc
parent326523756d2e93cec14d536d3860b4fa48fa10f7 (diff)
downloadgpsd-209144664fa758bc27f334a32b76fab9813c6f97.tar.gz
Partial splint cleanup. All regression tests pass. PPS is live.
-rw-r--r--.splintrc5
-rw-r--r--SConstruct1
-rw-r--r--gpsd.h-tail8
-rw-r--r--gpsmon.c4
-rw-r--r--gpsmon.h2
-rw-r--r--gpxlogger.c2
-rw-r--r--libgps_json.c4
-rw-r--r--libgpsd_core.c4
-rw-r--r--monitor_sirf.c2
-rw-r--r--ntpshm.c8
-rw-r--r--ppsthread.c21
-rw-r--r--sd_socket.c2
12 files changed, 48 insertions, 15 deletions
diff --git a/.splintrc b/.splintrc
index 24bad2ad..9b292835 100644
--- a/.splintrc
+++ b/.splintrc
@@ -18,3 +18,8 @@
-DCRTSCTS=0x00020000
-DONLCR=0x00000002
-D__gnuc_va_list=va_list
+-D__signed__=signed
+-D__pid_t=int
+-D__size_t=size_t
+-Dpps_handle_t=int
+
diff --git a/SConstruct b/SConstruct
index 1ea9fba5..ec3eba80 100644
--- a/SConstruct
+++ b/SConstruct
@@ -1348,6 +1348,7 @@ def Utility(target, source, action):
# Report splint warnings
# Note: test_bits.c is unsplintable because of the PRI64 macros.
+# If you get preprocessor or fatal errors, add +showscan.
splintopts = "-I/usr/include/libusb-1.0 +quiet"
# splint does not know about multi-arch, work around that
ma_status, ma = _getstatusoutput('dpkg-architecture -qDEB_HOST_MULTIARCH')
diff --git a/gpsd.h-tail b/gpsd.h-tail
index ae47c36c..169a3da9 100644
--- a/gpsd.h-tail
+++ b/gpsd.h-tail
@@ -29,11 +29,13 @@
* CONFIG_PPS_DEBUG=y [optional to kernel log pulses]
* CONFIG_PPS_CLIENT_LDISC=y
*/
+#ifndef S_SPLINT_S
#if defined(HAVE_SYS_TIMEPPS_H)
// include unistd.h here as it is missing on older pps-tools releases.
// 'close' is not defined otherwise.
#include <unistd.h>
#include <sys/timepps.h>
+#endif /* S_SPLINT_S */
#endif
#ifdef _WIN32
@@ -997,6 +999,7 @@ void cfmakeraw(struct termios *);
/* Needed because 4.x versions of GCC are really annoying */
#define ignore_return(funcall) assert(funcall != -23)
+#ifndef S_SPLINT_S
#if defined(NTPSHM_ENABLE) || defined(SHM_EXPORT_ENABLE)
/* memory barriers */
static /*@unused@*/ inline void barrier(void) {
@@ -1008,7 +1011,10 @@ static /*@unused@*/ inline void barrier(void) {
# error Memory barriers are not supported. Disable NTPSHM and SHM export.
#endif /* defined(NTPSHM_ENABLE) || defined(SHM_EXPORT_ENABLE) */
}
-#endif /* */
+#endif /* defined(NTPSHM_ENABLE) || defined(SHM_EXPORT_ENABLE) */
+#else
+#define barrier()
+#endif /* S_SPLINT_S */
#endif /* _GPSD_H_ */
// Local variables:
diff --git a/gpsmon.c b/gpsmon.c
index 53865a8b..7784003b 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -45,7 +45,7 @@ extern struct monitor_object_t oncore_mmt, tnt_mmt, aivdm_mmt;
struct gps_device_t session;
WINDOW *devicewin;
bool serial;
-float timedelta = 0;
+double timedelta = 0;
/* These are private */
static struct gps_context_t context;
@@ -837,7 +837,7 @@ static void gpsmon_hook(struct gps_device_t *device, gps_mask_t changed UNUSED)
/*@+observertrans +nullpass +globstate@*/
#ifdef PPS_ENABLE
-static char *pps_report(struct gps_device_t *session UNUSED,
+static /*@observer@*/ char *pps_report(struct gps_device_t *session UNUSED,
struct timedrift_t *td UNUSED,
double edge_offset) {
/*
diff --git a/gpsmon.h b/gpsmon.h
index 370926c3..cc6cd156 100644
--- a/gpsmon.h
+++ b/gpsmon.h
@@ -35,7 +35,7 @@ extern void monitor_complain(const char *fmt, ...);
extern WINDOW *devicewin;
extern struct gps_device_t session;
extern bool serial; /* True - direct mode, False - daemon mode */
-extern float timedelta;
+extern double timedelta;
#endif /* _GPSD_GPSMON_H_ */
/* gpsmon.h ends here */
diff --git a/gpxlogger.c b/gpxlogger.c
index b4875d5a..b8829644 100644
--- a/gpxlogger.c
+++ b/gpxlogger.c
@@ -298,9 +298,11 @@ int main(int argc, char **argv)
source.port = NULL;
source.device = NULL;
} else {
+ /*@-statictrans -observertrans@*/
source.server = (char *)"localhost";
source.port = (char *)DEFAULT_GPSD_PORT;
source.device = NULL;
+ /*@+statictrans +observertrans@*/
}
if (optind < argc) {
diff --git a/libgps_json.c b/libgps_json.c
index d5590c14..83cfbb8e 100644
--- a/libgps_json.c
+++ b/libgps_json.c
@@ -381,10 +381,14 @@ static int json_pps_read(const char *buf, struct gps_data_t *gpsdata,
* This is theoretically dodgy, but in practice likely not
* to break until GPSes are obsolete.
*/
+ /*@-usedef@*/
+ /*@-type@*//* splint is confused about struct timespec */
gpsdata->timedrift.real.tv_sec = (long)real_sec;
gpsdata->timedrift.real.tv_nsec = (time_t)real_nsec;
gpsdata->timedrift.clock.tv_sec = (long)clock_sec;
gpsdata->timedrift.clock.tv_nsec = (time_t)clock_nsec;
+ /*@+type@*/
+ /*@+usedef@*/
if (status != 0)
return status;
diff --git a/libgpsd_core.c b/libgpsd_core.c
index e07d8cc1..f9dce0fd 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -249,11 +249,11 @@ void gps_context_init(struct gps_context_t *context)
/* *INDENT-ON* */
(void)memcpy(context, &nullcontext, sizeof(struct gps_context_t));
-#ifdef PPS_ENABLE
+#if !defined(S_SPLINT_S) && defined(PPS_ENABLE)
/*@-nullpass@*/
(void)pthread_mutex_init(&report_mutex, NULL);
/*@+nullpass@*/
-#endif /* PPS_ENABLE */
+#endif /* defined(S_SPLINT_S) defined(PPS_ENABLE) */
}
/*@+compdestroy@*/
diff --git a/monitor_sirf.c b/monitor_sirf.c
index b6f212f6..421674f1 100644
--- a/monitor_sirf.c
+++ b/monitor_sirf.c
@@ -386,7 +386,7 @@ static void sirf_update(void)
display(mid7win, 1, 29, "%lu", getbeu32(buf, 12)); /* Clock Bias */
display(mid7win, 2, 16, "%lu", getbeu32(buf, 16)); /* Estimated Time */
/* Not a CSD field, but there's no better place to put it */
- if (timedelta)
+ if (timedelta != 0)
display(mid7win, 2, 39, "%f", timedelta); /* PPS offset */
monitor_log("CSD 0x07=");
break;
diff --git a/ntpshm.c b/ntpshm.c
index 0162309d..09a388d8 100644
--- a/ntpshm.c
+++ b/ntpshm.c
@@ -275,7 +275,7 @@ int ntpshm_put(struct gps_device_t *session, double fixtime, double fudge)
shmTime->clockTimeStampNSec = (unsigned)(microseconds*1000);
shmTime->receiveTimeStampSec = (time_t) tv.tv_sec;
shmTime->receiveTimeStampUSec = (int)tv.tv_usec;
- shmTime->receiveTimeStampNSec = (int)(tv.tv_usec*1000);
+ shmTime->receiveTimeStampNSec = (unsigned int)(tv.tv_usec*1000);
shmTime->leap = session->context->leap_notify;
/* setting the precision here does not seem to help anything, too
* hard to calculate properly anyway. Let ntpd figure it out.
@@ -339,12 +339,14 @@ static int ntpshm_pps(struct gps_device_t *session,
*/
shmTimeP->valid = 0;
shmTimeP->count++;
+ /*@-type@*//* splint is confused about struct timespec */
shmTimeP->clockTimeStampSec = (time_t)actual_ts->tv_sec;
shmTimeP->clockTimeStampUSec = (int)(actual_ts->tv_nsec/1000);
shmTimeP->clockTimeStampNSec = (unsigned)actual_ts->tv_nsec;
shmTimeP->receiveTimeStampSec = (time_t)clock_ts->tv_sec;
shmTimeP->receiveTimeStampUSec = (int)(clock_ts->tv_nsec/1000);
shmTimeP->receiveTimeStampNSec = (unsigned)clock_ts->tv_nsec;
+ /*@+type@*/
shmTimeP->leap = session->context->leap_notify;
/* precision is a placebo, ntpd does not really use it
* real world accuracy is around 16uS, thus -16 precision */
@@ -352,10 +354,12 @@ static int ntpshm_pps(struct gps_device_t *session,
shmTimeP->count++;
shmTimeP->valid = 1;
+ /*@-usedef@*/
/* this is more an offset jitter/dispersion than precision,
* but still useful for debug */
offset = fabs((double)(clock_tv.tv_sec - actual_tv.tv_sec)
+ ((double)(clock_tv.tv_usec - actual_tv.tv_usec) / 1000000.0));
+ /*@+usedef@*/
precision = offset != 0 ? (int)(ceil(log(offset) / M_LN2)) : -20;
/*@-type@*//* splint is confused about struct timespec */
gpsd_report(session->context->debug, LOG_RAW,
@@ -431,7 +435,9 @@ static void chrony_send(struct gps_device_t *session,
sample.pulse = 0;
sample.leap = session->context->leap_notify;
sample.magic = SOCK_MAGIC;
+ /*@-type@*//* splint is confused about struct timespec */
TSTOTV(&sample.tv, actual_ts);
+ /*@+type@*/
sample.offset = offset;
(void)send(session->chronyfd, &sample, sizeof (sample), 0);
diff --git a/ppsthread.c b/ppsthread.c
index d724a9ae..a7bc2a85 100644
--- a/ppsthread.c
+++ b/ppsthread.c
@@ -61,17 +61,21 @@ static int init_kernel_pps(struct gps_device_t *session)
/* return handle for kernel pps, or -1; requires root privileges */
{
int ldisc = 18; /* the PPS line discipline */
+#ifndef S_SPLINT_S
pps_params_t pp;
+#endif /* S_SPLINT_S */
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 pps_num = '\0'; /* /dev/pps[pps_num] is our device */
char path[GPS_PATH_MAX] = "";
+ int ret;
session->kernelpps_handle = -1;
- if ( !isatty(session->gpsdata.gps_fd) ) {
+ if ( isatty(session->gpsdata.gps_fd) == 0 ) {
gpsd_report(session->context->debug, LOG_INF, "KPPS gps_fd not a tty\n");
return -1;
}
+ /*@+ignoresigns@*/
/* Attach the line PPS discipline, so no need to ldattach */
/* This activates the magic /dev/pps0 device */
/* Note: this ioctl() requires root */
@@ -81,6 +85,7 @@ static int init_kernel_pps(struct gps_device_t *session)
strerror(errno));
return -1;
}
+ /*@-ignoresigns@*/
/* uh, oh, magic file names!, RFC2783 neglects to specify how
* to associate the serial device and pps device names */
@@ -92,7 +97,7 @@ static int init_kernel_pps(struct gps_device_t *session)
* yes, this could be done with libsysfs, but trying to keep the
* number of required libs small, and libsysfs would still be linux only */
memset( (void *)&globbuf, 0, sizeof(globbuf));
- glob("/sys/devices/virtual/pps/pps?/path", 0, NULL, &globbuf);
+ (void)glob("/sys/devices/virtual/pps/pps?/path", 0, NULL, &globbuf);
memset( (void *)&path, 0, sizeof(path));
for ( i = 0; i < globbuf.gl_pathc; i++ ) {
@@ -102,7 +107,7 @@ static int init_kernel_pps(struct gps_device_t *session)
if ( 0 < r ) {
path[r - 1] = '\0'; /* remove trailing \x0a */
}
- close(fd);
+ (void)close(fd);
}
gpsd_report(session->context->debug, LOG_INF,
"KPPS checking %s, %s\n",
@@ -131,7 +136,7 @@ static int init_kernel_pps(struct gps_device_t *session)
"KPPS only works as root \n");
return -1;
}
- int ret = open(path, O_RDWR);
+ ret = open(path, O_RDWR);
if ( 0 > ret ) {
gpsd_report(session->context->debug, LOG_INF,
"KPPS cannot open %s: %s\n", path, strerror(errno));
@@ -147,6 +152,7 @@ static int init_kernel_pps(struct gps_device_t *session)
} else {
/* have kernel PPS handle */
int caps;
+#ifndef S_SPLINT_S
/* get features supported */
if ( 0 > time_pps_getcap(session->kernelpps_handle, &caps)) {
gpsd_report(session->context->debug, LOG_ERROR,
@@ -159,6 +165,7 @@ static int init_kernel_pps(struct gps_device_t *session)
/* linux 2.6.34 can not PPS_ECHOASSERT | PPS_ECHOCLEAR */
memset( (void *)&pp, 0, sizeof(pps_params_t));
pp.mode = PPS_CAPTUREBOTH;
+#endif /* S_SPLINT_S */
if ( 0 > time_pps_setparams(session->kernelpps_handle, &pp)) {
gpsd_report(session->context->debug, LOG_ERROR,
@@ -171,7 +178,7 @@ static int init_kernel_pps(struct gps_device_t *session)
}
#endif /* defined(HAVE_SYS_TIMEPPS_H) */
-/*@-mustfreefresh -type@ -unrecog -branchstate*/
+/*@-mustfreefresh -type -unrecog -branchstate@*/
static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
{
struct gps_device_t *session = (struct gps_device_t *)arg;
@@ -513,7 +520,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
#if defined(HAVE_SYS_TIMEPPS_H)
if (session->kernelpps_handle > 0) {
gpsd_report(session->context->debug, LOG_PROG, "PPS descriptor cleaned up\n");
- time_pps_destroy(session->kernelpps_handle);
+ (void)time_pps_destroy(session->kernelpps_handle);
}
#endif
if (session->thread_wrap_hook != NULL)
diff --git a/sd_socket.c b/sd_socket.c
index 8c8c7719..8d5b7d8a 100644
--- a/sd_socket.c
+++ b/sd_socket.c
@@ -5,7 +5,9 @@
#include <limits.h>
#include <stdlib.h>
+#ifndef S_SPLINT_S
#include <unistd.h>
+#endif
#include "sd_socket.h"