summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-03-29 07:57:18 -0400
committerEric S. Raymond <esr@thyrsus.com>2011-03-29 07:57:18 -0400
commitdb7d7be4c385b0810378db4f5580b5dc8dcfb1ee (patch)
treedab588924b29d7b66800d1b0560f8c3a2c584e6a
parent41160f7fa55bc99a3e7a57a957dcae22f33069cb (diff)
downloadgpsd-db7d7be4c385b0810378db4f5580b5dc8dcfb1ee.tar.gz
scan-build and splint cleanup. All regression tests pass.
-rw-r--r--driver_evermore.c4
-rw-r--r--driver_garmin.c8
-rw-r--r--driver_rtcm2.c3
-rw-r--r--driver_tsip.c2
-rw-r--r--gpsdecode.c4
-rw-r--r--gpsmon.c1
-rw-r--r--json.c12
-rw-r--r--monitor_italk.c4
-rw-r--r--net_ntrip.c7
-rw-r--r--packet.c17
10 files changed, 35 insertions, 27 deletions
diff --git a/driver_evermore.c b/driver_evermore.c
index 55da0eed..a8534d75 100644
--- a/driver_evermore.c
+++ b/driver_evermore.c
@@ -172,6 +172,10 @@ gps_mask_t evermore_parse(struct gps_device_t * session, unsigned char *buf,
tp++;
}
+ /* bail out if no payload (scan-build throws spurious error otherwise) */
+ if (tp <= buf2)
+ return 0;
+
type = (unsigned char)getub(buf2, 1);
/*@ +usedef @*/
diff --git a/driver_garmin.c b/driver_garmin.c
index 2acc8e55..f784e853 100644
--- a/driver_garmin.c
+++ b/driver_garmin.c
@@ -742,7 +742,7 @@ static void Build_Send_USB_Packet(struct gps_device_t *session,
// So here goes just in case
if (0 == (theBytesToWrite % ASYNC_DATA_SIZE)) {
char *n = "";
- theBytesReturned = gpsd_write(session, n, 0);
+ (void)gpsd_write(session, n, 0);
}
}
#endif /* __linux__ || S_SPLINT_S */
@@ -792,7 +792,8 @@ static void Build_Send_SER_Packet(struct gps_device_t *session,
}
// Add DLE, ETX
*buffer++ = (uint8_t) DLE;
- *buffer++ = (uint8_t) ETX;
+ /* we used to say n++ here, but scan-build complains */
+ *buffer = (uint8_t) ETX;
#if 1
gpsd_report(LOG_IO, "Garmin: SendPacket(), writing %zd bytes: %s\n",
@@ -1098,7 +1099,8 @@ gps_mask_t garmin_ser_parse(struct gps_device_t *session)
n + i);
return 0;
}
- c = buf[n + i++];
+ /* we used to say n++ here, but scan-build complains */
+ c = buf[n + i];
if ('\x03' != c) {
Send_NAK();
gpsd_report(LOG_RAW + 1, "Garmin: Final ETX not ETX\n");
diff --git a/driver_rtcm2.c b/driver_rtcm2.c
index 5e04e4a2..a9cb0b12 100644
--- a/driver_rtcm2.c
+++ b/driver_rtcm2.c
@@ -775,7 +775,8 @@ void rtcm2_unpack( /*@out@*/ struct rtcm2_t *tp, char *buf)
if (m->w4.datum_sub_div_char3) {
tp->reference.datum[n++] = (char)(m->w4.datum_sub_div_char3);
}
- tp->reference.datum[n++] = '\0';
+ /* we used to say n++ here, but scan-build complains */
+ tp->reference.datum[n] = '\0';
if (len >= 4) {
tp->reference.dx = m->w5.dx * DXYZ_SCALE;
tp->reference.dy =
diff --git a/driver_tsip.c b/driver_tsip.c
index 7a4ff62d..93e880ad 100644
--- a/driver_tsip.c
+++ b/driver_tsip.c
@@ -551,7 +551,7 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
session->newdata.latitude = getbed(buf, 0) * RAD_2_DEG;
session->newdata.longitude = getbed(buf, 8) * RAD_2_DEG;
session->newdata.altitude = getbed(buf, 16);
- d1 = getbed(buf, 24); /* clock bias */
+ //d1 = getbed(buf, 24); clock bias */
f1 = getbef(buf, 32); /* time-of-fix */
if ((session->context->valid & GPS_TIME_VALID)!=0) {
session->newdata.time =
diff --git a/gpsdecode.c b/gpsdecode.c
index 213f4e55..17501422 100644
--- a/gpsdecode.c
+++ b/gpsdecode.c
@@ -485,8 +485,8 @@ int main(int argc, char **argv)
exit(1);
}
}
- argc -= optind;
- argv += optind;
+ //argc -= optind;
+ //argv += optind;
if (mode == doencode)
encode(stdin, stdout);
diff --git a/gpsmon.c b/gpsmon.c
index a243d3a9..bbe99880 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -740,7 +740,6 @@ int main(int argc, char **argv)
continue;
/*@ +usedef +compdef @*/
- arg = line;
if (isspace(line[1])) {
for (arg = line + 2; *arg != '\0' && isspace(*arg); arg++)
arg++;
diff --git a/json.c b/json.c
index e4f2d60f..462c0c23 100644
--- a/json.c
+++ b/json.c
@@ -498,7 +498,7 @@ int json_read_array(const char *cp, const struct json_array_t *arr,
const char **end)
{
/*@-nullstate -onlytrans@*/
- int substatus, offset;
+ int substatus, offset, arrcount;
char *tp;
if (end != NULL)
@@ -515,8 +515,7 @@ int json_read_array(const char *cp, const struct json_array_t *arr,
cp++;
tp = arr->arr.strings.store;
- if (arr->count != NULL)
- *(arr->count) = 0;
+ arrcount = 0;
for (offset = 0; offset < arr->maxlen; offset++) {
json_debug_trace((1, "Looking at %s\n", cp));
switch (arr->element_type) {
@@ -563,8 +562,7 @@ int json_read_array(const char *cp, const struct json_array_t *arr,
json_debug_trace((1, "Invalid array subtype.\n"));
return JSON_ERR_SUBTYPE;
}
- if (arr->count != NULL)
- (*arr->count)++;
+ arrcount++;
if (isspace(*cp))
cp++;
if (*cp == ']') {
@@ -580,11 +578,13 @@ int json_read_array(const char *cp, const struct json_array_t *arr,
json_debug_trace((1, "Too many elements in array.\n"));
return JSON_ERR_SUBTOOLONG;
breakout:
+ if (arr->count != NULL)
+ *(arr->count) = arrcount;
if (end != NULL)
*end = cp;
/*@ -nullderef @*/
json_debug_trace((1, "leaving json_read_array() with %d elements\n",
- *arr->count));
+ arrcount));
/*@ +nullderef @*/
return 0;
/*@+nullstate +onlytrans@*/
diff --git a/monitor_italk.c b/monitor_italk.c
index f38cc851..1bb79a76 100644
--- a/monitor_italk.c
+++ b/monitor_italk.c
@@ -71,7 +71,7 @@ static bool italk_initialize(void)
static void display_itk_navfix(unsigned char *buf, size_t len)
{
- unsigned int tow, tod, nsec, d, svlist;
+ unsigned int tow, tod, d, svlist;
unsigned short gps_week, nsv;
unsigned short year, mon, day, hour, min, sec;
double epx, epy, epz, evx, evy, evz;
@@ -95,7 +95,7 @@ static void display_itk_navfix(unsigned char *buf, size_t len)
hour = (ushort) getleu16(buf, 7 + 66);
min = (ushort) getleu16(buf, 7 + 68);
sec = (ushort) getleu16(buf, 7 + 70);
- nsec = (ushort) getleu32(buf, 7 + 72);
+ //nsec = (ushort) getleu32(buf, 7 + 72);
year = (ushort) getleu16(buf, 7 + 76);
mon = (ushort) getleu16(buf, 7 + 78);
day = (ushort) getleu16(buf, 7 + 80);
diff --git a/net_ntrip.c b/net_ntrip.c
index 27b1de15..bcdc1dfb 100644
--- a/net_ntrip.c
+++ b/net_ntrip.c
@@ -488,9 +488,10 @@ int ntrip_open(struct gps_device_t *device, char *caster)
(void)strlcpy(device->ntrip.stream.mountpoint,
stream,
sizeof(device->ntrip.stream.mountpoint));
- (void)strlcpy(device->ntrip.stream.credentials,
- auth,
- sizeof(device->ntrip.stream.credentials));
+ if (auth != NULL)
+ (void)strlcpy(device->ntrip.stream.credentials,
+ auth,
+ sizeof(device->ntrip.stream.credentials));
(void)strlcpy(device->ntrip.stream.url,
url,
sizeof(device->ntrip.stream.url));
diff --git a/packet.c b/packet.c
index 39053977..5181101f 100644
--- a/packet.c
+++ b/packet.c
@@ -1448,7 +1448,8 @@ void packet_parse(struct gps_packet_t *lexer)
}
if (lexer->inbuffer[n++] != DLE)
goto not_garmin;
- if (lexer->inbuffer[n++] != ETX)
+ /* we used to say n++ here, but scan-build complains */
+ if (lexer->inbuffer[n] != ETX)
goto not_garmin;
/*@ +charint */
chksum &= 0xff;
@@ -1694,7 +1695,8 @@ void packet_parse(struct gps_packet_t *lexer)
}
if (lexer->inbuffer[n++] != DLE)
goto not_evermore;
- if (lexer->inbuffer[n++] != ETX)
+ /* we used to say n++ here, but scan-build complains */
+ if (lexer->inbuffer[n] != ETX)
goto not_evermore;
crc &= 0xff;
if (crc != checksum) {
@@ -1720,21 +1722,20 @@ void packet_parse(struct gps_packet_t *lexer)
#define getiw(i) ((uint16_t)(((uint16_t)getib((i)+1) << 8) | (uint16_t)getib((i))))
else if (lexer->state == ITALK_RECOGNIZED) {
- volatile uint16_t len, n, csum, xsum, tmpw;
- volatile uint32_t tmpdw;
+ volatile uint16_t len, n, csum, xsum;
/* number of words */
len = (uint16_t) (lexer->inbuffer[6] & 0xff);
/*@ -type @*/
- /* initialize all my registers */
- csum = tmpw = tmpdw = 0;
/* expected checksum */
xsum = getiw(7 + 2 * len);
+
+ csum = 0;
for (n = 0; n < len; n++) {
- tmpw = getiw(7 + 2 * n);
- tmpdw = (csum + 1) * (tmpw + n);
+ volatile uint16_t tmpw = getiw(7 + 2 * n);
+ volatile uint32_t tmpdw = (csum + 1) * (tmpw + n);
csum ^= (tmpdw & 0xffff) ^ ((tmpdw >> 16) & 0xffff);
}
/*@ +type @*/