[prev in list] [next in list] [prev in thread] [next in thread]
List: gpsd-commit-watch
Subject: [Gpsd-commit-watch] r2555 - trunk
From: esr () sheep ! berlios ! de (Eric S ! Raymond at BerliOS)
Date: 2005-05-26 20:25:07
Message-ID: 200505262025.j4QKP7Od030356 () sheep ! berlios ! de
[Download RAW message or body]
Author: esr
Date: 2005-05-26 22:25:06 +0200 (Thu, 26 May 2005)
New Revision: 2555
Modified:
trunk/.splintrc
trunk/drivers.c
trunk/gps.h
trunk/libgpsd_core.c
trunk/packet.c
trunk/sirf.c
Log:
Down to 1562 splint warnings.
Modified: trunk/.splintrc
===================================================================
--- trunk/.splintrc 2005-05-26 19:19:29 UTC (rev 2554)
+++ trunk/.splintrc 2005-05-26 20:25:06 UTC (rev 2555)
@@ -7,3 +7,4 @@
-Du_int16_t=short
-Du_int8_t=short
-Dcaddr_t=short
+-DFD_SETSIZE=31
Modified: trunk/drivers.c
===================================================================
--- trunk/drivers.c 2005-05-26 19:19:29 UTC (rev 2554)
+++ trunk/drivers.c 2005-05-26 20:25:06 UTC (rev 2555)
@@ -219,7 +219,7 @@
*
**************************************************************************/
-static struct gps_type_t zodiac_binary, earthmate;
+extern struct gps_type_t zodiac_binary, earthmate;
/*
* There is a good HOWTO at <http://www.hamhud.net/ka9mva/earthmate.htm>.
Modified: trunk/gps.h
===================================================================
--- trunk/gps.h 2005-05-26 19:19:29 UTC (rev 2554)
+++ trunk/gps.h 2005-05-26 20:25:06 UTC (rev 2555)
@@ -45,32 +45,32 @@
*/
struct gps_fix_t {
double time; /* Time of update, seconds since Unix epoch */
-#define TIME_NOT_VALID 0
+#define TIME_NOT_VALID 0.0
int mode; /* Mode of fix */
#define MODE_NOT_SEEN 0 /* mode update not seen yet */
#define MODE_NO_FIX 1 /* none */
#define MODE_2D 2 /* good for latitude/longitude */
#define MODE_3D 3 /* good for altitude/climb too */
double ept; /* Expected time uncertainty */
-#define UNCERTAINTY_NOT_VALID -1
+#define UNCERTAINTY_NOT_VALID -1.0
double latitude; /* Latitude in degrees (valid if mode >= 2) */
-#define LATITUDE_NOT_VALID -721
+#define LATITUDE_NOT_VALID -721.0
double longitude; /* Longitude in degrees (valid if mode >= 2) */
-#define LONGITUDE_NOT_VALID -721
+#define LONGITUDE_NOT_VALID -721.0
double eph; /* Horizontal position uncertainty, meters */
double altitude; /* Altitude in meters (valid if mode == 3) */
-#define ALTITUDE_NOT_VALID -999
+#define ALTITUDE_NOT_VALID -999.0
double epv; /* Vertical position uncertainty, meters */
double track; /* Course made good (relative to true north) */
-#define TRACK_NOT_VALID -1 /* No course data yet */
+#define TRACK_NOT_VALID -1.0 /* No course data yet */
double epd; /* Track uncertainty, degrees */
double speed; /* Speed over ground, meters/sec */
-#define SPEED_NOT_VALID -1 /* No speed data yet */
+#define SPEED_NOT_VALID -1.0 /* No speed data yet */
double eps; /* Speed uncertainty, meters/sec */
double climb; /* Vertical speed, meters/sec */
double epc; /* Vertical speed uncertainty */
double separation; /* Geoidal separation, MSL - WGS84 (Meters) */
-#define NO_SEPARATION -99999 /* must be out of band */
+#define NO_SEPARATION -99999.0 /* must be out of band */
};
struct gps_data_t {
Modified: trunk/libgpsd_core.c
===================================================================
--- trunk/libgpsd_core.c 2005-05-26 19:19:29 UTC (rev 2554)
+++ trunk/libgpsd_core.c 2005-05-26 20:25:06 UTC (rev 2555)
@@ -38,7 +38,7 @@
if (dsock >= 0) {
gethostname(hn, sizeof(hn));
snprintf(buf, sizeof(buf), "HELO %s gpsd %s\r\nR\r\n", hn, VERSION);
- write(dsock, buf, strlen(buf));
+ (void)write(dsock, buf, strlen(buf));
}
return dsock;
}
@@ -91,10 +91,10 @@
(void)gpsd_close(session);
session->gpsdata.gps_fd = -1;
#ifdef NTPSHM_ENABLE
- ntpshm_free(session->context, session->shmTime);
+ (void)ntpshm_free(session->context, session->shmTime);
session->shmTime = -1;
# ifdef PPS_ENABLE
- ntpshm_free(session->context, session->shmTimeP);
+ (void)ntpshm_free(session->context, session->shmTimeP);
session->shmTimeP = -1;
# endif /* PPS_ENABLE */
#endif /* NTPSHM_ENABLE */
@@ -112,7 +112,7 @@
/* wait for status change on the device's carrier-detect line */
while (ioctl(session->gpsdata.gps_fd, TIOCMIWAIT, TIOCM_CAR) == 0) {
- gettimeofday(&tv,NULL);
+ (void)gettimeofday(&tv,NULL);
if (ioctl(session->gpsdata.gps_fd, TIOCMGET, &state) != 0)
break;
@@ -176,7 +176,7 @@
#if defined(PPS_ENABLE) && defined(TIOCMIWAIT)
if (session->shmTime >= 0 && session->context->shmTimePPS) {
if ((session->shmTimeP = ntpshm_alloc(session->context)) >= 0)
- pthread_create(&pt,NULL,gpsd_ppsmonitor, (void *)session);
+ (void)pthread_create(&pt,NULL,gpsd_ppsmonitor,(void *)session);
}
#endif /* defined(PPS_ENABLE) && defined(TIOCMIWAIT) */
#endif /* NTPSHM_ENABLE */
@@ -263,9 +263,9 @@
}
/* save the old fix for later uncertainty computations */
- memcpy(&session->lastfix,
- &session->gpsdata.fix,
- sizeof(struct gps_fix_t));
+ (void)memcpy(&session->lastfix,
+ &session->gpsdata.fix,
+ sizeof(struct gps_fix_t));
}
#endif /* BINARY_ENABLE */
@@ -276,11 +276,11 @@
session->sentdgps++;
if (session->dsock > -1) {
char buf[BUFSIZ];
- snprintf(buf, sizeof(buf), "R %0.8f %0.8f %0.2f\r\n",
- session->gpsdata.fix.latitude,
- session->gpsdata.fix.longitude,
- session->gpsdata.fix.altitude);
- write(session->dsock, buf, strlen(buf));
+ (void)snprintf(buf, sizeof(buf), "R %0.8f %0.8f %0.2f\r\n",
+ session->gpsdata.fix.latitude,
+ session->gpsdata.fix.longitude,
+ session->gpsdata.fix.altitude);
+ (void)write(session->dsock, buf, strlen(buf));
gpsd_report(2, "=> dgps %s", buf);
}
}
@@ -364,16 +364,16 @@
{
gpsd_deactivate(session);
if (session->gpsdata.gps_device)
- free(session->gpsdata.gps_device);
- free(session);
+ (void)free(session->gpsdata.gps_device);
+ (void)free(session);
}
void gpsd_zero_satellites(struct gps_data_t *out)
{
- memset(out->PRN, '\0', sizeof(out->PRN));
- memset(out->elevation, '\0', sizeof(out->elevation));
- memset(out->azimuth, '\0', sizeof(out->azimuth));
- memset(out->ss, '\0', sizeof(out->ss));
+ (void)memset(out->PRN, 0, sizeof(out->PRN));
+ (void)memset(out->elevation, 0, sizeof(out->elevation));
+ (void)memset(out->azimuth, 0, sizeof(out->azimuth));
+ (void)memset(out->ss, 0, sizeof(out->ss));
out->satellites = 0;
}
@@ -416,7 +416,7 @@
intfixtime = (int)session->gpsdata.fix.time;
gmtime_r(&intfixtime, &tm);
if (session->gpsdata.fix.mode > 1) {
- sprintf(bufp,
+ (void)sprintf(bufp,
"$GPGGA,%02d%02d%02d,%09.4f,%c,%010.4f,%c,%d,%02d,%s,%.1f,%c,",
tm.tm_hour,
tm.tm_min,
@@ -430,21 +430,21 @@
hdop_str,
session->gpsdata.fix.altitude, 'M');
if (session->gpsdata.fix.separation == NO_SEPARATION)
- strcat(bufp, ",,");
+ (void)strcat(bufp, ",,");
else
- sprintf(bufp+strlen(bufp), "%.3f,M",
+ (void)sprintf(bufp+strlen(bufp), "%.3f,M",
session->gpsdata.fix.separation);
if (session->mag_var == NO_MAG_VAR)
- strcat(bufp, ",,");
+ (void)strcat(bufp, ",,");
else {
- sprintf(bufp+strlen(bufp), "%3.2f,", fabs(session->mag_var));
- strcat(bufp, (session->mag_var > 0) ? "E": "W");
+ (void)sprintf(bufp+strlen(bufp), "%3.2f,", fabs(session->mag_var));
+ (void)strcat(bufp, (session->mag_var > 0) ? "E": "W");
}
nmea_add_checksum(bufp);
gpsd_raw_hook(session, bufp, strlen(bufp), 1);
bufp += strlen(bufp);
}
- sprintf(bufp,
+ (void)sprintf(bufp,
"$GPRMC,%02d%02d%02d,%c,%09.4f,%c,%010.4f,%c,%.4f,%.3f,%02d%02d%02d,,",
tm.tm_hour,
tm.tm_min,
@@ -480,7 +480,7 @@
}
bufp += strlen(bufp);
if (i < session->gpsdata.satellites)
- sprintf(bufp, ",%02d,%02d,%03d,%02d",
+ (void)sprintf(bufp, ",%02d,%02d,%03d,%02d",
session->gpsdata.PRN[i],
session->gpsdata.elevation[i],
session->gpsdata.azimuth[i],
@@ -497,7 +497,7 @@
int i, j;
char *bufp2 = bufp;
- sprintf(bufp, "$GPGSA,%c,%d,", 'A', session->gpsdata.fix.mode);
+ (void)sprintf(bufp, "$GPGSA,%c,%d,", 'A', session->gpsdata.fix.mode);
j = 0;
for (i = 0; i < MAXCHANNELS; i++) {
if (session->gpsdata.used[i]) {
@@ -511,7 +511,7 @@
sprintf(bufp, ",");
}
bufp += strlen(bufp);
- sprintf(bufp, "%.1f,%.1f,%.1f*",
+ (void)sprintf(bufp, "%.1f,%.1f,%.1f*",
session->gpsdata.pdop,
session->gpsdata.hdop,
session->gpsdata.vdop);
@@ -525,7 +525,7 @@
) {
// output PGRME
// only if realistic
- sprintf(bufp, "$PGRME,%.2f,%.2f,%.2f",
+ (void)sprintf(bufp, "$PGRME,%.2f,%.2f,%.2f",
session->gpsdata.fix.eph,
session->gpsdata.fix.epv,
session->gpsdata.epe);
Modified: trunk/packet.c
===================================================================
--- trunk/packet.c 2005-05-26 19:19:29 UTC (rev 2554)
+++ trunk/packet.c 2005-05-26 20:25:06 UTC (rev 2555)
@@ -129,6 +129,7 @@
static void nexstate(struct gps_device_t *session, unsigned char c)
{
+/*@ +charint */
switch(session->packet_state)
{
case GROUND_STATE:
@@ -420,6 +421,7 @@
break;
#endif /* ZODIAC_ENABLE */
}
+/*@ -charint */
}
#ifdef STATE_DEBUG
@@ -558,7 +560,7 @@
unsigned int checksum = (trailer[0] << 8) | trailer[1];
unsigned int n, crc = 0;
for (n = 4; n < (size_t)(trailer - session->inbuffer); n++)
- crc += session->inbuffer[n];
+ crc += (int)session->inbuffer[n];
crc &= 0x7fff;
if (checksum == crc)
packet_accept(session, SIRF_PACKET);
Modified: trunk/sirf.c
===================================================================
--- trunk/sirf.c 2005-05-26 19:19:29 UTC (rev 2554)
+++ trunk/sirf.c 2005-05-26 20:25:06 UTC (rev 2555)
@@ -36,35 +36,38 @@
#define HI(n) ((n) >> 8)
#define LO(n) ((n) & 0xff)
-static u_int16_t sirf_write(int fd, u_int8_t *msg) {
- int i, len, ok, crc;
+static size_t sirf_write(int fd, unsigned char *msg) {
+ unsigned int crc;
+ size_t i, len, ok;
char buf[MAX_PACKET_LENGTH*2];
- len = (msg[2] << 8) | msg[3];
+ len = (size_t)((msg[2] << 8) | msg[3]);
/* calculate CRC */
crc = 0;
for (i = 0; i < len; i++)
- crc += msg[4 + i];
+ crc += (int)msg[4 + i];
crc &= 0x7fff;
/* enter CRC after payload */
- msg[len + 4] = (u_int8_t)((crc & 0xff00) >> 8);
- msg[len + 5] = (u_int8_t)( crc & 0x00ff);
+ msg[len + 4] = (unsigned char)((crc & 0xff00) >> 8);
+ msg[len + 5] = (unsigned char)( crc & 0x00ff);
buf[0] = '\0';
for (i = 0; i < len+8; i++)
- sprintf(buf+strlen(buf), " %02x", msg[i]);
+ (void)snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),
+ " %02x", (unsigned)msg[i]);
gpsd_report(4, "Writing SiRF control type %02x:%s\n", msg[4], buf);
- ok = write(fd, msg, len+8) == len+8;
- tcdrain(fd);
+ ok = (write(fd, msg, len+8) == (ssize_t)(len+8));
+ (void)tcdrain(fd);
return(ok);
}
-static int sirf_speed(int ttyfd, int speed)
+static size_t sirf_speed(int ttyfd, speed_t speed)
/* change speed in binary mode */
{
- u_int8_t msg[] = {0xa0, 0xa2, 0x00, 0x09,
+ /*@ +charint @*/
+ unsigned char msg[] = {0xa0, 0xa2, 0x00, 0x09,
0x86,
0x0, 0x0, 0x12, 0xc0, /* 4800 bps */
0x08, /* 8 data bits */
@@ -72,16 +75,18 @@
0x00, /* no parity */
0x00, /* reserved */
0x00, 0x00, 0xb0, 0xb3};
+ /*@ -charint @*/
- msg[7] = HI(speed);
- msg[8] = LO(speed);
+ msg[7] = (unsigned char)HI(speed);
+ msg[8] = (unsigned char)LO(speed);
return (sirf_write(ttyfd, msg));
}
-static int sirf_to_nmea(int ttyfd, int speed)
+static size_t sirf_to_nmea(int ttyfd, speed_t speed)
/* switch from binary to NMEA at specified baud */
{
- u_int8_t msg[] = {0xa0, 0xa2, 0x00, 0x18,
+ /*@ +charint @*/
+ unsigned char msg[] = {0xa0, 0xa2, 0x00, 0x18,
0x81, 0x02,
0x01, 0x01, /* GGA */
0x00, 0x00, /* suppress GLL */
@@ -93,21 +98,22 @@
0x00, 0x01, 0x00, 0x01,
0x12, 0xc0, /* 4800 bps */
0x00, 0x00, 0xb0, 0xb3};
+ /*@ -charint @*/
- msg[26] = HI(speed);
- msg[27] = LO(speed);
+ msg[26] = (unsigned char)HI(speed);
+ msg[27] = (unsigned char)LO(speed);
return (sirf_write(ttyfd, msg));
}
-#define getb(off) ((u_int8_t)buf[off])
+#define getb(off) ((unsigned char)buf[off])
#define getw(off) ((short)((getb(off) << 8) | getb(off+1)))
#define getl(off) ((int)((getw(off) << 16) | (getw(off+2) & 0xffff)))
static void sirfbin_mode(struct gps_device_t *session, int mode)
{
if (mode == 0) {
- gpsd_switch_driver(session, "SiRF-II NMEA");
- sirf_to_nmea(session->gpsdata.gps_fd,session->gpsdata.baudrate);
+ (void)gpsd_switch_driver(session, "SiRF-II NMEA");
+ (void)sirf_to_nmea(session->gpsdata.gps_fd,session->gpsdata.baudrate);
session->gpsdata.driver_mode = 0;
}
}
@@ -117,7 +123,8 @@
int st, i, j, cn, navtype, mask;
char buf2[MAX_PACKET_LENGTH*3+2];
double fv;
- u_int8_t enablesubframe[] = {0xa0, 0xa2, 0x00, 0x19,
+ /*@ +charint @*/
+ unsigned char enablesubframe[] = {0xa0, 0xa2, 0x00, 0x19,
0x80, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
@@ -126,7 +133,7 @@
0x00, 0x00, 0x00, 0x0C,
0x10,
0x00, 0x00, 0xb0, 0xb3};
- u_int8_t disablesubframe[] = {0xa0, 0xa2, 0x00, 0x19,
+ unsigned char disablesubframe[] = {0xa0, 0xa2, 0x00, 0x19,
0x80, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
@@ -136,21 +143,21 @@
0x00,
0x00, 0x00, 0xb0, 0xb3};
+ /*@ -charint @*/
if (len < 0)
return 0;
buf2[0] = '\0';
for (i = 0; i < len; i++)
- sprintf(buf2+strlen(buf2), "%02x", buf[i]);
+ (void)snprintf(buf2+strlen(buf2),
+ sizeof(buf2)-strlen(buf2),
+ "%02x", (int)buf[i]);
strcat(buf2, "\n");
- gpsd_report(5, "Raw SiRF packet type 0x%02x length %d: %s\n", buf[0],len,buf2);
buf += 4;
len -= 8;
+ gpsd_report(5, "Raw SiRF packet type 0x%02x length %d: %s\n", buf[0],len,buf2);
+ snprintf(session->gpsdata.tag,sizeof(session->gpsdata.tag),"MID%d",buf[0]);
-
- if (buf[0] != 0xff)
- snprintf(session->gpsdata.tag,sizeof(session->gpsdata.tag),"MID%d",buf[0]);
-
switch (buf[0])
{
case 0x02: /* Measure Navigation Data Out */
@@ -272,10 +279,12 @@
} else if (fv < 232)
session->driverstate |= SIRF_EQ_231;
else {
- u_int8_t enablemid52[] = {
+ /*@ +charint @*/
+ unsigned char enablemid52[] = {
0xa0, 0xa2, 0x00, 0x08,
0xa6, 0x00, 0x34, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0xdb, 0xb0, 0xb3};
+ /*@ -charint @*/
gpsd_report(4, "Enabling PPS message...\n");
(void)sirf_write(session->gpsdata.gps_fd, enablemid52);
session->driverstate |= SIRF_GE_232;
@@ -691,18 +700,19 @@
}
/* do this every time*/
{
- u_int8_t dgpscontrol[] = {0xa0, 0xa2, 0x00, 0x07,
+ /*@ +charint @*/
+ unsigned char dgpscontrol[] = {0xa0, 0xa2, 0x00, 0x07,
0x85, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0xb0, 0xb3};
- u_int8_t sbasparams[] = {0xa0, 0xa2, 0x00, 0x06,
+ unsigned char sbasparams[] = {0xa0, 0xa2, 0x00, 0x06,
0xaa, 0x00, 0x01, 0x00,
0x00, 0x00,
0x00, 0x00, 0xb0, 0xb3};
- u_int8_t versionprobe[] = {0xa0, 0xa2, 0x00, 0x02,
+ unsigned char versionprobe[] = {0xa0, 0xa2, 0x00, 0x02,
0x84, 0x00,
0x00, 0x00, 0xb0, 0xb3};
- u_int8_t modecontrol[] = {0xa0, 0xa2, 0x00, 0x0e,
+ unsigned char modecontrol[] = {0xa0, 0xa2, 0x00, 0x0e,
0x88,
0x00, 0x00, /* pad bytes */
0x00, /* degraded mode off */
@@ -715,6 +725,7 @@
0x00, /* disable dead reckoning */
0x01, /* enable track smoothing */
0x00, 0x00, 0xb0, 0xb3};
+ /*@ -charint @*/
gpsd_report(4, "Setting DGPS control to use SBAS...\n");
(void)sirf_write(session->gpsdata.gps_fd, dgpscontrol);
gpsd_report(4, "Setting SBAS to auto/integrity mode...\n");
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic