diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2011-10-09 09:00:40 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2011-10-09 09:00:40 -0400 |
commit | a6f20e590e9b485822befc3542caa1f21cdff676 (patch) | |
tree | 0a7a6857dda2943dc5189eff368067f1bd3cf915 | |
parent | afe4984bb17a7a72764b84d7b959dc0431d0a130 (diff) | |
download | gpsd-a6f20e590e9b485822befc3542caa1f21cdff676.tar.gz |
const and splint cleanup.
-rw-r--r-- | gps_json.h | 4 | ||||
-rw-r--r-- | gpsd_json.c | 8 | ||||
-rw-r--r-- | gpsdecode.c | 9 | ||||
-rw-r--r-- | gpsmon.c | 1 | ||||
-rw-r--r-- | monitor_nmea.c | 7 | ||||
-rw-r--r-- | monitor_oncore.c | 5 | ||||
-rw-r--r-- | monitor_sirf.c | 12 | ||||
-rw-r--r-- | monitor_tnt.c | 5 | ||||
-rw-r--r-- | ntpshm.c | 35 |
9 files changed, 58 insertions, 28 deletions
@@ -13,7 +13,9 @@ #ifdef __cplusplus extern "C" { #endif -void json_data_report(gps_mask_t, struct gps_device_t *, struct policy_t *, +void json_data_report(const gps_mask_t, + const struct gps_device_t *, + const struct policy_t *, /*@out@*/char *, size_t); char *json_stringify(/*@out@*/char *, size_t, /*@in@*/const char *); void json_tpv_dump(const struct gps_device_t *, diff --git a/gpsd_json.c b/gpsd_json.c index e89012a6..a3f58e80 100644 --- a/gpsd_json.c +++ b/gpsd_json.c @@ -2935,13 +2935,13 @@ void json_att_dump(const struct gps_data_t *gpsdata, } #endif /* COMPASS_ENABLE */ -void json_data_report(gps_mask_t changed, - struct gps_device_t *session, - struct policy_t *policy, +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) /* report a session state in JSON */ { - struct gps_data_t *datap = &session->gpsdata; + const struct gps_data_t *datap = &session->gpsdata; buf[0] = '\0'; if ((changed & REPORT_IS) != 0) { diff --git a/gpsdecode.c b/gpsdecode.c index 7027cc6c..0c03a113 100644 --- a/gpsdecode.c +++ b/gpsdecode.c @@ -448,10 +448,11 @@ static void encode(FILE *fpin, FILE *fpout) { char inbuf[BUFSIZ]; struct policy_t policy; - struct gps_data_t gpsdata; + struct gps_device_t session; int lineno = 0; memset(&policy, '\0', sizeof(policy)); + memset(&session, '\0', sizeof(session)); policy.json = true; while (fgets(inbuf, (int)sizeof(inbuf), fpin) != NULL) { @@ -460,15 +461,15 @@ static void encode(FILE *fpin, FILE *fpout) ++lineno; if (inbuf[0] == '#') continue; - status = libgps_json_unpack(inbuf, &gpsdata, NULL); + status = libgps_json_unpack(inbuf, &session.gpsdata, NULL); if (status != 0) { (void)fprintf(stderr, "gpsdecode: dying with status %d (%s) on line %d\n", status, json_error_string(status), lineno); exit(1); } - json_data_report(gpsdata.set, - &gpsdata, &policy, + json_data_report(session.gpsdata.set, + &session, &policy, inbuf, sizeof(inbuf)); (void)fputs(inbuf, fpout); } @@ -344,6 +344,7 @@ static bool monitor_raw_send( /*@in@*/ unsigned char *buf, size_t len) void monitor_complain(const char *fmt, ...) { va_list ap; + assert(cmdwin!=NULL); (void)wmove(cmdwin, 0, (int)strlen(type_name) + 2); (void)wclrtoeol(cmdwin); (void)wattrset(cmdwin, A_BOLD | A_BLINK); diff --git a/monitor_nmea.c b/monitor_nmea.c index 2cdac01f..fb03258b 100644 --- a/monitor_nmea.c +++ b/monitor_nmea.c @@ -38,7 +38,11 @@ static bool nmea_initialize(void) { int i; - /*@ -onlytrans @*/ + /* splint pacification */ + assert(nmeawin!=NULL && cookedwin!=NULL && satwin!=NULL && gprmcwin!=NULL + && gpggawin!= NULL && gpgstwin!=NULL && gpgsawin!=NULL); + + /*@ -globstate -onlytrans @*/ cookedwin = derwin(devicewin, 3, 80, 0, 0); (void)wborder(cookedwin, 0, 0, 0, 0, 0, 0, 0, 0); (void)syncok(cookedwin, true); @@ -124,6 +128,7 @@ static bool nmea_initialize(void) last_tick = timestamp(); return (nmeawin != NULL); + /*@ +globstate @*/ } static void cooked_pvt(void) diff --git a/monitor_oncore.c b/monitor_oncore.c index 29d462ed..ed0dc457 100644 --- a/monitor_oncore.c +++ b/monitor_oncore.c @@ -75,8 +75,12 @@ static const char *pos_hold_mode[] = { static bool oncore_initialize(void) { + /*@-globstate@*/ unsigned int i; + /* splint pacification */ + assert(Aywin != NULL); + /*@ -onlytrans @*/ Ea1win = subwin(devicewin, 5, 80, 1, 0); Eawin = subwin(devicewin, MAXTRACKSATS + 3, 27, 6, 0); @@ -169,6 +173,7 @@ static bool oncore_initialize(void) memset(EaSVlines, 0, sizeof(EaSVlines)); return true; + /*@+globstate@*/ } static void oncore_update(void) diff --git a/monitor_sirf.c b/monitor_sirf.c index dd6d798d..74da43d9 100644 --- a/monitor_sirf.c +++ b/monitor_sirf.c @@ -63,8 +63,12 @@ static char *dgpsvec[] = { static bool sirf_initialize(void) { + /*@-globstate@*/ unsigned int i; + /* splint pacification */ + assert(mid2win!=NULL && mid7win != NULL); + /*@ -onlytrans @*/ mid2win = subwin(devicewin, 6, 80, 1, 0); mid4win = subwin(devicewin, MAXSATS + 3, 30, 7, 0); @@ -208,6 +212,7 @@ static bool sirf_initialize(void) gpsd_time_init(session.context, time(NULL)); return true; + /*@+globstate@*/ } static void decode_ecef(double x, double y, double z, @@ -219,6 +224,9 @@ static void decode_ecef(double x, double y, double z, const double e_2 = (a * a - b * b) / (b * b); double lambda, p, theta, phi, n, h, vnorth, veast, vup, speed, heading; + /* splint pacification */ + assert(mid2win!=NULL); + lambda = atan2(y, x); /*@ -evalorder @*/ p = sqrt(pow(x, 2) + pow(y, 2)); @@ -273,7 +281,9 @@ static void sirf_update(void) uint8_t dgps; char tbuf[JSON_DATE_MAX+1]; - assert(mid27win != NULL); + /* splint pacification */ + assert(mid2win!=NULL && mid27win != NULL); + buf = session.packet.outbuffer + 4; len = session.packet.outbuflen - 8; switch (buf[0]) { diff --git a/monitor_tnt.c b/monitor_tnt.c index 7af64b08..0bf35c24 100644 --- a/monitor_tnt.c +++ b/monitor_tnt.c @@ -14,6 +14,10 @@ static WINDOW *thtmwin; static bool tnt_initialize(void) { + /* splint pacification */ + assert(thtmwin != NULL); + + /*@-globstate@*/ /*@ -onlytrans @*/ thtmwin = derwin(devicewin, 6, 80, 0, 0); (void)wborder(thtmwin, 0, 0, 0, 0, 0, 0, 0, 0), @@ -32,6 +36,7 @@ static bool tnt_initialize(void) (void)wattrset(thtmwin, A_NORMAL); /*@ +onlytrans @*/ return true; + /*@+globstate@*/ } static void tnt_update(void) @@ -269,6 +269,24 @@ int ntpshm_put(struct gps_device_t *session, double fixtime, double fudge) } #ifdef PPS_ENABLE +/* + * Possible pins for PPS: DCD, CTS, RTS, RI. Pinouts: + * + * DB9 DB25 Name Full name + * --- ---- ---- -------------------- + * 3 2 TXD --> Transmit Data + * 2 3 RXD <-- Receive Data + * 7 4 RTS --> Request To Send + * 8 5 CTS <-- Clear To Send + * 6 6 DSR <-- Data Set Ready + * 4 20 DTR --> Data Terminal Ready + * 1 8 DCD <-- Data Carrier Detect + * 9 22 RI <-- Ring Indicator + * 5 7 SG Signal ground + */ +#include "pps_pin.h" + +/*@unused@*//* splint is confused here */ /* put NTP shared memory info based on received PPS pulse * * good news is that kernel PPS gives us nSec resolution @@ -527,23 +545,6 @@ static int init_kernel_pps(struct gps_device_t *session) { } #endif /* defined(HAVE_SYS_TIMEPPS_H) */ -/* - * Possible pins for PPS: DCD, CTS, RTS, RI. Pinouts: - * - * DB9 DB25 Name Full name - * --- ---- ---- -------------------- - * 3 2 TXD --> Transmit Data - * 2 3 RXD <-- Receive Data - * 7 4 RTS --> Request To Send - * 8 5 CTS <-- Clear To Send - * 6 6 DSR <-- Data Set Ready - * 4 20 DTR --> Data Terminal Ready - * 1 8 DCD <-- Data Carrier Detect - * 9 22 RI <-- Ring Indicator - * 5 7 SG Signal ground - */ -#include "pps_pin.h" - /*@-mustfreefresh -type@ -unrecog*/ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) { |