From 032607920d8d6f335e3bfbca1fc76e9d77dc7457 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 5 Nov 2013 20:21:42 -0500 Subject: Full splint cleanup. Partial cppcheck cleanup. --- bsd_base64.c | 2 +- cgps.c | 7 ++++--- contrib/binlog.c | 4 ++-- contrib/motosend.c | 7 ++++--- driver_ais.c | 2 +- driver_nmea0183.c | 3 ++- driver_nmea2000.c | 16 +++++++++------- driver_oncore.c | 5 +++-- driver_sirf.c | 3 ++- driver_superstar2.c | 2 +- driver_ubx.c | 5 +++-- driver_zodiac.c | 7 +++---- drivers.c | 6 +++--- gpsctl.c | 2 +- gpsd_json.c | 7 ++++--- lcdgps.c | 6 +++--- libgps_json.c | 2 +- libgps_shm.c | 3 +-- libgps_sock.c | 2 +- libgpsd_core.c | 6 +++--- monitor_oncore.c | 3 ++- monitor_sirf.c | 4 ++-- packet.c | 5 +++-- ppsthread.c | 10 +++++++--- srecord.c | 4 ++-- test_bits.c | 4 ++-- 26 files changed, 70 insertions(+), 57 deletions(-) diff --git a/bsd_base64.c b/bsd_base64.c index cedecafb..eba89d99 100644 --- a/bsd_base64.c +++ b/bsd_base64.c @@ -130,7 +130,6 @@ b64_ntop(unsigned char const *src, size_t srclength, char *target, size_t datalength = 0; unsigned char input[3]; unsigned char output[4]; - size_t i; while (2 < srclength) { input[0] = *src++; @@ -157,6 +156,7 @@ b64_ntop(unsigned char const *src, size_t srclength, char *target, /* Now we worry about padding. */ if (0 != srclength) { + size_t i; /* Get what's left. */ input[0] = input[1] = input[2] = '\0'; for (i = 0; i < srclength; i++) diff --git a/cgps.c b/cgps.c index 3fe1db23..f59c700b 100644 --- a/cgps.c +++ b/cgps.c @@ -410,7 +410,7 @@ static void update_compass_panel(struct gps_data_t *gpsdata) static void update_gps_panel(struct gps_data_t *gpsdata) /* This gets called once for each new GPS sentence. */ { - int i, j, n; + int i, j; int newstate; char scr[128], *s; bool usedflags[MAXCHANNELS]; @@ -444,7 +444,7 @@ static void update_gps_panel(struct gps_data_t *gpsdata) SATELLITES_WIDTH - 3, scr); } } else { - n = 0; + int n = 0; for (i = 0; i < MAX_POSSIBLE_SATS; i++) { if (n < display_sats) { if ((i < gpsdata->satellites_visible) @@ -682,7 +682,6 @@ static void usage(char *prog) int main(int argc, char *argv[]) { int option; - int c; unsigned int flags = WATCH_ENABLE; /*@ -observertrans @*/ @@ -808,6 +807,8 @@ int main(int argc, char *argv[]) /* heart of the client */ for (;;) { + int c; + if (!gps_waiting(&gpsdata, 5000000)) { die(GPS_TIMEOUT); } else { diff --git a/contrib/binlog.c b/contrib/binlog.c index 1506be88..8e5e8d9e 100644 --- a/contrib/binlog.c +++ b/contrib/binlog.c @@ -16,7 +16,7 @@ void spinner(int ); int main(int argc, char **argv) { - int speed, n, l, ifd, ofd; + int speed, n, ifd, ofd; struct termios term; char buf[BUFSIZ]; @@ -58,7 +58,7 @@ int main(int argc, char **argv) { tcflush(ifd, TCIOFLUSH); n = 0; while (1){ - l = read(ifd, buf, BUFSIZ); + int l = read(ifd, buf, BUFSIZ); if (l > 0) assert(write(ofd, buf, l) > 0); usleep(1000); diff --git a/contrib/motosend.c b/contrib/motosend.c index c1c3e477..f8e505ea 100644 --- a/contrib/motosend.c +++ b/contrib/motosend.c @@ -166,8 +166,9 @@ char *gpsd_hexdump(char *binbuf, size_t binbuflen) return hexbuf; } -int gpsd_hexpack(char *src, char *dst, int len){ - int i, k, l; +int gpsd_hexpack(char *src, char *dst, int len) +{ + int i, l; l = (int)(strlen(src) / 2); if ((l < 1) || (l > len)) @@ -175,7 +176,7 @@ int gpsd_hexpack(char *src, char *dst, int len){ bzero(dst, len); for (i = 0; i < l; i++) - if ((k = hex2bin(src+i*2)) != -1) + if (hex2bin(src+i*2) != -1) dst[i] = (char)(k & 0xff); else return -1; diff --git a/driver_ais.c b/driver_ais.c index 72036915..d006780f 100644 --- a/driver_ais.c +++ b/driver_ais.c @@ -38,10 +38,10 @@ static void from_sixbit(unsigned char *bitvec, uint start, int count, char *to) "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_ !\"#$%&'()*+,-./0123456789:;<=>?"; #endif /* S_SPLINT_S */ int i; - char newchar; /* six-bit to ASCII */ for (i = 0; i < count; i++) { + char newchar; newchar = sixchr[ubits(bitvec, start + 6 * i, 6U, false)]; if (newchar == '@') break; diff --git a/driver_nmea0183.c b/driver_nmea0183.c index fd17df4a..484dda99 100644 --- a/driver_nmea0183.c +++ b/driver_nmea0183.c @@ -1067,10 +1067,11 @@ static gps_mask_t processPASHR(int c UNUSED, char *field[], session->gpsdata.dop.tdop); } } else if (0 == strcmp("SAT", field[1])) { /* Satellite Status */ - int i, n, p, u; + int i, n, u; n = session->gpsdata.satellites_visible = atoi(field[2]); u = 0; for (i = 0; i < n; i++) { + int p; session->gpsdata.PRN[i] = p = atoi(field[3 + i * 5 + 0]); session->gpsdata.azimuth[i] = atoi(field[3 + i * 5 + 1]); session->gpsdata.elevation[i] = atoi(field[3 + i * 5 + 2]); diff --git a/driver_nmea2000.c b/driver_nmea2000.c index cb65b0ee..f9c1ae47 100644 --- a/driver_nmea2000.c +++ b/driver_nmea2000.c @@ -970,6 +970,7 @@ static gps_mask_t hnd_127250(unsigned char *bu, int len, PGN *pgn, struct gps_de print_data(session->context, bu, len, pgn); + /*@-type@*/ session->gpsdata.attitude.heading = getleu16(bu, 1) * RAD_2_DEG * 0.0001; // printf("ATT 0:%8.3f\n",session->gpsdata.attitude.heading); aux = getles16(bu, 3); @@ -981,6 +982,7 @@ static gps_mask_t hnd_127250(unsigned char *bu, int len, PGN *pgn, struct gps_de if (aux != 0x07fff) { session->gpsdata.attitude.heading += aux * RAD_2_DEG * 0.0001; } + /*@+type@*/ // printf("ATT 2:%8.3f %6x\n",session->gpsdata.attitude.heading, aux); session->gpsdata.attitude.mag_st = '\0'; session->gpsdata.attitude.pitch = NAN; @@ -1047,7 +1049,7 @@ static gps_mask_t hnd_128267(unsigned char *bu, int len, PGN *pgn, struct gps_de session->gpsdata.attitude.gyro_x = NAN; session->gpsdata.attitude.gyro_y = NAN; session->gpsdata.attitude.temp = NAN; - session->gpsdata.attitude.depth = getleu32(bu, 1) *.01; + /*@i@*/session->gpsdata.attitude.depth = getleu32(bu, 1) *.01; gpsd_report(session->context->debug, LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); @@ -1273,7 +1275,6 @@ static /*@null@*/ PGN *search_pgnlist(unsigned int pgn, PGN *pgnlist) /*@-nullstate -branchstate -globstate -mustfreeonly@*/ static void find_pgn(struct can_frame *frame, struct gps_device_t *session) { - PGN *work; unsigned int can_net; session->driver.nmea2000.workpgn = NULL; @@ -1349,6 +1350,7 @@ static void find_pgn(struct can_frame *frame, struct gps_device_t *session) } if (source_unit == session->driver.nmea2000.unit) { + PGN *work; if (session->driver.nmea2000.pgnlist != NULL) { work = search_pgnlist(source_pgn, session->driver.nmea2000.pgnlist); } else { @@ -1436,9 +1438,9 @@ static void find_pgn(struct can_frame *frame, struct gps_device_t *session) gpsd_report(session->context->debug, LOG_ERROR, "Fast error %2x %2x %2x %2x %6d\n", session->driver.nmea2000.idx, - /*@i1@*/frame->data[0], - session->driver.nmea2000.unit, - (unsigned int) session->driver.nmea2000.fast_packet_len, + /*@i2@*/frame->data[0], + session->driver.nmea2000.unit, + (unsigned int) session->driver.nmea2000.fast_packet_len, source_pgn); } } else { @@ -1489,7 +1491,7 @@ static ssize_t nmea2000_get(struct gps_device_t *session) return 0; } -/*@-mustfreeonly@*/ +/*@-mustfreeonly -nullstate@*/ static gps_mask_t nmea2000_parse_input(struct gps_device_t *session) { gps_mask_t mask; @@ -1507,7 +1509,7 @@ static gps_mask_t nmea2000_parse_input(struct gps_device_t *session) return mask; } -/*@+mustfreeonly@*/ +/*@+mustfreeonly -nullstate@*/ /*@+nullassign@*/ diff --git a/driver_oncore.c b/driver_oncore.c index 45929451..a0b208d6 100644 --- a/driver_oncore.c +++ b/driver_oncore.c @@ -67,10 +67,9 @@ oncore_msg_navsol(struct gps_device_t *session, unsigned char *buf, unsigned char flags; double lat, lon, alt; float speed, track, dop; - unsigned int i, j, st, nsv, off; + unsigned int i, j, st, nsv; int Bbused; struct tm unpacked_date; - unsigned int nsec; if (data_len != 76) return 0; @@ -99,6 +98,7 @@ oncore_msg_navsol(struct gps_device_t *session, unsigned char *buf, * and not UTC time. Do not use it. */ if (session->context->leap_seconds) { + unsigned int nsec; unpacked_date.tm_mon = (int)getub(buf, 4) - 1; unpacked_date.tm_mday = (int)getub(buf, 5); unpacked_date.tm_year = (int)getbeu16(buf, 6) - 1900; @@ -150,6 +150,7 @@ oncore_msg_navsol(struct gps_device_t *session, unsigned char *buf, nsv = 0; for (i = st = 0; i < 8; i++) { int sv, mode, sn, status; + unsigned int off; off = 40 + 4 * i; sv = (int)getub(buf, off); diff --git a/driver_sirf.c b/driver_sirf.c index 646ae94f..c8f38813 100644 --- a/driver_sirf.c +++ b/driver_sirf.c @@ -531,7 +531,7 @@ static gps_mask_t sirf_msg_navdata(struct gps_device_t *session, static gps_mask_t sirf_msg_svinfo(struct gps_device_t *session, unsigned char *buf, size_t len) { - int st, i, j, cn; + int st, i, j; if (len != 188) return 0; @@ -542,6 +542,7 @@ static gps_mask_t sirf_msg_svinfo(struct gps_device_t *session, gpsd_zero_satellites(&session->gpsdata); for (i = st = 0; i < SIRF_CHANNELS; i++) { + int cn; int off = 8 + 15 * i; bool good; session->gpsdata.PRN[st] = (int)getub(buf, off); diff --git a/driver_superstar2.c b/driver_superstar2.c index 9761c824..969ad87a 100644 --- a/driver_superstar2.c +++ b/driver_superstar2.c @@ -287,7 +287,6 @@ superstar2_msg_measurement(struct gps_device_t *session, unsigned char *buf, { gps_mask_t mask = 0; int i, n; - unsigned long ul; double t; gpsd_report(session->context->debug, LOG_PROG, @@ -301,6 +300,7 @@ superstar2_msg_measurement(struct gps_device_t *session, unsigned char *buf, } t = getled64((char *)buf, 7); /* measurement time */ for (i = 0; i < n; i++) { + unsigned long ul; session->gpsdata.raw.mtime[i] = t; session->gpsdata.PRN[i] = (int)getub(buf, 11 * i + 15) & 0x1f; session->gpsdata.ss[i] = (double)getub(buf, 11 * i * 15 + 1) / 4.0; diff --git a/driver_ubx.c b/driver_ubx.c index feb14b11..6fbcd9e3 100644 --- a/driver_ubx.c +++ b/driver_ubx.c @@ -77,8 +77,7 @@ static gps_mask_t ubx_msg_nav_sol(struct gps_device_t *session, unsigned char *buf, size_t data_len) { - unsigned short gw; - unsigned int tow, flags; + unsigned int flags; double epx, epy, epz, evx, evy, evz; unsigned char navmode; gps_mask_t mask; @@ -89,6 +88,8 @@ ubx_msg_nav_sol(struct gps_device_t *session, unsigned char *buf, flags = (unsigned int)getub(buf, 11); mask = 0; if ((flags & (UBX_SOL_VALID_WEEK | UBX_SOL_VALID_TIME)) != 0) { + unsigned short gw; + unsigned int tow; tow = (unsigned int)getleu32(buf, 0); gw = (unsigned short)getles16(buf, 8); session->newdata.time = gpsd_gpstime_resolve(session, gw, tow / 1000.0); diff --git a/driver_zodiac.c b/driver_zodiac.c index 14e15f28..025bab3d 100644 --- a/driver_zodiac.c +++ b/driver_zodiac.c @@ -124,10 +124,8 @@ static void send_rtcm(struct gps_device_t *session, static ssize_t zodiac_send_rtcm(struct gps_device_t *session, const char *rtcmbuf, size_t rtcmbytes) { - size_t len; - while (rtcmbytes > 0) { - len = (size_t) (rtcmbytes > 64 ? 64 : rtcmbytes); + size_t len = (size_t) (rtcmbytes > 64 ? 64 : rtcmbytes); send_rtcm(session, rtcmbuf, len); rtcmbytes -= len; rtcmbuf += len; @@ -218,7 +216,7 @@ static gps_mask_t handle1000(struct gps_device_t *session) static gps_mask_t handle1002(struct gps_device_t *session) /* satellite signal quality report */ { - int i, j, status, prn; + int i, j; /* ticks = getzlong(6); */ /* sequence = getzword(8); */ @@ -233,6 +231,7 @@ static gps_mask_t handle1002(struct gps_device_t *session) session->gpsdata.satellites_used = 0; memset(session->gpsdata.used, 0, sizeof(session->gpsdata.used)); for (i = 0; i < ZODIAC_CHANNELS; i++) { + int status, prn; /*@ -type @*/ session->driver.zodiac.Zv[i] = status = (int)getzword(15 + (3 * i)); session->driver.zodiac.Zs[i] = prn = (int)getzword(16 + (3 * i)); diff --git a/drivers.c b/drivers.c index 90eb5689..f741d1b4 100644 --- a/drivers.c +++ b/drivers.c @@ -27,8 +27,6 @@ ssize_t generic_get(struct gps_device_t *session) gps_mask_t generic_parse_input(struct gps_device_t *session) { - const struct gps_type_t **dp; - if (session->packet.type == BAD_PACKET) return 0; else if (session->packet.type == COMMENT_PACKET) { @@ -36,6 +34,7 @@ gps_mask_t generic_parse_input(struct gps_device_t *session) return 0; #ifdef NMEA_ENABLE } else if (session->packet.type == NMEA_PACKET) { + const struct gps_type_t **dp; gps_mask_t st = 0; char *sentence = (char *)session->packet.outbuffer; @@ -1177,7 +1176,7 @@ static bool aivdm_decode(const char *buf, size_t buflen, unsigned char *field[NMEA_MAX*2]; unsigned char fieldcopy[NMEA_MAX*2+1]; unsigned char *data, *cp; - unsigned char ch, pad; + unsigned char pad; struct aivdm_context_t *ais_context; int i; @@ -1278,6 +1277,7 @@ static bool aivdm_decode(const char *buf, size_t buflen, /* wacky 6-bit encoding, shades of FIELDATA */ /*@ +charint @*/ for (cp = data; cp < data + strlen((char *)data); cp++) { + unsigned char ch; ch = *cp; ch -= 48; if (ch >= 40) diff --git a/gpsctl.c b/gpsctl.c index 74cdda64..909219a0 100644 --- a/gpsctl.c +++ b/gpsctl.c @@ -610,7 +610,6 @@ int main(int argc, char **argv) static struct gps_device_t session; /* zero this too */ fd_set all_fds; fd_set rfds; - int maxfd = 0; /*@ -mustfreeonly -immediatetrans @*/ gps_context_init(&context); @@ -628,6 +627,7 @@ int main(int argc, char **argv) * and find out what is actually there. */ if (!(forcetype != NULL && echo)) { + int maxfd = 0; if (device == NULL) { gpsd_report(context.debug, LOG_ERROR, "device must be specified for low-level access.\n"); diff --git a/gpsd_json.c b/gpsd_json.c index dbebcc5c..0a5fc22c 100644 --- a/gpsd_json.c +++ b/gpsd_json.c @@ -275,7 +275,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) { - int i, j, used, reported = 0; + int i, reported = 0; char tbuf[JSON_DATE_MAX+1]; assert(replylen > 2); @@ -328,10 +328,11 @@ void json_sky_dump(const struct gps_data_t *datap, if (reported) { (void)strlcat(reply, "\"satellites\":[", replylen); for (i = 0; i < reported; i++) { - used = 0; + int j; + bool used = false; for (j = 0; j < datap->satellites_used; j++) if (datap->used[j] == datap->PRN[i]) { - used = 1; + used = true; break; } if (datap->PRN[i]) { diff --git a/lcdgps.c b/lcdgps.c index 3c3eee6a..d35cd10c 100644 --- a/lcdgps.c +++ b/lcdgps.c @@ -76,13 +76,13 @@ int sd; /* Read a line from a socket */ ssize_t sockreadline(int sockd,void *vptr,size_t maxlen) { - ssize_t n,rc; + ssize_t n; char c,*buffer; buffer=vptr; for (n = 1; n < (ssize_t)maxlen; n++) { - + ssize_t rc; if ((rc=read(sockd,&c,1))==1) { *buffer++=c; if (c=='\n') @@ -108,13 +108,13 @@ ssize_t sockreadline(int sockd,void *vptr,size_t maxlen) { /* Write a line to a socket */ ssize_t sockwriteline(int sockd,const void *vptr,size_t n) { size_t nleft; - ssize_t nwritten; const char *buffer; buffer=vptr; nleft=n; while (nleft>0) { + ssize_t nwritten; if ((nwritten= write(sockd,buffer,nleft))<=0) { if (errno==EINTR) nwritten=0; diff --git a/libgps_json.c b/libgps_json.c index 83cfbb8e..d4b10bf5 100644 --- a/libgps_json.c +++ b/libgps_json.c @@ -356,7 +356,7 @@ static int json_error_read(const char *buf, struct gps_data_t *gpsdata, static int json_pps_read(const char *buf, struct gps_data_t *gpsdata, /*@null@*/ const char **endptr) { - int real_sec, real_nsec, clock_sec, clock_nsec; + int real_sec = 0, real_nsec = 0, clock_sec = 0, clock_nsec = 0; /*@ -fullinitblock @*/ const struct json_attr_t json_attrs_pps[] = { /* *INDENT-OFF* */ diff --git a/libgps_shm.c b/libgps_shm.c index f25a07e4..88b340e8 100644 --- a/libgps_shm.c +++ b/libgps_shm.c @@ -70,12 +70,11 @@ bool gps_shm_waiting(const struct gps_data_t *gpsdata, int timeout) /* check to see if new data has been written */ { volatile struct shmexport_t *shared = (struct shmexport_t *)PRIVATE(gpsdata)->shmseg; - bool newdata; timestamp_t basetime = timestamp(); /* busy-waiting sucks, but there's not really an alternative */ for (;;) { - newdata = false; + bool newdata = false; barrier(); if (shared->bookend1 == shared->bookend2 && shared->bookend1 > PRIVATE(gpsdata)->tick) newdata = true; diff --git a/libgps_sock.c b/libgps_sock.c index bdbecdea..a8361077 100644 --- a/libgps_sock.c +++ b/libgps_sock.c @@ -267,9 +267,9 @@ int gps_unpack(char *buf, struct gps_data_t *gpsdata) for (ns = buf; ns; ns = strstr(ns + 1, "GPSD")) { if ( /*@i1@*/ strncmp(ns, "GPSD", 4) == 0) { - bool eol = false; /* the following should execute each time we have a good next sp */ for (sp = ns + 5; *sp != '\0'; sp = tp + 1) { + bool eol = false; tp = sp + strcspn(sp, ",\r\n"); eol = *tp == '\r' || *tp == '\n'; if (*tp == '\0') diff --git a/libgpsd_core.c b/libgpsd_core.c index f9dce0fd..69d16199 100644 --- a/libgpsd_core.c +++ b/libgpsd_core.c @@ -998,7 +998,7 @@ int gpsd_await_data(/*@out@*/fd_set *rfds, const int debug) /* await data from any socket in the all_fds set */ { - int i, status; + int status; #ifdef COMPAT_SELECT struct timeval tv; #endif /* COMPAT_SELECT */ @@ -1036,6 +1036,7 @@ int gpsd_await_data(/*@out@*/fd_set *rfds, /*@ +usedef +nullpass @*/ if (debug >= LOG_SPIN) { + int i; char dbuf[BUFSIZ]; dbuf[0] = '\0'; for (i = 0; i < FD_SETSIZE; i++) @@ -1444,7 +1445,6 @@ int gpsd_multipoll(const bool data_ready, { if (data_ready) { - gps_mask_t changed; int fragments; gpsd_report(device->context->debug, LOG_RAW + 1, @@ -1471,7 +1471,7 @@ int gpsd_multipoll(const bool data_ready, #endif /* NETFEED_ENABLE */ for (fragments = 0; ; fragments++) { - changed = gpsd_poll(device); + gps_mask_t changed = gpsd_poll(device); if (changed == ERROR_SET) { gpsd_report(device->context->debug, LOG_WARN, diff --git a/monitor_oncore.c b/monitor_oncore.c index f5aec8da..43529e82 100644 --- a/monitor_oncore.c +++ b/monitor_oncore.c @@ -175,7 +175,7 @@ static bool oncore_initialize(void) static void oncore_update(void) { - unsigned int i, j, off; + unsigned int i, off; unsigned char *buf; unsigned int type; @@ -297,6 +297,7 @@ static void oncore_update(void) memset(Bblines, 0, sizeof(Bblines)); Bblines_mask = 0; for (i = 0; i < ch; i++) { + unsigned int j; off = 5 + 7 * i; sv = (unsigned char)getub(buf, off); /*@ -boolops @*/ diff --git a/monitor_sirf.c b/monitor_sirf.c index 421674f1..2d5e1d5f 100644 --- a/monitor_sirf.c +++ b/monitor_sirf.c @@ -272,7 +272,7 @@ static void decode_ecef(double x, double y, double z, /*@ -globstate */ static void sirf_update(void) { - int i, j, ch, sv, off; + int i, j, ch, sv; unsigned char *buf; size_t len; uint8_t dgps; @@ -333,7 +333,7 @@ static void sirf_update(void) case 0x04: /* Measured Tracking Data */ ch = (int)getub(buf, 7); for (i = 0; i < ch; i++) { - int az, el, state; + int az, el, state, off; double cn; off = 8 + 15 * i; diff --git a/packet.c b/packet.c index ce600627..ac25fad1 100644 --- a/packet.c +++ b/packet.c @@ -1398,15 +1398,16 @@ static void packet_discard(struct gps_packet_t *lexer) static void character_discard(struct gps_packet_t *lexer) /* shift the input buffer to discard one character and reread data */ { - char scratchbuf[MAX_PACKET_LENGTH*2+1]; memmove(lexer->inbuffer, lexer->inbuffer + 1, (size_t)-- lexer->inbuflen); lexer->inbufptr = lexer->inbuffer; - if (lexer->debug >= LOG_RAW+1) + if (lexer->debug >= LOG_RAW+1) { + char scratchbuf[MAX_PACKET_LENGTH*2+1]; gpsd_report(lexer->debug, LOG_RAW + 1, "Character discarded, buffer %zu chars = %s\n", lexer->inbuflen, gpsd_packetdump(scratchbuf, sizeof(scratchbuf), (char *)lexer->inbuffer, lexer->inbuflen)); + } } /* get 0-origin big-endian words relative to start of packet buffer */ diff --git a/ppsthread.c b/ppsthread.c index 00f7437c..8ea10982 100644 --- a/ppsthread.c +++ b/ppsthread.c @@ -193,13 +193,15 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) #endif /* TIOCMIWAIT */ #if defined(HAVE_SYS_TIMEPPS_H) int edge_kpps = 0; /* 0 = clear edge, 1 = assert edge */ +#ifndef S_SPLINT_S int cycle_kpps, duration_kpps; struct timespec pulse_kpps[2] = { {0, 0}, {0, 0} }; struct timespec tv_kpps; pps_info_t pi; memset( (void *)&pi, 0, sizeof(pps_info_t)); -#endif +#endif /* S_SPLINT_S */ +#endif /* defined(HAVE_SYS_TIMEPPS_H) */ gpsd_report(session->context->debug, LOG_PROG, "PPS Create Thread gpsd_ppsmonitor\n"); @@ -251,7 +253,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) /* ok and log used by KPPS and TIOMCWAIT */ ok = false; log = NULL; -#if defined(HAVE_SYS_TIMEPPS_H) +#if defined(HAVE_SYS_TIMEPPS_H) && !defined(S_SPLINT_S) if ( 0 <= session->kernelpps_handle ) { struct timespec kernelpps_tv; /* on a quad core 2.4GHz Xeon this removes about 20uS of @@ -312,7 +314,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) } } } -#endif /* HAVE_SYS_TIMEPPS_H */ +#endif /* defined(HAVE_SYS_TIMEPPS_H) && !defined(S_SPLINT_S) */ #if defined(TIOCMIWAIT) @@ -498,6 +500,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) (long)l_offset); log1 = "timestamp out of range"; } else { + /*@-compdef@*/ last_second_used = session->last_fixtime; if (session->thread_report_hook != NULL) log1 = session->thread_report_hook(session, @@ -507,6 +510,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) if (session->context->pps_hook != NULL) session->context->pps_hook(session, &drift, edge_offset); + /*@+compdef@*/ } gpsd_report(session->context->debug, LOG_RAW, "PPS edge %.20s %lu.%06lu offset %.9f\n", diff --git a/srecord.c b/srecord.c index 402a6e30..b76ba9ac 100644 --- a/srecord.c +++ b/srecord.c @@ -121,7 +121,7 @@ unsigned char sr_sum(unsigned int count, unsigned int addr, unsigned char *bbuf) { int i, j; - unsigned char k, sum = 0; + unsigned char sum = 0; sum = (count & 0xff); sum += ((addr & 0x000000ff)); @@ -130,7 +130,7 @@ sr_sum(unsigned int count, unsigned int addr, unsigned char *bbuf) sum += ((addr & 0xff000000) >> 24); j = count - 5; for (i = 0; i < j; i++) { - k = bbuf[i]; + unsigned char k = bbuf[i]; sum += k; } return ~sum; diff --git a/test_bits.c b/test_bits.c index b70fa6a3..1b93a50e 100644 --- a/test_bits.c +++ b/test_bits.c @@ -135,8 +135,6 @@ int main(int argc, char *argv[]) 7, 2, 2, false, "2 bits crossing 1st to 2nd byte (0x1923)"}, }; - unsigned char *sp; - memcpy(buf, "\x01\x02\x03\x04\x05\x06\x07\x08", 8); memcpy(buf + 8, "\xff\xfe\xfd\xfc\xfb\xfa\xf9\xf8", 8); memcpy(buf + 16, "\x40\x09\x21\xfb\x54\x44\x2d\x18", 8); @@ -151,6 +149,8 @@ int main(int argc, char *argv[]) /*@+type@*/ if (!quiet) { + unsigned char *sp; + (void)fputs("Test data:", stdout); for (sp = buf; sp < buf + 28; sp++) (void)printf(" %02x", *sp); -- cgit v1.2.1