summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2013-10-29 13:30:25 -0400
committerEric S. Raymond <esr@thyrsus.com>2013-10-29 13:30:25 -0400
commita7c2f46d6d14f81cf379b6a77a4919ded0408a39 (patch)
tree4321242d66635581a117e8ca26f41235718fba95
parent689e3c3f6c388709a560c1e42b3a04a18020a4fb (diff)
downloadgpsd-a7c2f46d6d14f81cf379b6a77a4919ded0408a39.tar.gz
splint cleanup. Regression tests pass and PPS live-tests correctly.
-rw-r--r--driver_zodiac.c6
-rw-r--r--gpsd.c2
-rw-r--r--gpsd.h-tail21
-rw-r--r--gpsdctl.c4
-rw-r--r--libgpsd_core.c4
-rw-r--r--ntpshm.c16
-rw-r--r--ppsthread.c13
-rw-r--r--test_packet.c4
8 files changed, 41 insertions, 29 deletions
diff --git a/driver_zodiac.c b/driver_zodiac.c
index ec93c13d..296dbece 100644
--- a/driver_zodiac.c
+++ b/driver_zodiac.c
@@ -49,16 +49,16 @@ static unsigned short zodiac_checksum(unsigned short *w, int n)
return -csum;
}
-static int end_write(int fd, void *d, int len)
+static ssize_t end_write(int fd, void *d, size_t len)
/* write an array of shorts in little-endian format */
{
- char buf[BUFSIZ];
+ unsigned char buf[BUFSIZ];
short *data = (short *)d;
size_t n = (size_t)(len/2);
for (n = 0; n < (size_t)(len/2); n++)
putle16(buf, n*2, data[n]);
- return write(fd, buf, len);
+ return write(fd, (char*)buf, len);
}
/* zodiac_spew - Takes a message type, an array of data words, and a length
diff --git a/gpsd.c b/gpsd.c
index db0650aa..f31d07eb 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -1665,9 +1665,11 @@ static void ship_pps_drift_message(struct gps_device_t *session,
/* on PPS interrupt, ship a drift message to all clients */
{
#ifdef SOCKET_EXPORT_ENABLE
+ /*@-type@*//* splint is confused about struct timespec */
notify_watchers(session, "{\"class\":\"PPS\",\"device\":\"%s\",\"real_sec\":%ld, \"real_nsec\":0,\"clock_sec\":%ld,\"clock_nsec\":%ld}\r\n",
session->gpsdata.dev.path,
sec, ts->tv_sec, ts->tv_nsec);
+ /*@+type@*/
#endif /* SOCKET_EXPORT_ENABLE */
}
#endif /* PPS_ENABLE */
diff --git a/gpsd.h-tail b/gpsd.h-tail
index d6b4f877..29a79a2b 100644
--- a/gpsd.h-tail
+++ b/gpsd.h-tail
@@ -251,7 +251,8 @@ struct gps_context_t {
/*@reldef@*/volatile struct shmTime *shmTime[NTPSHMSEGS];
bool shmTimeInuse[NTPSHMSEGS];
# ifdef PPS_ENABLE
- void (*pps_hook)(struct gps_device_t *, unsigned long, struct timespec *);
+ /*@null@*/ void (*pps_hook)(struct gps_device_t *,
+ unsigned long, struct timespec *);
# endif /* PPS_ENABLE */
#endif /* NTPSHM_ENABLE */
#ifdef SHM_EXPORT_ENABLE
@@ -432,8 +433,8 @@ struct gps_device_t {
/* session object, encapsulates all global state */
struct gps_data_t gpsdata;
/*@relnull@*/const struct gps_type_t *device_type;
- int driver_index; /* numeric index of current driver */
- int drivers_identified; /* bitmask; what drivers have we seen? */
+ unsigned int driver_index; /* numeric index of current driver */
+ unsigned int drivers_identified; /* bitmask; what drivers have we seen? */
#ifdef RECONFIGURE_ENABLE
/*@relnull@*/const struct gps_type_t *last_controller;
#endif /* RECONFIGURE_ENABLE */
@@ -470,13 +471,13 @@ struct gps_device_t {
pps_handle_t kernelpps_handle;
#endif /* defined(HAVE_SYS_TIMEPPS_H) */
int chronyfd; /* for talking to chrony */
- void (*thread_init_hook)(struct gps_device_t *);
- void (*thread_error_hook)(struct gps_device_t *);
- char *(*thread_report_hook)(struct gps_device_t *,
- struct timeval *,
- struct timespec *,
- long);
- void (*thread_wrap_hook)(struct gps_device_t *);
+ /*@null@*/ void (*thread_init_hook)(struct gps_device_t *);
+ /*@null@*/ void (*thread_error_hook)(struct gps_device_t *);
+ /*@null@*/ char *(*thread_report_hook)(struct gps_device_t *,
+ struct timeval *,
+ struct timespec *,
+ double);
+ /*@null@*/ void (*thread_wrap_hook)(struct gps_device_t *);
# endif /* PPS_ENABLE */
#endif /* NTPSHM_ENABLE */
double mag_var; /* magnetic variation in degrees */
diff --git a/gpsdctl.c b/gpsdctl.c
index 4a9e4017..017dd1c9 100644
--- a/gpsdctl.c
+++ b/gpsdctl.c
@@ -74,11 +74,11 @@ static int gpsd_control(char *action, char *argument)
if (stat(argument, &sb) != 1)
(void)chmod(argument, sb.st_mode | S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP);
(void)snprintf(buf, sizeof(buf), "+%s\r\n", argument);
- status = write(connect, buf, strlen(buf));
+ status = (int)write(connect, buf, strlen(buf));
ignore_return(read(connect, buf, 12));
} else if (strcmp(action, "remove") == 0) {
(void)snprintf(buf, sizeof(buf), "-%s\r\n", argument);
- status = write(connect, buf, strlen(buf));
+ status = (int)write(connect, buf, strlen(buf));
ignore_return(read(connect, buf, 12));
} else {
(void)syslog(LOG_ERR, "unknown action \"%s\"", action);
diff --git a/libgpsd_core.c b/libgpsd_core.c
index 547d2dff..7a667a1d 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -173,12 +173,13 @@ static void gpsd_run_device_hook(const int debuglevel,
}
}
+/*@-kepttrans@*/
int gpsd_switch_driver(struct gps_device_t *session, char *type_name)
{
/*@-mustfreeonly@*/
const struct gps_type_t **dp;
bool first_sync = (session->device_type != NULL);
- int i;
+ unsigned int i;
if (first_sync && strcmp(session->device_type->type_name, type_name) == 0)
return 0;
@@ -212,6 +213,7 @@ int gpsd_switch_driver(struct gps_device_t *session, char *type_name)
/*@ +compmempass @*/
/*@+mustfreeonly@*/
}
+/*@+kepttrans@*/
/*@-compdestroy@*/
void gps_context_init(struct gps_context_t *context)
diff --git a/ntpshm.c b/ntpshm.c
index 4045018f..4ccea3ed 100644
--- a/ntpshm.c
+++ b/ntpshm.c
@@ -299,7 +299,9 @@ static int ntpshm_pps(struct gps_device_t *session, struct timeval *actual_tv,
return 0;
/* for now we use uSec, not nSec */
+ /*@-type@*//* splint is confused about struct timespec */
TSTOTV( &tv, ts );
+ /*@+type@*/
/* we use the shmTime mode 1 protocol
*
@@ -330,15 +332,17 @@ static int ntpshm_pps(struct gps_device_t *session, struct timeval *actual_tv,
/* this is more an offset jitter/dispersion than precision,
* but still useful for debug */
- offset = fabs((tv.tv_sec - actual_tv->tv_sec)
+ offset = fabs((double)(tv.tv_sec - actual_tv->tv_sec)
+ ((double)(tv.tv_usec - actual_tv->tv_usec) / 1000000.0));
precision = offset != 0 ? (int)(ceil(log(offset) / M_LN2)) : -20;
+ /*@-type@*//* splint is confused about struct timespec */
gpsd_report(session->context->debug, LOG_RAW,
"PPS ntpshm_pps %lu.%03lu @ %lu.%09lu, preci %d\n",
(unsigned long)actual_tv->tv_sec,
(unsigned long)actual_tv->tv_usec,
(unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec,
precision);
+ /*@+type@*/
return 1;
}
@@ -351,8 +355,9 @@ struct sock_sample {
/* cppcheck-suppress unusedStructMember */
int _pad;
int magic; /* must be SOCK_MAGIC */
-} sample;
+};
+/*@-mustfreefresh@*/
static void init_hook(struct gps_device_t *session)
/* for chrony SOCK interface, which allows nSec timekeeping */
{
@@ -386,6 +391,7 @@ static void init_hook(struct gps_device_t *session)
"PPS using chrony socket: %s\n", chrony_path);
}
}
+/*@+mustfreefresh@*/
/* actual_tv is when we think the PPS pulse wass */
@@ -405,7 +411,7 @@ static void chrony_send(struct gps_device_t *session,
sample.tv = *actual_tv; /* structure copy */
sample.offset = offset;
- send(session->chronyfd, &sample, sizeof (sample), 0);
+ (void)send(session->chronyfd, &sample, sizeof (sample), 0);
}
static void wrap_hook(struct gps_device_t *session)
@@ -414,10 +420,10 @@ static void wrap_hook(struct gps_device_t *session)
(void)close(session->chronyfd);
}
-static char *report_hook(struct gps_device_t *session,
+static /*@observer@*/ char *report_hook(struct gps_device_t *session,
struct timeval *actual_tv,
struct timespec *ts,
- long edge_offset)
+ double edge_offset)
/* ship the time of a PPS event to ntpd and/or chrony */
{
char *log1;
diff --git a/ppsthread.c b/ppsthread.c
index 8e34ba6b..2df1b406 100644
--- a/ppsthread.c
+++ b/ppsthread.c
@@ -185,12 +185,12 @@ static int init_kernel_pps(struct gps_device_t *session)
}
#endif /* defined(HAVE_SYS_TIMEPPS_H) */
-/*@-mustfreefresh -type@ -unrecog*/
+/*@-mustfreefresh -type@ -unrecog -branchstate*/
static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
{
struct gps_device_t *session = (struct gps_device_t *)arg;
- struct timeval tv;
- struct timespec ts;
+ struct timeval tv = {0, 0};
+ struct timespec ts = {0, 0};
#if defined(TIOCMIWAIT)
int cycle, duration, state = 0, laststate = -1, unchanged = 0;
struct timeval pulse[2] = { {0, 0}, {0, 0} };
@@ -497,7 +497,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
#endif
{
// use plain PPS
- TVTOTS( &ts, &tv);
+ /*@i10@*/TVTOTS( &ts, &tv);
}
/* This innocuous-looking "+ 1" embodies a significant
@@ -541,7 +541,6 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
gpsd_report(session->context->debug, LOG_RAW,
"PPS edge rejected %.100s", log);
}
-
}
#if defined(HAVE_SYS_TIMEPPS_H)
if (session->kernelpps_handle > 0) {
@@ -554,7 +553,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
gpsd_report(session->context->debug, LOG_PROG, "PPS gpsd_ppsmonitor exited.\n");
return NULL;
}
-/*@+mustfreefresh +type +unrecog@*/
+/*@+mustfreefresh +type +unrecog +branchstate@*/
/*
* Entry points begin here.
@@ -584,8 +583,10 @@ void pps_thread_activate(struct gps_device_t *session)
void pps_thread_deactivate(struct gps_device_t *session)
/* cleanly terminate PPS thread */
{
+ /*@-nullstate -mustfreeonly@*/
session->thread_report_hook = NULL;
session->context->pps_hook = NULL;
+ /*@+nullstate +mustfreeonly@*/
}
#if defined(HAVE_SYS_TIMEPPS_H)
diff --git a/test_packet.c b/test_packet.c
index 9830d6cd..2228ddbf 100644
--- a/test_packet.c
+++ b/test_packet.c
@@ -330,7 +330,7 @@ static int property_check(void)
int status;
for (dp = gpsd_drivers; *dp; dp++) {
- if ((*dp)->packet_type == COMMENT_PACKET)
+ if (*dp == NULL || (*dp)->packet_type == COMMENT_PACKET)
continue;
#ifdef RECONFIGURE_ENABLE
@@ -370,7 +370,7 @@ static int property_check(void)
status = EXIT_SUCCESS;
for (dp = gpsd_drivers; *dp; dp++) {
- if ((*dp)->packet_type == COMMENT_PACKET)
+ if (*dp == NULL || (*dp)->packet_type == COMMENT_PACKET)
continue;
#ifdef CONTROLSEND_ENABLE
if (CONTROLLABLE(*dp) && (*dp)->control_send == NULL) {