summaryrefslogtreecommitdiff
path: root/libgps_json.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2015-03-30 17:10:53 -0400
committerEric S. Raymond <esr@thyrsus.com>2015-03-30 17:10:53 -0400
commit28bf37132d86cc59320e21d843960d086cef664c (patch)
treebf085b5f89f1d1061b6a88ecc66c50721b13d86c /libgps_json.c
parentecb7e1ff3ec73000918c56861c55258c2d4deada (diff)
downloadgpsd-28bf37132d86cc59320e21d843960d086cef664c.tar.gz
Retire splint from our set of static analyzers.
The proximate cause was that we've been seing emission of error messages that were randomly and disturbingly variable across different environments - notably Raspbian and Gentoo splint gave nontrivially different results than Ubuntu 14.10 splint. And this was *not* due to Ubuntu patches! A pristine splint built from the 3.1.2 tarball on Ubuntu didn't match the Raspbian and Gentoo results either. But this has been coming for a while. Easy access to more modern static analyzers such as coverity, scan-build and cppcheck has been decreasing the utility of splint, which is unmaintained and somewhat buggy and not easy to use. Only file not cleaned is ppsthread.c, because Gary has been working on it during this cleanup. All regression tests pass. PPS observed live on GR601-W.
Diffstat (limited to 'libgps_json.c')
-rw-r--r--libgps_json.c56
1 files changed, 9 insertions, 47 deletions
diff --git a/libgps_json.c b/libgps_json.c
index ba967ca8..8f97c274 100644
--- a/libgps_json.c
+++ b/libgps_json.c
@@ -24,18 +24,9 @@ PERMISSIONS
#ifdef SOCKET_EXPORT_ENABLE
#include "gps_json.h"
-/*
- * There's a splint limitation that parameters can be declared
- * @out@ or @null@ but not, apparently, both. This collides with
- * the (admittedly tricky) way we use endptr. The workaround is to
- * declare it @null@ and use -compdef around the JSON reader calls.
- */
-/*@-compdef@*/
-
static int json_tpv_read(const char *buf, struct gps_data_t *gpsdata,
- /*@null@*/ const char **endptr)
+ const char **endptr)
{
- /*@ -fullinitblock @*/
const struct json_attr_t json_attrs_1[] = {
/* *INDENT-OFF* */
{"class", t_check, .dflt.check = "TPV"},
@@ -76,15 +67,13 @@ static int json_tpv_read(const char *buf, struct gps_data_t *gpsdata,
{NULL},
/* *INDENT-ON* */
};
- /*@ +fullinitblock @*/
return json_read_object(buf, json_attrs_1, endptr);
}
static int json_noise_read(const char *buf, struct gps_data_t *gpsdata,
- /*@null@*/ const char **endptr)
+ const char **endptr)
{
- /*@ -fullinitblock @*/
const struct json_attr_t json_attrs_1[] = {
/* *INDENT-OFF* */
{"class", t_check, .dflt.check = "GST"},
@@ -111,16 +100,13 @@ static int json_noise_read(const char *buf, struct gps_data_t *gpsdata,
{NULL},
/* *INDENT-ON* */
};
- /*@ +fullinitblock @*/
return json_read_object(buf, json_attrs_1, endptr);
}
static int json_sky_read(const char *buf, struct gps_data_t *gpsdata,
- /*@null@*/ const char **endptr)
+ const char **endptr)
{
- /*@ -fullinitblock @*/
- /*@-type@*//* STRUCTARRAY confuses splint */
const struct json_attr_t json_attrs_satellites[] = {
/* *INDENT-OFF* */
{"PRN", t_integer, STRUCTOBJECT(struct satellite_t, PRN)},
@@ -161,7 +147,6 @@ static int json_sky_read(const char *buf, struct gps_data_t *gpsdata,
{NULL},
/* *INDENT-ON* */
};
- /*@ +fullinitblock @*/
int status, i, j;
for (i = 0; i < MAXCHANNELS; i++) {
@@ -187,9 +172,8 @@ static int json_sky_read(const char *buf, struct gps_data_t *gpsdata,
}
static int json_att_read(const char *buf, struct gps_data_t *gpsdata,
- /*@null@*/ const char **endptr)
+ const char **endptr)
{
- /*@ -fullinitblock @*/
const struct json_attr_t json_attrs_1[] = {
/* *INDENT-OFF* */
{"class", t_check, .dflt.check = "ATT"},
@@ -238,15 +222,13 @@ static int json_att_read(const char *buf, struct gps_data_t *gpsdata,
{NULL},
/* *INDENT-ON* */
};
- /*@ +fullinitblock @*/
return json_read_object(buf, json_attrs_1, endptr);
}
static int json_devicelist_read(const char *buf, struct gps_data_t *gpsdata,
- /*@null@*/ const char **endptr)
+ const char **endptr)
{
- /*@ -fullinitblock @*/
const struct json_attr_t json_attrs_subdevices[] = {
/* *INDENT-OFF* */
{"class", t_check, .dflt.check = "DEVICE"},
@@ -274,7 +256,6 @@ static int json_devicelist_read(const char *buf, struct gps_data_t *gpsdata,
{NULL},
/* *INDENT-ON* */
};
- /*@-type@*//* STRUCTARRAY confuses splint */
const struct json_attr_t json_attrs_devices[] = {
{"class", t_check,.dflt.check = "DEVICES"},
{"devices", t_array, STRUCTARRAY(gpsdata->devices.list,
@@ -282,8 +263,6 @@ static int json_devicelist_read(const char *buf, struct gps_data_t *gpsdata,
&gpsdata->devices.ndevices)},
{NULL},
};
- /*@+type@*/
- /*@ +fullinitblock @*/
int status;
memset(&gpsdata->devices, '\0', sizeof(gpsdata->devices));
@@ -297,9 +276,8 @@ static int json_devicelist_read(const char *buf, struct gps_data_t *gpsdata,
}
static int json_version_read(const char *buf, struct gps_data_t *gpsdata,
- /*@null@*/ const char **endptr)
+ const char **endptr)
{
- /*@ -fullinitblock @*/
const struct json_attr_t json_attrs_version[] = {
/* *INDENT-OFF* */
{"class", t_check, .dflt.check = "VERSION"},
@@ -314,7 +292,6 @@ static int json_version_read(const char *buf, struct gps_data_t *gpsdata,
{NULL},
/* *INDENT-ON* */
};
- /*@ +fullinitblock @*/
int status;
memset(&gpsdata->version, '\0', sizeof(gpsdata->version));
@@ -324,9 +301,8 @@ static int json_version_read(const char *buf, struct gps_data_t *gpsdata,
}
static int json_error_read(const char *buf, struct gps_data_t *gpsdata,
- /*@null@*/ const char **endptr)
+ const char **endptr)
{
- /*@ -fullinitblock @*/
const struct json_attr_t json_attrs_error[] = {
/* *INDENT-OFF* */
{"class", t_check, .dflt.check = "ERROR"},
@@ -335,7 +311,6 @@ static int json_error_read(const char *buf, struct gps_data_t *gpsdata,
{NULL},
/* *INDENT-ON* */
};
- /*@ +fullinitblock @*/
int status;
memset(&gpsdata->error, '\0', sizeof(gpsdata->error));
@@ -347,10 +322,9 @@ static int json_error_read(const char *buf, struct gps_data_t *gpsdata,
}
int json_toff_read(const char *buf, struct gps_data_t *gpsdata,
- /*@null@*/ const char **endptr)
+ const char **endptr)
{
int real_sec = 0, real_nsec = 0, clock_sec = 0, clock_nsec = 0;
- /*@ -fullinitblock @*/
const struct json_attr_t json_attrs_toff[] = {
/* *INDENT-OFF* */
{"class", t_check, .dflt.check = "TOFF"},
@@ -367,19 +341,14 @@ int json_toff_read(const char *buf, struct gps_data_t *gpsdata,
{NULL},
/* *INDENT-ON* */
};
- /*@ +fullinitblock @*/
int status;
memset(&gpsdata->toff, '\0', sizeof(gpsdata->toff));
status = json_read_object(buf, json_attrs_toff, endptr);
- /*@-usedef@*/
- /*@-type@*//* splint is confused about struct timespec */
gpsdata->toff.real.tv_sec = (time_t)real_sec;
gpsdata->toff.real.tv_nsec = (long)real_nsec;
gpsdata->toff.clock.tv_sec = (time_t)clock_sec;
gpsdata->toff.clock.tv_nsec = (long)clock_nsec;
- /*@+type@*/
- /*@+usedef@*/
if (status != 0)
return status;
@@ -387,10 +356,9 @@ int json_toff_read(const char *buf, struct gps_data_t *gpsdata,
}
int json_pps_read(const char *buf, struct gps_data_t *gpsdata,
- /*@null@*/ const char **endptr)
+ const char **endptr)
{
int real_sec = 0, real_nsec = 0, clock_sec = 0, clock_nsec = 0;
- /*@ -fullinitblock @*/
const struct json_attr_t json_attrs_pps[] = {
/* *INDENT-OFF* */
{"class", t_check, .dflt.check = "PPS"},
@@ -407,7 +375,6 @@ int json_pps_read(const char *buf, struct gps_data_t *gpsdata,
{NULL},
/* *INDENT-ON* */
};
- /*@ +fullinitblock @*/
int status;
memset(&gpsdata->pps, '\0', sizeof(gpsdata->pps));
@@ -416,14 +383,10 @@ 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->pps.real.tv_sec = (time_t)real_sec;
gpsdata->pps.real.tv_nsec = (long)real_nsec;
gpsdata->pps.clock.tv_sec = (time_t)clock_sec;
gpsdata->pps.clock.tv_nsec = (long)clock_nsec;
- /*@+type@*/
- /*@+usedef@*/
if (status != 0)
return status;
@@ -575,7 +538,6 @@ int libgps_json_unpack(const char *buf,
return -1;
}
-/*@+compdef@*/
#endif /* SOCKET_EXPORT_ENABLE */