summaryrefslogtreecommitdiff
path: root/gpsd_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 /gpsd_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 'gpsd_json.c')
-rw-r--r--gpsd_json.c63
1 files changed, 19 insertions, 44 deletions
diff --git a/gpsd_json.c b/gpsd_json.c
index 9d51b12d..f27d29c9 100644
--- a/gpsd_json.c
+++ b/gpsd_json.c
@@ -54,12 +54,11 @@ struct classmap_t classmap[CLASSMAP_NITEMS] = {
};
/* *INDENT-ON* */
-char *json_stringify( /*@out@*/ char *to,
+char *json_stringify( char *to,
size_t len,
- /*@in@*/ const char *from)
+ const char *from)
/* escape double quotes and control characters inside a JSON string */
{
- /*@-temptrans@*/
const char *sp;
char *tp;
@@ -105,10 +104,9 @@ char *json_stringify( /*@out@*/ char *to,
*tp = '\0';
return to;
- /*@+temptrans@*/
}
-void json_version_dump( /*@out@*/ char *reply, size_t replylen)
+void json_version_dump( char *reply, size_t replylen)
{
(void)snprintf(reply, replylen,
"{\"class\":\"VERSION\",\"release\":\"%s\",\"rev\":\"%s\",\"proto_major\":%d,\"proto_minor\":%d}\r\n",
@@ -125,7 +123,7 @@ void json_version_dump( /*@out@*/ char *reply, size_t replylen)
void json_tpv_dump(const struct gps_device_t *session,
const struct policy_t *policy CONDITIONALLY_UNUSED,
- /*@out@*/ char *reply, size_t replylen)
+ char *reply, size_t replylen)
{
const struct gps_data_t *gpsdata = &session->gpsdata;
@@ -182,12 +180,10 @@ 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;
- /*@i@*/(int)clock_gettime(CLOCK_REALTIME, &rtime_tmp);
- /*@i1@*/timespec_str(&rtime_tmp, rtime_str, sizeof(rtime_str));
- /*@-formattype@*/
+ (int)clock_gettime(CLOCK_REALTIME, &rtime_tmp);
+ timespec_str(&rtime_tmp, rtime_str, sizeof(rtime_str));
str_appendf(reply, replylen, "\"rtime\":%s,", rtime_str);
#ifdef PPS_ENABLE
if (session->pps_thread.ppsout_count) {
@@ -197,7 +193,6 @@ void json_tpv_dump(const struct gps_device_t *session,
str_appendf(reply, replylen, "\"pps\":%s,", ts_str);
/* TODO: add PPS precision to JSON output */
}
- /*@+type +formattype@*/
#endif /* PPS_ENABLE */
str_appendf(reply, replylen,
"\"sor\":%.9f,\"chars\":%lu,\"sats\":%2d,"
@@ -216,7 +211,7 @@ void json_tpv_dump(const struct gps_device_t *session,
}
void json_noise_dump(const struct gps_data_t *gpsdata,
- /*@out@*/ char *reply, size_t replylen)
+ char *reply, size_t replylen)
{
char tbuf[JSON_DATE_MAX+1];
@@ -247,7 +242,7 @@ void json_noise_dump(const struct gps_data_t *gpsdata,
}
void json_sky_dump(const struct gps_data_t *datap,
- /*@out@*/ char *reply, size_t replylen)
+ char *reply, size_t replylen)
{
int i, reported = 0;
@@ -300,7 +295,7 @@ void json_sky_dump(const struct gps_data_t *datap,
}
void json_device_dump(const struct gps_device_t *device,
- /*@out@*/ char *reply, size_t replylen)
+ char *reply, size_t replylen)
{
struct classmap_t *cmp;
char buf1[JSON_VAL_MAX * 2 + 1];
@@ -313,7 +308,6 @@ void json_device_dump(const struct gps_device_t *device,
(void)strlcat(reply, device->device_type->type_name, replylen);
(void)strlcat(reply, "\",", replylen);
}
- /*@-mustfreefresh@*/
if (device->subtype[0] != '\0') {
(void)strlcat(reply, "\"subtype\":\"", replylen);
(void)strlcat(reply,
@@ -321,7 +315,6 @@ void json_device_dump(const struct gps_device_t *device,
replylen);
(void)strlcat(reply, "\",", replylen);
}
- /*@+mustfreefresh@*/
/*
* There's an assumption here: Anything that we type service_sensor is
* a serial device with the usual control parameters.
@@ -363,9 +356,8 @@ void json_device_dump(const struct gps_device_t *device,
}
void json_watch_dump(const struct policy_t *ccp,
- /*@out@*/ char *reply, size_t replylen)
+ char *reply, size_t replylen)
{
- /*@-compdef@*/
(void)snprintf(reply, replylen,
"{\"class\":\"WATCH\",\"enable\":%s,\"json\":%s,\"nmea\":%s,\"raw\":%d,\"scaled\":%s,\"timing\":%s,\"split24\":%s,\"pps\":%s,",
ccp->watcher ? "true" : "false",
@@ -380,11 +372,10 @@ void json_watch_dump(const struct policy_t *ccp,
str_appendf(reply, replylen, "\"device\":\"%s\",", ccp->devpath);
str_rstrip_char(reply, ',');
(void)strlcat(reply, "}\r\n", replylen);
- /*@+compdef@*/
}
void json_subframe_dump(const struct gps_data_t *datap,
- /*@out@*/ char buf[], size_t buflen)
+ char buf[], size_t buflen)
{
const struct subframe_t *subframe = &datap->subframe;
const bool scaled = datap->policy.scaled;
@@ -397,7 +388,6 @@ void json_subframe_dump(const struct gps_data_t *datap,
(unsigned int)subframe->subframe_num,
JSON_BOOL(scaled));
- /*@-type@*/
if ( 1 == subframe->subframe_num ) {
if (scaled) {
str_appendf(buf, buflen,
@@ -498,7 +488,6 @@ void json_subframe_dump(const struct gps_data_t *datap,
}
} else if ( subframe->is_almanac ) {
if (scaled) {
- /*@-compdef@*/
str_appendf(buf, buflen,
",\"ALMANAC\":{\"ID\":%d,\"Health\":%u,"
"\"e\":%g,\"toa\":%lu,"
@@ -546,7 +535,6 @@ void json_subframe_dump(const struct gps_data_t *datap,
case 52:
{
int i;
- /*@+charint@*/
/* decoding of ERD to SV is non trivial and not done yet */
str_appendf(buf, buflen,
",\"ERD\":{\"ai\":%u,", subframe->sub4_13.ai);
@@ -559,7 +547,6 @@ void json_subframe_dump(const struct gps_data_t *datap,
str_rstrip_char(buf, ',');
str_appendf(buf, buflen, "}");
break;
- /*@-charint@*/
}
case 55:
/* JSON is UTF-8. double quote, backslash and
@@ -654,7 +641,6 @@ void json_subframe_dump(const struct gps_data_t *datap,
(unsigned int)subframe->pageid);
if ( 51 == subframe->pageid ) {
int i;
- /*@+matchanyintegral@*/
/* subframe5, page 25 */
str_appendf(buf, buflen,
",\"HEALTH2\":{\"toa\":%lu,\"WNa\":%u,",
@@ -668,21 +654,17 @@ void json_subframe_dump(const struct gps_data_t *datap,
str_rstrip_char(buf, ',');
str_appendf(buf, buflen, "}");
- /*@-matchanyintegral@*/
}
}
- /*@+type@*/
(void)strlcat(buf, "}\r\n", buflen);
- /*@+compdef@*/
}
#if defined(RTCM104V2_ENABLE)
void json_rtcm2_dump(const struct rtcm2_t *rtcm,
- /*@null@*/const char *device,
- /*@out@*/char buf[], size_t buflen)
+ const char *device,
+ char buf[], size_t buflen)
/* dump the contents of a parsed RTCM104 message as JSON */
{
- /*@-mustfreefresh@*/
char buf1[JSON_VAL_MAX * 2 + 1];
unsigned int n;
@@ -828,17 +810,15 @@ void json_rtcm2_dump(const struct rtcm2_t *rtcm,
str_rstrip_char(buf, ',');
(void)strlcat(buf, "}\r\n", buflen);
- /*@+mustfreefresh@*/
}
#endif /* defined(RTCM104V2_ENABLE) */
#if defined(RTCM104V3_ENABLE)
void json_rtcm3_dump(const struct rtcm3_t *rtcm,
- /*@null@*/const char *device,
- /*@out@*/char buf[], size_t buflen)
+ const char *device,
+ char buf[], size_t buflen)
/* dump the contents of a parsed RTCM104v3 message as JSON */
{
- /*@-mustfreefresh@*/
char buf1[JSON_VAL_MAX * 2 + 1];
unsigned short i;
unsigned int n;
@@ -1227,7 +1207,6 @@ void json_rtcm3_dump(const struct rtcm3_t *rtcm,
break;
case 1029:
- /*@-formatcode@*//* splint has a bug */
str_appendf(buf, buflen,
"\"station_id\":%u,\"mjd\":%u,\"sec\":%u,"
"\"len\":%zd,\"units\":%zd,\"msg\":\"%s\",",
@@ -1238,7 +1217,6 @@ void json_rtcm3_dump(const struct rtcm3_t *rtcm,
rtcm->rtcmtypes.rtcm3_1029.unicode_units,
json_stringify(buf1, sizeof(buf1),
(char *)rtcm->rtcmtypes.rtcm3_1029.text));
- /*@+formatcode@*/
break;
case 1033:
@@ -1266,7 +1244,6 @@ void json_rtcm3_dump(const struct rtcm3_t *rtcm,
str_rstrip_char(buf, ',');
(void)strlcat(buf, "}\r\n", buflen);
- /*@+mustfreefresh@*/
#undef CODE
#undef INT
}
@@ -1274,8 +1251,8 @@ void json_rtcm3_dump(const struct rtcm3_t *rtcm,
#if defined(AIVDM_ENABLE)
void json_aivdm_dump(const struct ais_t *ais,
- /*@null@*/const char *device, bool scaled,
- /*@out@*/char *buf, size_t buflen)
+ const char *device, bool scaled,
+ char *buf, size_t buflen)
{
char buf1[JSON_VAL_MAX * 2 + 1];
char buf2[JSON_VAL_MAX * 2 + 1];
@@ -1585,7 +1562,6 @@ void json_aivdm_dump(const struct ais_t *ais,
str_appendf(buf, buflen,
"\"type\":%u,\"repeat\":%u,\"mmsi\":%u,\"scaled\":%s,",
ais->type, ais->repeat, ais->mmsi, JSON_BOOL(scaled));
- /*@ -formatcode -mustfreefresh @*/
switch (ais->type) {
case 1: /* Position Report */
case 2:
@@ -3293,13 +3269,12 @@ void json_aivdm_dump(const struct ais_t *ais,
(void)strlcat(buf, "}\r\n", buflen);
break;
}
- /*@ +formatcode +mustfreefresh @*/
}
#endif /* defined(AIVDM_ENABLE) */
#ifdef COMPASS_ENABLE
void json_att_dump(const struct gps_data_t *gpsdata,
- /*@out@*/ char *reply, size_t replylen)
+ char *reply, size_t replylen)
/* dump the contents of an attitude_t structure as JSON */
{
assert(replylen > sizeof(char *));
@@ -3391,7 +3366,7 @@ void json_att_dump(const struct gps_data_t *gpsdata,
void json_data_report(const gps_mask_t changed,
const struct gps_device_t *session,
const struct policy_t *policy,
- /*@out@*/char *buf, size_t buflen)
+ char *buf, size_t buflen)
/* report a session state in JSON */
{
const struct gps_data_t *datap = &session->gpsdata;