summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2006-10-26 21:06:58 +0000
committerEric S. Raymond <esr@thyrsus.com>2006-10-26 21:06:58 +0000
commitfd4454fe36da611eef7d3c75918ac5a4d5c0c12c (patch)
treed3251d8fe02e0728b5e06cee682a02fcf5f99e0a
parent8c4c1b38e7db2adc24528912d20486d386764327 (diff)
downloadgpsd-fd4454fe36da611eef7d3c75918ac5a4d5c0c12c.tar.gz
Partial splint cleanup.
-rw-r--r--.splintrc1
-rw-r--r--dgnss.c4
-rw-r--r--garmin.c28
-rw-r--r--garminctl.c77
-rw-r--r--gps.h2
-rw-r--r--itraxctl.c25
-rw-r--r--libgps.c2
-rw-r--r--libgpsd_core.c9
-rw-r--r--nmea_parse.c8
-rw-r--r--packet.c11
-rw-r--r--sirfmon.c4
-rw-r--r--zodiac.c1
12 files changed, 96 insertions, 76 deletions
diff --git a/.splintrc b/.splintrc
index 07f47f6b..71321211 100644
--- a/.splintrc
+++ b/.splintrc
@@ -20,6 +20,7 @@
-Du_int64_t=ulong
-Din_addr_t=int
-Dcaddr_t=short
+-Disgps30bits_t=uint
-DFD_SETSIZE=31
-DB57600=010001
-DB115200=0010011
diff --git a/dgnss.c b/dgnss.c
index 42c769d9..bf078f94 100644
--- a/dgnss.c
+++ b/dgnss.c
@@ -53,8 +53,8 @@ int dgnss_poll(struct gps_context_t *context)
context->rtcmbytes = read(context->dsock, context->rtcmbuf, sizeof(context->rtcmbuf));
if ((context->rtcmbytes == -1 && errno != EAGAIN) ||
(context->rtcmbytes == 0)) {
- shutdown(context->dsock, SHUT_RDWR);
- close(context->dsock);
+ (void)shutdown(context->dsock, SHUT_RDWR);
+ (void)close(context->dsock);
return -1;
} else
context->rtcmtime = timestamp();
diff --git a/garmin.c b/garmin.c
index ef6f2913..ae85a4f1 100644
--- a/garmin.c
+++ b/garmin.c
@@ -245,7 +245,8 @@ gps_mask_t PrintSERPacket(struct gps_device_t *session, unsigned char pkt_id
switch( pkt_id ) {
case GARMIN_PKTID_L001_COMMAND_DATA:
- prod_id = get_uint16(buf);
+ prod_id = get_uint16((uint8_t *)buf);
+ /*@ -branchstate @*/
switch ( prod_id ) {
case CMND_ABORT:
msg = "Abort current xfer";
@@ -265,14 +266,15 @@ gps_mask_t PrintSERPacket(struct gps_device_t *session, unsigned char pkt_id
msg = msg_buf;
break;
}
+ /*@ +branchstate @*/
gpsd_report(3, "Appl, Command Data: %s\n", msg);
break;
case GARMIN_PKTID_PRODUCT_RQST:
gpsd_report(3, "Appl, Product Data req\n");
break;
case GARMIN_PKTID_PRODUCT_DATA:
- prod_id = get_uint16(buf);
- ver = get_uint16(&buf[2]);
+ prod_id = get_uint16((uint8_t *)buf);
+ ver = get_uint16((uint8_t *)&buf[2]);
maj_ver = (int)(ver / 100);
min_ver = (int)(ver - (maj_ver * 100));
gpsd_report(3, "Appl, Product Data, sz: %d\n", pkt_len);
@@ -432,7 +434,7 @@ gps_mask_t PrintSERPacket(struct gps_device_t *session, unsigned char pkt_id
// after a GARMIN_PKTID_PRODUCT_RQST
gpsd_report(3, "Appl, Product Capability, sz: %d\n", pkt_len);
for ( i = 0; i < pkt_len ; i += 3 ) {
- gpsd_report(3, " %c%03d\n", buf[i], get_uint16( &buf[i+1] ) );
+ gpsd_report(3, " %c%03d\n", buf[i], get_uint16((uint8_t *)&buf[i+1] ) );
}
break;
default:
@@ -492,9 +494,10 @@ static gps_mask_t PrintUSBPacket(struct gps_device_t *session, Packet_t *pkt)
case GARMIN_LAYERID_APPL:
/* raw data transport, shared with Garmin Serial Driver */
- mask = PrintSERPacket(session, (unsigned char)pkt->mPacketId
- , (int)mDataSize, pkt->mData.uchars );
-
+ mask = PrintSERPacket(session,
+ (unsigned char)pkt->mPacketId,
+ (int)mDataSize,
+ (unsigned char *)pkt->mData.uchars);
break;
case 75:
// private, garmin USB kernel driver specific
@@ -545,7 +548,7 @@ static void Build_Send_Packet( struct gps_device_t *session,
uint8_t *buffer = (uint8_t *)session->driver.garmin.Buffer;
Packet_t *thePacket = (Packet_t*)buffer;
ssize_t theBytesReturned = 0;
- ssize_t theBytesToWrite = 12 + length;
+ ssize_t theBytesToWrite = 12 + (ssize_t)length;
set_int32(buffer, layer_id);
set_int32(buffer+4, pkt_id);
@@ -563,7 +566,7 @@ static void Build_Send_Packet( struct gps_device_t *session,
(void)PrintUSBPacket ( session, thePacket);
theBytesReturned = write( session->gpsdata.gps_fd
- , thePacket, theBytesToWrite);
+ , thePacket, (size_t)theBytesToWrite);
gpsd_report(4, "SendPacket(), wrote %d bytes\n", theBytesReturned);
// Garmin says:
@@ -617,6 +620,7 @@ static int GetPacket (struct gps_device_t *session )
// continue;
for( cnt = 0 ; cnt < 10 ; cnt++ ) {
+ size_t pkt_size;
// Read async data until the driver returns less than the
// max async data size, which signifies the end of a packet
@@ -648,7 +652,7 @@ static int GetPacket (struct gps_device_t *session )
session->driver.garmin.BufferLen = 0;
break;
}
- size_t pkt_size = 12 + get_int32((uint8_t*)&thePacket->mDataSize);
+ pkt_size = 12 + get_int32((uint8_t*)&thePacket->mDataSize);
if ( 12 <= session->driver.garmin.BufferLen) {
// have enough data to check packet size
if ( session->driver.garmin.BufferLen > pkt_size) {
@@ -997,7 +1001,7 @@ gps_mask_t garmin_ser_parse(struct gps_device_t *session)
data_index = 0;
for ( i = 0; i < 256 ; i++ ) {
- if ( pkt_len == data_index ) {
+ if ( (int)pkt_len == data_index ) {
// got it all
break;
}
@@ -1052,6 +1056,7 @@ gps_mask_t garmin_ser_parse(struct gps_device_t *session)
}
/* debug */
+ /*@ -usedef -compdef @*/
for ( i = 0 ; i < data_index ; i++ ) {
gpsd_report(6, "Char: %#02x\n", data_buf[i]);
}
@@ -1061,6 +1066,7 @@ gps_mask_t garmin_ser_parse(struct gps_device_t *session)
, pkt_id, pkt_len, chksum);
mask = PrintSERPacket(session, pkt_id, pkt_len, data_buf);
+ /*@ +usedef +compdef @*/
return mask;
}
/*@ -charint @*/
diff --git a/garminctl.c b/garminctl.c
index 0b24f196..6cccec4e 100644
--- a/garminctl.c
+++ b/garminctl.c
@@ -19,6 +19,7 @@
#include <string.h>
#include <termios.h>
#include <unistd.h>
+#include <stdbool.h>
/* gross - globals */
static struct termios ttyset;
@@ -29,11 +30,11 @@ static int debug_level = 0;
#define GARMIN_PACKET 1
#define NMEA_PACKET 2
-void logit(int , char *, ...);
-void nmea_add_checksum(char *);
-int nmea_send(int , const char *, ... );
+static void logit(int , char *, ...);
+static void nmea_add_checksum(char *);
+static int nmea_send(int , const char *, ... );
#ifndef HAVE_STRLCAT
- size_t strlcat(char *dst, const char *src, size_t size);
+static size_t strlcat(char *dst, const char *src, size_t size);
#endif
/* how many characters to look at when trying to find baud rate lock */
@@ -138,7 +139,7 @@ static int set_speed( int fd,unsigned int speed)
{
unsigned int rate, count, state;
int st;
- unsigned char c;
+ char c;
(void)tcflush(fd, TCIOFLUSH); /* toss stale data */
@@ -270,9 +271,10 @@ static int set_speed( int fd,unsigned int speed)
static unsigned int *ip, rates[] = {0, 4800, 9600, 19200, 38400, 57600};
/* return speed found */
-static unsigned int hunt_open(int fd, int *st)
+/*@ -mustdefine @*/
+static unsigned int hunt_open(int fd, /*@out@*/int *st)
{
- int speed;
+ unsigned int speed;
/*
* Tip from Chris Kuethe: the FTDI chip used in the Trip-Nav
* 200 (and possibly other USB GPSes) gets completely hosed
@@ -296,8 +298,9 @@ static unsigned int hunt_open(int fd, int *st)
}
return 0;
}
+/*@ +mustdefine @*/
-static void serial_initialize(char *device, int *fd, int *st)
+static void serial_initialize(const char *device, /*@out@*/int *fd, /*@out@*/int *st)
{
if ( (*fd = open(device,O_RDWR)) < 0) {
perror(device);
@@ -359,6 +362,17 @@ int nmea_send(int fd, const char *fmt, ... )
}
}
+static void settle(void)
+{
+ struct timespec delay, rem;
+ /*@ -type -unrecog @*/
+ memset( &delay, 0, sizeof(delay));
+ delay.tv_sec = 0;
+ delay.tv_nsec = 333000000L;
+ nanosleep(&delay, &rem);
+ /*@ +type +unrecog @*/
+}
+
static void usage(void) {
fprintf(stderr, "Usage: garminctl [OPTIONS] {serial-port}\n\n"
"SVN ID: $Id$ \n"
@@ -373,16 +387,16 @@ static void usage(void) {
int main( int argc, char **argv)
{
- struct timespec delay, rem;
- int fd;
+ int fd = 0;
int st; /* packet type detected */
int status;
char *buf;
int option;
- int to_nmea = 0;
- int to_binary = 0;
+ bool to_nmea = false;
+ bool to_binary = false;
char *device = "";
+ /*@ -branchstate @*/
while ((option = getopt(argc, argv, "?hbnVD:")) != -1) {
switch (option) {
case 'D':
@@ -390,11 +404,11 @@ int main( int argc, char **argv)
break;
case 'n':
// go to NMEA mode
- to_nmea = 1;
+ to_nmea = true;
break;
case 'b':
// go to Binary mode
- to_binary = 1;
+ to_binary = true;
break;
case 'V':
(void)fprintf(stderr, "%s: SVN ID: $Id$ \n", argv[0]);
@@ -410,7 +424,7 @@ int main( int argc, char **argv)
if (optind < argc) {
device = argv[optind];
}
- if ( !device || !strlen(device) ) {
+ if ( !device || strlen(device)==0 ) {
logit(0, "ERROR: missing device name\n");
usage();
exit(1);
@@ -421,7 +435,7 @@ int main( int argc, char **argv)
usage();
exit(1);
}
-
+ /*@ +branchstate @*/
serial_initialize(device, &fd, &st);
@@ -440,23 +454,14 @@ int main( int argc, char **argv)
logit(0, "=> GPS: FAILED\n");
return 1;
}
- // wait 33mS, essential!
- memset( &delay, 0, sizeof(delay));
- delay.tv_sec = 0;
- delay.tv_nsec = 33300000L;
- nanosleep(&delay, &rem);
+ settle(); // wait 33mS, essential!
/* once a sec, no binary, no averaging, NMEA 2.3, WAAS */
- nmea_send(fd, "$PGRMC1,1,1");
- //nmea_send(fd, "$PGRMC1,1,1,1,,,,2,W,N");
- nmea_send(fd, "$PGRMI,,,,,,,R");
- // wait 333mS, essential!
- // then figure out the new speed.
- memset( &delay, 0, sizeof(delay));
- delay.tv_sec = 0;
- delay.tv_nsec = 333000000L;
- nanosleep(&delay, &rem);
+ (void)nmea_send(fd, "$PGRMC1,1,1");
+ //(void)nmea_send(fd, "$PGRMC1,1,1,1,,,,2,W,N");
+ (void)nmea_send(fd, "$PGRMI,,,,,,,R");
+ settle(); // wait 333mS, essential!
if ( (bps = hunt_open(fd, &st))==0) {
logit(0, "Can't sync up with device!\n");
@@ -465,17 +470,11 @@ int main( int argc, char **argv)
} else if ( to_binary && st == GARMIN_PACKET ) {
logit(0, "GPS already in GARMIN mode\n");
} else if ( to_binary ) {
- nmea_send(fd, "$PGRMC1,1,2,1,,,,2,W,N");
- nmea_send(fd, "$PGRMI,,,,,,,R");
+ (void)nmea_send(fd, "$PGRMC1,1,2,1,,,,2,W,N");
+ (void)nmea_send(fd, "$PGRMI,,,,,,,R");
// garmin serial binary is 9600 only!
logit(0, "NOTE: Garmin binary is 9600 baud only!\n");
- // wait 333mS, essential!
- // then figure out the new speed.
- memset( &delay, 0, sizeof(delay));
- delay.tv_sec = 0;
- delay.tv_nsec = 333000000L;
- nanosleep(&delay, &rem);
-
+ settle(); // wait 333mS, essential!
if ( (bps = hunt_open(fd, &st))==0) {
logit(0, "Can't sync up with device!\n");
exit(1);
diff --git a/gps.h b/gps.h
index f9e8b3db..49640e5c 100644
--- a/gps.h
+++ b/gps.h
@@ -96,12 +96,14 @@ struct gps_fix_t {
/* RTCM104 doesn't specify this, so give it the largest reasonable value */
#define MAXHEALTH (RTCM_WORDS_MAX-2)
+#ifndef S_SPLINT_S
/*
* A nominally 30-bit word (24 bits of data, 6 bits of parity)
* used both in the GPS downlink protocol described in IS-GPS-200
* and in the format for DGPS corrections used in RTCM-104.
*/
typedef /*@unsignedintegraltype@*/ uint32_t isgps30bits_t;
+#endif /* S_SPLINT_S */
struct rtcm_t {
/* header contents */
diff --git a/itraxctl.c b/itraxctl.c
index cfe560e2..87e4e5e1 100644
--- a/itraxctl.c
+++ b/itraxctl.c
@@ -61,8 +61,10 @@ void usage(void);
void
itrax_reset(int fd){
- int i, n;
+ int i;
+ size_t n;
char buf[BUFSIZ];
+ /*@+charint@*/
char resetstr[18] = { 0x3c, 0x21, /* HEADER */
0x7f, /* src: NODE_HOST | TASK_HOST */
0x20, /* dst: NODE_ITRAX | TASK_SYSTEM */
@@ -74,6 +76,7 @@ itrax_reset(int fd){
0x00, 0x00, 0x00, 0x00, /* DUMMY */
0x17, 0x00, /* CHECKSUM */
0x3e /* TRAILER */ };
+ /*@-charint@*/
struct resetmsg rm = {
.h1 = '<',
.h2 = '!',
@@ -90,19 +93,19 @@ itrax_reset(int fd){
};
memcpy(&resetstr, &rm, 18);
- italk_add_checksum((char *)&rm, sizeof(rm));
- write(fd, &rm, sizeof(rm));
+ (void)italk_add_checksum((char *)&rm, sizeof(rm));
+ (void)write(fd, &rm, sizeof(rm));
for (i = 0; i < 5; i++){
- n = write(fd, resetstr, sizeof(resetstr));
- tcdrain(fd);
- usleep(1000);
+ (void)write(fd, resetstr, sizeof(resetstr));
+ (void)tcdrain(fd);
+ (void)usleep(1000);
}
/* XXX This is Evil. it will go away when I get reset working */
- read(fd, buf, BUFSIZ);
+ (void)read(fd, buf, BUFSIZ);
for(n = 0; n < BUFSIZ; n++){
if (0 == n%16)
- printf("\n%04x ", n);
- printf("%02x ", buf[n]&0xff);
+ printf("\n%04x ", (unsigned int)n);
+ printf("%02x ", (unsigned int)(buf[n]&0xff));
}
printf("\n");
}
@@ -111,7 +114,8 @@ void
italk_add_checksum(char *buf, size_t len){
volatile unsigned long tmp = 0;
volatile unsigned short sum = 0 , w = 0, *sp;
- int k, n;
+ /* +ignoresigns */
+ unsigned char k, n;
/*
* XXX this checksum routine is silly. fix it.
* ntohs and htons are my friends
@@ -128,6 +132,7 @@ italk_add_checksum(char *buf, size_t len){
sum ^= ((tmp >> 16) ^ tmp);
}
buf[len-3] = sum;
+ /* -ignoresigns */
}
void
diff --git a/libgps.c b/libgps.c
index b810df60..e94d39b2 100644
--- a/libgps.c
+++ b/libgps.c
@@ -469,7 +469,7 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
gpsdata->profiling = (sp[2] == '1');
break;
case '$':
- if (gpsdata->profiling != 1)
+ if (gpsdata->profiling != true)
break;
/*@ +matchanyintegral -formatcode @*/
(void)sscanf(sp, "$=%8s %zd %lf %lf %lf %lf %lf %lf",
diff --git a/libgpsd_core.c b/libgpsd_core.c
index f71e8ca4..17e0b870 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -715,10 +715,12 @@ char /*@ observer @*/ *gpsd_hexdump(const void *binbuf, size_t binbuflen)
const char *ibuf = (const char *)binbuf;
const char *hexchar = "0123456789abcdef";
+ /*@ -shiftimplementation @*/
for (i = 0; i < len; i++) {
hexbuf[j++] = hexchar[ ibuf[i]&0x0f ];
hexbuf[j++] = hexchar[ (ibuf[i]&0xf0)>>4 ];
}
+ /*@ +shiftimplementation @*/
hexbuf[j] ='\0';
#else /* SQUELCH defined */
hexbuf[0] = '\0';
@@ -729,7 +731,7 @@ char /*@ observer @*/ *gpsd_hexdump(const void *binbuf, size_t binbuflen)
int gpsd_hexpack(char *src, char *dst, int len){
int i, k, l;
- l = strlen(src) / 2;
+ l = (int)(strlen(src) / 2);
if ((l < 1) || (l > len))
return -1;
@@ -742,7 +744,9 @@ int gpsd_hexpack(char *src, char *dst, int len){
return l;
}
-int hex2bin(char *s){
+/*@ +charint -shiftimplementation @*/
+int hex2bin(char *s)
+{
int a, b;
a = s[0] & 0xff;
@@ -768,3 +772,4 @@ int hex2bin(char *s){
return ((a<<4) + b);
}
+/*@ -charint +shiftimplementation @*/
diff --git a/nmea_parse.c b/nmea_parse.c
index cd3be39f..b4965fce 100644
--- a/nmea_parse.c
+++ b/nmea_parse.c
@@ -450,9 +450,9 @@ static gps_mask_t processPGRME(int c UNUSED, char *field[], struct gps_device_t
* Garmin won't say, but the general belief is that these are 50% CEP.
* We follow the advice at <http://gpsinformation.net/main/errors.htm>.
*/
- if ((strcmp(field[2], "M")) ||
- (strcmp(field[4], "M")) ||
- (strcmp(field[6], "M"))){
+ if ((strcmp(field[2], "M")!=0) ||
+ (strcmp(field[4], "M")!=0) ||
+ (strcmp(field[6], "M")!=0)){
session->gpsdata.fix.eph =
session->gpsdata.fix.epv =
session->gpsdata.epe = 100;
@@ -626,7 +626,7 @@ gps_mask_t nmea_parse(char *sentence, struct gps_device_t *session)
if (strlen(nmea_phrase[i].name) == 3)
s += 2; /* skip talker ID */
if (strcmp(nmea_phrase[i].name, s) == 0) {
- if (nmea_phrase[i].decoder && (count >= nmea_phrase[i].nf)) {
+ if (nmea_phrase[i].decoder!=NULL && (count >= nmea_phrase[i].nf)) {
retval = (nmea_phrase[i].decoder)(count, field, session);
strncpy(session->gpsdata.tag, nmea_phrase[i].name, MAXTAGLEN);
session->gpsdata.sentence_length = strlen(sentence);
diff --git a/packet.c b/packet.c
index 3eec391e..53b9b279 100644
--- a/packet.c
+++ b/packet.c
@@ -688,8 +688,9 @@ ssize_t packet_parse(struct gps_device_t *session, size_t fix)
if ( packetlen < 5) {
session->packet_state = GROUND_STATE;
} else {
- unsigned int n, pkt_id, chksum, c, len;
- bool ok = false;
+ unsigned int pkt_id, ch, chksum, len;
+ size_t n;
+ bool ok = false;
#ifdef GARMIN_ENABLE
n = 0;
@@ -711,9 +712,9 @@ ssize_t packet_parse(struct gps_device_t *session, size_t fix)
}
if (len > 0) break;
/* check sum byte */
- c = session->inbuffer[n++];
- chksum += c;
- if (c == 0x10) {
+ ch = session->inbuffer[n++];
+ chksum += ch;
+ if (ch == 0x10) {
if (session->inbuffer[n++] != 0x10) break;
}
if (session->inbuffer[n++] != 0x10) break;
diff --git a/sirfmon.c b/sirfmon.c
index 7b70c330..e2c842cc 100644
--- a/sirfmon.c
+++ b/sirfmon.c
@@ -445,11 +445,11 @@ static void decode_sirf(unsigned char buf[], int len)
total 3 x 12 = 36 bytes
******************************************************************/
- touchwin(mid27win);
+ (void)touchwin(mid27win);
display(mid27win, 1, 14, " ");
display(mid27win, 1, 14, "%s", dgpsvec[(int)getub(buf, 1)]);
for (i = j = 0; i < 12; i++) {
- touchwin(mid27win);
+ (void)touchwin(mid27win);
if (/*@i1@*/getub(buf, 16+3*i) != '\0') {
(void)wprintw(mid27win, " %d=%d", getub(buf, 16+3*i), getsw(buf, 16+3*i+1));
j++;
diff --git a/zodiac.c b/zodiac.c
index f3ac97ea..611a93a7 100644
--- a/zodiac.c
+++ b/zodiac.c
@@ -413,6 +413,7 @@ struct gps_type_t zodiac_binary =
.typename = "Zodiac binary", /* full name of type */
.trigger = NULL, /* no trigger */
.channels = 12, /* consumer-grade GPS */
+ .wakeup = NULL, /* no probe on baud rate change */
.probe = NULL, /* no probe */
.initializer = NULL, /* no initialization */
.get_packet = packet_get, /* use the generic packet getter */