summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Tachometer.c2
-rw-r--r--drivers.c2
-rw-r--r--geoid.c2
-rw-r--r--gpsd.c118
-rw-r--r--gpsd.h6
-rw-r--r--gpsutils.c2
-rw-r--r--gpsutils.h8
-rw-r--r--libgps.c28
-rw-r--r--libgpsd_core.c6
-rw-r--r--report.c2
-rw-r--r--serial.c25
-rw-r--r--sirfmon.c14
12 files changed, 108 insertions, 107 deletions
diff --git a/Tachometer.c b/Tachometer.c
index c1b044d7..86634bdf 100644
--- a/Tachometer.c
+++ b/Tachometer.c
@@ -36,6 +36,7 @@ typedef struct {
XPoint point_list[5];
} StringRec;
+/*@ +charint @*/
/* Number character database - like an LED */
static DigitRec num_segment[] = {
{{1,1,1,1,1,1,0}},
@@ -93,6 +94,7 @@ static StringRec char_data[] = {
{24, 5},
{24, 2}}}};
#endif
+/*@ -charint @*/
#define offst(field) XtOffset(TachometerWidget, field)
static XtResource resources[] = {
diff --git a/drivers.c b/drivers.c
index 70b4e383..8dea8ecd 100644
--- a/drivers.c
+++ b/drivers.c
@@ -219,7 +219,7 @@ static struct gps_type_t tripmate = {
*
**************************************************************************/
-extern struct gps_type_t zodiac_binary, earthmate;
+static struct gps_type_t zodiac_binary, earthmate;
/*
* There is a good HOWTO at <http://www.hamhud.net/ka9mva/earthmate.htm>.
diff --git a/geoid.c b/geoid.c
index 9a201326..c0e1d0e8 100644
--- a/geoid.c
+++ b/geoid.c
@@ -23,6 +23,7 @@ static double bilinear(double x1, double y1, double x2, double y2, double x, dou
/* return geoid separtion (MSL - WGS84) in meters, given a lat/lot in degrees */
+/*@ +charint @*/
double wgs84_separation(double lat, double lon)
{
#define GEOID_ROW 19
@@ -47,6 +48,7 @@ double wgs84_separation(double lat, double lon)
/* 70N */ 2, 2, 1, -1, -3, -7,-14,-24,-27,-25,-19, 3, 24, 37, 47, 60, 61, 58, 51, 43, 29, 20, 12, 5, -2,-10, -14,-12,-10,-14,-12, -6, -2, 3, 6, 4, 2,
/* 80N */ 3, 1, -2, -3, -3, -3, -1, 3, 1, 5, 9, 11, 19, 27, 31, 34, 33, 34, 33, 34, 28, 23, 17, 13, 9, 4, 4, 1, -2, -2, 0, 2, 3, 2, 1, 1, 3,
/* 90N */ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13};
+/*@ -charint @*/
int ilat, ilon;
int ilat1, ilat2, ilon1, ilon2;
diff --git a/gpsd.c b/gpsd.c
index 30810efe..d136f7bb 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -268,7 +268,7 @@ static int throttled_write(int cfd, char *buf, int len)
char *cp, buf2[MAX_PACKET_LENGTH*3];
buf2[0] = '\0';
for (cp = buf; cp < buf + len; cp++)
- sprintf(buf2 + strlen(buf2), "%02x", *cp & 0xff);
+ (void)sprintf(buf2 + strlen(buf2), "%02x", *cp & 0xff);
gpsd_report(3, "=> client(%d): =%s\r\n", cfd, buf2);
}
}
@@ -418,7 +418,7 @@ static int handle_request(int cfd, char *buf, int buflen)
phrase[0] = '\0';
switch (toupper(*p++)) {
case 'A':
- if (assign_channel(whoami) &&
+ if (assign_channel(whoami)!=0 &&
have_fix(whoami->device) &&
whoami->device->gpsdata.fix.mode == MODE_3D)
(void)snprintf(phrase, sizeof(phrase), ",A=%.3f",
@@ -427,7 +427,7 @@ static int handle_request(int cfd, char *buf, int buflen)
strcpy(phrase, ",A=?");
break;
case 'B': /* change baud rate (SiRF/Zodiac only) */
- if (assign_channel(whoami) && *p == '=') {
+ if (assign_channel(whoami)!=0 && *p == '=') {
i = atoi(++p);
while (isdigit(*p)) p++;
if (whoami->device->device_type->speed_switcher)
@@ -464,7 +464,7 @@ static int handle_request(int cfd, char *buf, int buflen)
strcpy(phrase, ",B=?");
break;
case 'C':
- if (assign_channel(whoami))
+ if (assign_channel(whoami)!=0)
(void)snprintf(phrase, sizeof(phrase), ",C=%d",
whoami->device->device_type->cycle);
else
@@ -472,13 +472,13 @@ static int handle_request(int cfd, char *buf, int buflen)
break;
case 'D':
strcpy(phrase, ",D=");
- if (assign_channel(whoami) && whoami->device->gpsdata.fix.time)
+ if (assign_channel(whoami)!=0 && whoami->device->gpsdata.fix.time)
unix_to_iso8601(whoami->device->gpsdata.fix.time, phrase+3);
else
strcpy(phrase, "?");
break;
case 'E':
- if (assign_channel(whoami) && have_fix(whoami->device)) {
+ if (assign_channel(whoami)!=0 && have_fix(whoami->device)) {
if (whoami->device->gpsdata.fix.eph
|| whoami->device->gpsdata.fix.epv)
(void)snprintf(phrase, sizeof(phrase), ",E=%.2f %.2f %.2f",
@@ -510,7 +510,7 @@ static int handle_request(int cfd, char *buf, int buflen)
strcpy(phrase, ",F=?");
break;
case 'I':
- if (assign_channel(whoami))
+ if (assign_channel(whoami)!=0)
(void)snprintf(phrase, sizeof(phrase), ",I=%s",
whoami->device->device_type->typename);
else
@@ -533,13 +533,13 @@ static int handle_request(int cfd, char *buf, int buflen)
(void)snprintf(phrase, sizeof(phrase), ",L=2 " VERSION " abcdefiklmnpqrstuvwxy"); //ghj
break;
case 'M':
- if (!assign_channel(whoami) && (!whoami->device || whoami->device->gpsdata.fix.mode == MODE_NOT_SEEN))
+ if (!assign_channel(whoami)!=0 && (!whoami->device || whoami->device->gpsdata.fix.mode == MODE_NOT_SEEN))
strcpy(phrase, ",M=?");
else
(void)snprintf(phrase, sizeof(phrase), ",M=%d", whoami->device->gpsdata.fix.mode);
break;
case 'N':
- if (!assign_channel(whoami))
+ if (!assign_channel(whoami)!=0)
strcpy(phrase, ",N=?");
else if (!whoami->device->device_type->mode_switcher)
strcpy(phrase, ",N=0");
@@ -559,7 +559,7 @@ static int handle_request(int cfd, char *buf, int buflen)
(void)snprintf(phrase, sizeof(phrase), ",N=%d", whoami->device->gpsdata.driver_mode);
break;
case 'O':
- if (!assign_channel(whoami) || !have_fix(whoami->device))
+ if (!assign_channel(whoami)!=0 || !have_fix(whoami->device))
strcpy(phrase, ",O=?");
else {
(void)snprintf(phrase, sizeof(phrase), ",O=%s %.2f %.3f %.6f %.6f",
@@ -567,50 +567,50 @@ static int handle_request(int cfd, char *buf, int buflen)
whoami->device->gpsdata.fix.time, whoami->device->gpsdata.fix.ept,
whoami->device->gpsdata.fix.latitude, whoami->device->gpsdata.fix.longitude);
if (whoami->device->gpsdata.fix.mode == MODE_3D)
- sprintf(phrase+strlen(phrase), " %7.2f",
+ (void)sprintf(phrase+strlen(phrase), " %7.2f",
whoami->device->gpsdata.fix.altitude);
else
strcat(phrase, " ?");
if (whoami->device->gpsdata.fix.eph)
- sprintf(phrase+strlen(phrase), " %5.2f", whoami->device->gpsdata.fix.eph);
+ (void)sprintf(phrase+strlen(phrase), " %5.2f", whoami->device->gpsdata.fix.eph);
else
strcat(phrase, " ?");
if (whoami->device->gpsdata.fix.epv)
- sprintf(phrase+strlen(phrase), " %5.2f", whoami->device->gpsdata.fix.epv);
+ (void)sprintf(phrase+strlen(phrase), " %5.2f", whoami->device->gpsdata.fix.epv);
else
strcat(phrase, " ?");
if (whoami->device->gpsdata.fix.track != TRACK_NOT_VALID)
- sprintf(phrase+strlen(phrase), " %8.4f %8.3f",
+ (void)sprintf(phrase+strlen(phrase), " %8.4f %8.3f",
whoami->device->gpsdata.fix.track, whoami->device->gpsdata.fix.speed);
else
strcat(phrase, " ? ?");
if (whoami->device->gpsdata.fix.mode == MODE_3D)
- sprintf(phrase+strlen(phrase), " %6.3f", whoami->device->gpsdata.fix.climb);
+ (void)sprintf(phrase+strlen(phrase), " %6.3f", whoami->device->gpsdata.fix.climb);
else
- strcat(phrase, " ?");
- strcat(phrase, " ?"); /* can't yet derive track error */
+ (void)strcat(phrase, " ?");
+ (void)strcat(phrase, " ?"); /* can't yet derive track error */
if (whoami->device->gpsdata.set & SPEEDERR_SET)
sprintf(phrase+strlen(phrase), " %5.2f",
whoami->device->gpsdata.fix.eps);
else
- strcat(phrase, " ?");
+ (void)strcat(phrase, " ?");
if (whoami->device->gpsdata.set & CLIMBERR_SET)
sprintf(phrase+strlen(phrase), " %5.2f",
whoami->device->gpsdata.fix.epc);
else
- strcat(phrase, " ?");
+ (void)strcat(phrase, " ?");
}
break;
case 'P':
- if (assign_channel(whoami) && have_fix(whoami->device))
+ if (assign_channel(whoami)!=0 && have_fix(whoami->device))
(void)snprintf(phrase, sizeof(phrase), ",P=%.6f %.6f",
whoami->device->gpsdata.fix.latitude,
whoami->device->gpsdata.fix.longitude);
else
- strcpy(phrase, ",P=?");
+ (void)strcpy(phrase, ",P=?");
break;
case 'Q':
- if (assign_channel(whoami) && (whoami->device->gpsdata.pdop || whoami->device->gpsdata.hdop || whoami->device->gpsdata.vdop))
+ if (assign_channel(whoami)!=0 && (whoami->device->gpsdata.pdop || whoami->device->gpsdata.hdop || whoami->device->gpsdata.vdop))
(void)snprintf(phrase, sizeof(phrase), ",Q=%d %.2f %.2f %.2f %.2f %.2f",
whoami->device->gpsdata.satellites_used,
whoami->device->gpsdata.pdop,
@@ -619,7 +619,7 @@ static int handle_request(int cfd, char *buf, int buflen)
whoami->device->gpsdata.tdop,
whoami->device->gpsdata.gdop);
else
- strcpy(phrase, ",Q=?");
+ (void)strcpy(phrase, ",Q=?");
break;
case 'R':
if (*p == '=') ++p;
@@ -645,41 +645,41 @@ static int handle_request(int cfd, char *buf, int buflen)
gpsd_report(3, "%d turned off raw mode\n", cfd);
(void)snprintf(phrase, sizeof(phrase), ",R=0");
} else {
- assign_channel(whoami);
+ assign_channel(whoami)!=0;
subscribers[cfd].raw = 1;
gpsd_report(3, "%d turned on raw mode\n", cfd);
(void)snprintf(phrase, sizeof(phrase), ",R=1");
}
break;
case 'S':
- if (assign_channel(whoami))
+ if (assign_channel(whoami)!=0)
(void)snprintf(phrase, sizeof(phrase), ",S=%d", whoami->device->gpsdata.status);
else
- strcpy(phrase, ",S=?");
+ (void)strcpy(phrase, ",S=?");
break;
case 'T':
- if (assign_channel(whoami) && have_fix(whoami->device) && whoami->device->gpsdata.fix.track != TRACK_NOT_VALID)
+ if (assign_channel(whoami)!=0 && have_fix(whoami->device) && whoami->device->gpsdata.fix.track != TRACK_NOT_VALID)
(void)snprintf(phrase, sizeof(phrase), ",T=%.4f", whoami->device->gpsdata.fix.track);
else
- strcpy(phrase, ",T=?");
+ (void)strcpy(phrase, ",T=?");
break;
case 'U':
- if (assign_channel(whoami) && have_fix(whoami->device) && whoami->device->gpsdata.fix.mode == MODE_3D)
+ if (assign_channel(whoami)!=0 && have_fix(whoami->device) && whoami->device->gpsdata.fix.mode == MODE_3D)
(void)snprintf(phrase, sizeof(phrase), ",U=%.3f", whoami->device->gpsdata.fix.climb);
else
- strcpy(phrase, ",U=?");
+ (void)strcpy(phrase, ",U=?");
break;
case 'V':
- if (assign_channel(whoami) && have_fix(whoami->device) && whoami->device->gpsdata.fix.track != TRACK_NOT_VALID)
+ if (assign_channel(whoami)!=0 && have_fix(whoami->device) && whoami->device->gpsdata.fix.track != TRACK_NOT_VALID)
(void)snprintf(phrase, sizeof(phrase), ",V=%.3f", whoami->device->gpsdata.fix.speed / KNOTS_TO_KPH);
else
- strcpy(phrase, ",V=?");
+ (void)strcpy(phrase, ",V=?");
break;
case 'W':
if (*p == '=') ++p;
if (*p == '1' || *p == '+') {
subscribers[cfd].watcher = 1;
- assign_channel(whoami);
+ assign_channel(whoami)!=0;
(void)snprintf(phrase, sizeof(phrase), ",W=1");
p++;
} else if (*p == '0' || *p == '-') {
@@ -691,31 +691,31 @@ static int handle_request(int cfd, char *buf, int buflen)
(void)snprintf(phrase, sizeof(phrase), ",W=0");
} else {
subscribers[cfd].watcher = 1;
- assign_channel(whoami);
+ assign_channel(whoami)!=0;
gpsd_report(3, "%d turned on watching\n", cfd);
(void)snprintf(phrase, sizeof(phrase), ",W=1");
}
break;
case 'X':
- if (assign_channel(whoami) && whoami->device)
+ if (assign_channel(whoami)!=0 && whoami->device)
(void)snprintf(phrase, sizeof(phrase), ",X=%f", whoami->device->gpsdata.online);
else
- strcpy(phrase, ",X=?");
+ (void)strcpy(phrase, ",X=?");
break;
case 'Y':
- if (assign_channel(whoami) && whoami->device->gpsdata.satellites) {
+ if (assign_channel(whoami)!=0 && whoami->device->gpsdata.satellites) {
int used, reported = 0;
- strcpy(phrase, ",Y=");
+ (void)strcpy(phrase, ",Y=");
if (whoami->device->gpsdata.tag[0])
- strcat(phrase, whoami->device->gpsdata.tag);
+ (void)strcat(phrase, whoami->device->gpsdata.tag);
else
- strcat(phrase, "-");
+ (void)strcat(phrase, "-");
if (whoami->device->gpsdata.set & TIME_SET)
- sprintf(phrase+strlen(phrase), " %f ",
+ (void)sprintf(phrase+strlen(phrase), " %f ",
whoami->device->gpsdata.sentence_time);
else
- strcat(phrase, " ? ");
- sprintf(phrase+strlen(phrase), "%d:",
+ (void)strcat(phrase, " ? ");
+ (void)sprintf(phrase+strlen(phrase), "%d:",
whoami->device->gpsdata.satellites);
for (i = 0; i < whoami->device->gpsdata.satellites; i++) {
used = 0;
@@ -725,7 +725,7 @@ static int handle_request(int cfd, char *buf, int buflen)
break;
}
if (whoami->device->gpsdata.PRN[i]) {
- sprintf(phrase+strlen(phrase), "%d %d %d %d %d:",
+ (void)sprintf(phrase+strlen(phrase), "%d %d %d %d %d:",
whoami->device->gpsdata.PRN[i],
whoami->device->gpsdata.elevation[i],whoami->device->gpsdata.azimuth[i],
whoami->device->gpsdata.ss[i],
@@ -737,7 +737,7 @@ static int handle_request(int cfd, char *buf, int buflen)
gpsd_report(1,"Satellite count %d != PRN count %d\n",
whoami->device->gpsdata.satellites, reported);
} else
- strcpy(phrase, ",Y=?");
+ (void)strcpy(phrase, ",Y=?");
break;
case 'Z':
assign_channel(whoami);
@@ -786,7 +786,7 @@ static int handle_request(int cfd, char *buf, int buflen)
goto breakout;
}
if (strlen(reply) + strlen(phrase) < sizeof(reply) - 1)
- strcat(reply, phrase);
+ (void)strcat(reply, phrase);
else
return -1; /* Buffer would overflow. Just return an error */
}
@@ -816,7 +816,7 @@ static void handle_control(int sfd, char *buf)
(void)write(sfd, "OK\n", 3);
} else
(void)write(sfd, "ERROR\n", 6);
- free(stash);
+ (void)free(stash);
} else if (buf[0] == '+') {
p = snarfline(buf+1, &stash);
if (find_device(stash))
@@ -828,7 +828,7 @@ static void handle_control(int sfd, char *buf)
else
(void)write(sfd, "ERROR\n", 6);
}
- free(stash);
+ (void)free(stash);
} else if (buf[0] == '!') {
p = snarfline(buf+1, &stash);
eq = strchr(stash, '=');
@@ -846,7 +846,7 @@ static void handle_control(int sfd, char *buf)
(void)write(sfd, "ERROR\n", 3);
}
}
- free(stash);
+ (void)free(stash);
}
}
@@ -914,7 +914,7 @@ int main(int argc, char *argv[])
* the socket before it's created.
*/
if (control_socket) {
- unlink(control_socket);
+ (void)unlink(control_socket);
if ((csock = filesock(control_socket)) < 0) {
gpsd_report(0,"control socket create failed, netlib error %d\n",csock);
exit(2);
@@ -929,7 +929,7 @@ int main(int argc, char *argv[])
FILE *fp;
if ((fp = fopen(pid_file, "w")) != NULL) {
- fprintf(fp, "%u\n", getpid());
+ (void)fprintf(fp, "%u\n", getpid());
(void)fclose(fp);
} else {
gpsd_report(1, "Cannot create PID file: %s.\n", pid_file);
@@ -955,14 +955,14 @@ int main(int argc, char *argv[])
}
#ifdef NTPSHM_ENABLE
- nice(-10); /* for precise timekeeping, increase priority */
- ntpshm_init(&context,nowait);
+ (void)nice(-10); /* for precise timekeeping increase priority */
+ (void)ntpshm_init(&context,nowait);
#endif /* NTPSHM_ENABLE */
/* make default devices accessible even after we drop privileges */
for (i = optind; i < argc; i++)
if (stat(argv[i], &stb) == 0)
- chmod(argv[i], stb.st_mode|S_IRGRP|S_IWGRP);
+ (void)chmod(argv[i], stb.st_mode|S_IRGRP|S_IWGRP);
#if DBUS_ENABLE
/* we need to connect to dbus as root */
@@ -988,21 +988,21 @@ int main(int argc, char *argv[])
gpsd_report(2, "running with effective group ID %d\n", getegid());
pw = getpwnam("nobody");
if (pw)
- setuid(pw->pw_uid);
+ (void)setuid(pw->pw_uid);
gpsd_report(2, "running with effective user ID %d\n", geteuid());
/* user may want to re-initialize all channels */
if ((st = setjmp(restartbuf)) > 0) {
for (dfd = 0; dfd < FD_SETSIZE; dfd++) {
if (channels[dfd])
- gpsd_wrap(channels[dfd]);
+ (void)gpsd_wrap(channels[dfd]);
}
if (st == SIGHUP+1)
gpsd_report(1, "gpsd restarted by SIGHUP\n");
else if (st > 0) {
gpsd_report(1,"Received terminating signal %d. Exiting...\n",st-1);
if (control_socket)
- unlink(control_socket);
+ (void)unlink(control_socket);
exit(10 + st);
}
}
@@ -1032,7 +1032,7 @@ int main(int argc, char *argv[])
for (;;) {
struct timeval tv;
- memcpy((char *)&rfds, (char *)&all_fds, sizeof(rfds));
+ (void)memcpy((char *)&rfds, (char *)&all_fds, sizeof(rfds));
if (device && device->dsock > -1)
FD_CLR(device->dsock, &rfds);
@@ -1091,7 +1091,7 @@ int main(int argc, char *argv[])
int opts = fcntl(ssock, F_GETFL);
if (opts >= 0)
- fcntl(ssock, F_SETFL, opts | O_NONBLOCK);
+ (void)fcntl(ssock, F_SETFL, opts | O_NONBLOCK);
gpsd_report(3, "control socket connect on %d\n", ssock);
FD_SET(ssock, &all_fds);
FD_SET(ssock, &control_fds);
diff --git a/gpsd.h b/gpsd.h
index 6aad60aa..8807ffde 100644
--- a/gpsd.h
+++ b/gpsd.h
@@ -170,11 +170,11 @@ extern int packet_sniff(struct gps_device_t *);
extern int gpsd_open(struct gps_device_t *);
extern int gpsd_next_hunt_setting(struct gps_device_t *);
extern int gpsd_switch_driver(struct gps_device_t *, char *);
-extern void gpsd_set_speed(struct gps_device_t *, unsigned int, unsigned int, unsigned int);
-extern int gpsd_get_speed(struct termios *);
+extern void gpsd_set_speed(struct gps_device_t *, speed_t, unsigned int, unsigned int);
+extern speed_t gpsd_get_speed(struct termios *);
extern void gpsd_close(struct gps_device_t *);
-extern void gpsd_raw_hook(struct gps_device_t *, char *, int len, int level);
+extern void gpsd_raw_hook(struct gps_device_t *, char *, size_t len, int level);
extern void gpsd_zero_satellites(struct gps_data_t *);
extern void gpsd_binary_fix_dump(struct gps_device_t *, char *);
extern void gpsd_binary_satellite_dump(struct gps_device_t *, char *);
diff --git a/gpsutils.c b/gpsutils.c
index e922356a..24fa5686 100644
--- a/gpsutils.c
+++ b/gpsutils.c
@@ -110,6 +110,7 @@ double gpstime_to_unix(int week, double tow)
#define Deg2Rad(n) ((n) * DEG_2_RAD)
+#ifdef __UNUSED__
static double CalcRad(double lat)
/* earth's radius of curvature in meters at specified latitude.*/
{
@@ -156,6 +157,7 @@ double earth_distance(double lat1, double lon1, double lat2, double lon2)
a = -1;
return CalcRad((lat1+lat2) / 2) * acos(a);
}
+#endif /* __UNUSED__ */
/*****************************************************************************
diff --git a/gpsutils.h b/gpsutils.h
index 58da4061..3cea7882 100644
--- a/gpsutils.h
+++ b/gpsutils.h
@@ -5,12 +5,6 @@ extern double timestamp(void);
extern double iso8601_to_unix(char *);
extern char *unix_to_iso8601(double t, char *);
extern double gpstime_to_unix(int, double);
-extern double earth_distance(double, double, double, double);
-
-/* return geoid separtion (MSL - WGS84) in meters, given a lat/lot in degrees */
+/* extern double earth_distance(double, double, double, double); */
extern double wgs84_separation(double lat, double lon);
-
-/* guess at preferred units from environment and compiled in defaults
- * return: 0 = miles/feet, 1 = knots/feet, 2 = km/meters
- */
extern int gpsd_units(void);
diff --git a/libgps.c b/libgps.c
index 893f7bb3..57ae6e32 100644
--- a/libgps.c
+++ b/libgps.c
@@ -155,7 +155,7 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
if (sp[2] == '?') {
gpsdata->fix.altitude = ALTITUDE_NOT_VALID;
} else {
- sscanf(sp, "A=%lf", &gpsdata->fix.altitude);
+ (void)sscanf(sp, "A=%lf", &gpsdata->fix.altitude);
gpsdata->set |= ALTITUDE_SET;
}
break;
@@ -163,14 +163,14 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
if (sp[2] == '?') {
gpsdata->baudrate = gpsdata->stopbits = 0;
} else
- sscanf(sp, "B=%d %*d %*s %d",
+ (void)sscanf(sp, "B=%d %*d %*s %d",
&gpsdata->baudrate, &gpsdata->stopbits);
break;
case 'C':
if (sp[2] == '?')
gpsdata->cycle = 0;
else
- sscanf(sp, "C=%d", &gpsdata->cycle);
+ (void)sscanf(sp, "C=%d", &gpsdata->cycle);
break;
case 'D':
if (sp[2] == '?')
@@ -186,7 +186,7 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
gpsdata->fix.eph = UNCERTAINTY_NOT_VALID;
gpsdata->fix.epv = UNCERTAINTY_NOT_VALID;
} else {
- sscanf(sp, "E=%lf %lf %lf",
+ (void)sscanf(sp, "E=%lf %lf %lf",
&gpsdata->epe,&gpsdata->fix.eph,&gpsdata->fix.epv);
gpsdata->set |= HERR_SET| VERR_SET | PERR_SET;
}
@@ -297,7 +297,7 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
gpsdata->fix.latitude = LATITUDE_NOT_VALID;
gpsdata->fix.longitude = LONGITUDE_NOT_VALID;
} else {
- sscanf(sp, "P=%lf %lf",
+ (void)sscanf(sp, "P=%lf %lf",
&gpsdata->fix.latitude, &gpsdata->fix.longitude);
gpsdata->set |= LATLON_SET;
}
@@ -309,7 +309,7 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
gpsdata->hdop = 0;
gpsdata->vdop = 0;
} else {
- sscanf(sp, "Q=%d %lf %lf %lf %lf %lf",
+ (void)sscanf(sp, "Q=%d %lf %lf %lf %lf %lf",
&gpsdata->satellites_used,
&gpsdata->pdop,
&gpsdata->hdop,
@@ -331,7 +331,7 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
if (sp[2] == '?') {
gpsdata->fix.track = TRACK_NOT_VALID;
} else {
- sscanf(sp, "T=%lf", &gpsdata->fix.track);
+ (void)sscanf(sp, "T=%lf", &gpsdata->fix.track);
gpsdata->set |= TRACK_SET;
}
break;
@@ -339,7 +339,7 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
if (sp[2] == '?') {
gpsdata->fix.climb = SPEED_NOT_VALID;
} else {
- sscanf(sp, "U=%lf", &gpsdata->fix.climb);
+ (void)sscanf(sp, "U=%lf", &gpsdata->fix.climb);
gpsdata->set |= CLIMB_SET;
}
break;
@@ -347,7 +347,7 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
if (sp[2] == '?') {
gpsdata->fix.speed = SPEED_NOT_VALID;
} else {
- sscanf(sp, "V=%lf", &gpsdata->fix.speed);
+ (void)sscanf(sp, "V=%lf", &gpsdata->fix.speed);
gpsdata->set |= SPEED_SET;
}
break;
@@ -355,7 +355,7 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
if (sp[2] == '?')
gpsdata->online = -1;
else {
- sscanf(sp, "X=%lf", &gpsdata->online);
+ (void)sscanf(sp, "X=%lf", &gpsdata->online);
gpsdata->set |= ONLINE_SET;
}
break;
@@ -369,7 +369,7 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
int ss[MAXCHANNELS], used[MAXCHANNELS];
char tag[21], timestamp[21];
- sscanf(sp, "Y=%20s %20s %d ",
+ (void)sscanf(sp, "Y=%20s %20s %d ",
tag, timestamp, &gpsdata->satellites);
strncpy(gpsdata->tag, tag, MAXTAGLEN);
if (timestamp[0] != '?') {
@@ -381,7 +381,7 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
}
for (j = 0; j < gpsdata->satellites; j++) {
sp = strchr(sp, ':') + 1;
- sscanf(sp, "%d %d %d %d %d", &i1, &i2, &i3, &i4, &i5);
+ (void)sscanf(sp, "%d %d %d %d %d", &i1, &i2, &i3, &i4, &i5);
PRN[j] = i1;
elevation[j] = i2; azimuth[j] = i3;
ss[j] = i4; used[j] = i5;
@@ -407,10 +407,10 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
gpsdata->set |= SATELLITE_SET;
break;
case 'Z':
- sscanf(sp, "Z=%d", &gpsdata->profiling);
+ (void)sscanf(sp, "Z=%d", &gpsdata->profiling);
break;
case '$':
- sscanf(sp, "$=%s %d %lf %lf %lf %lf %lf %lf",
+ (void)sscanf(sp, "$=%s %d %lf %lf %lf %lf %lf %lf",
gpsdata->tag,
&gpsdata->sentence_length,
&gpsdata->fix.time,
diff --git a/libgpsd_core.c b/libgpsd_core.c
index b2f3d281..85083672 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -37,7 +37,7 @@ int gpsd_open_dgps(char *dgpsserver)
dsock = netlib_connectsock(dgpsserver, dgpsport, "tcp");
if (dsock >= 0) {
gethostname(hn, sizeof(hn));
- sprintf(buf, "HELO %s gpsd %s\r\nR\r\n", hn, VERSION);
+ snprintf(buf, sizeof(buf), "HELO %s gpsd %s\r\nR\r\n", hn, VERSION);
write(dsock, buf, strlen(buf));
}
return dsock;
@@ -276,7 +276,7 @@ static int handle_packet(struct gps_device_t *session)
session->sentdgps++;
if (session->dsock > -1) {
char buf[BUFSIZ];
- sprintf(buf, "R %0.8f %0.8f %0.2f\r\n",
+ 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);
@@ -377,7 +377,7 @@ void gpsd_zero_satellites(struct gps_data_t *out)
out->satellites = 0;
}
-void gpsd_raw_hook(struct gps_device_t *session, char *sentence, int len, int level)
+void gpsd_raw_hook(struct gps_device_t *session, char *sentence, size_t len, int level)
{
if (session->gpsdata.raw_hook) {
session->gpsdata.raw_hook(&session->gpsdata, sentence, len, level);
diff --git a/report.c b/report.c
index 5f7dedf5..530db481 100644
--- a/report.c
+++ b/report.c
@@ -8,7 +8,7 @@ void gpsd_report(int errlevel UNUSED, const char *fmt, ... )
va_list ap;
va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
+ (void)vfprintf(stderr, fmt, ap);
va_end(ap);
}
diff --git a/serial.c b/serial.c
index d3066bf1..f75fa782 100644
--- a/serial.c
+++ b/serial.c
@@ -17,9 +17,9 @@
# endif /* CNEW_RTSCTS */
#endif /* !CRTSCTS */
-int gpsd_get_speed(struct termios* ttyctl)
+speed_t gpsd_get_speed(struct termios* ttyctl)
{
- int code = cfgetospeed(ttyctl);
+ speed_t code = cfgetospeed(ttyctl);
switch (code) {
case B0: return(0);
case B300: return(300);
@@ -35,9 +35,9 @@ int gpsd_get_speed(struct termios* ttyctl)
}
void gpsd_set_speed(struct gps_device_t *session,
- unsigned int speed, unsigned int parity, unsigned int stopbits)
+ speed_t speed, unsigned int parity, unsigned int stopbits)
{
- unsigned int rate;
+ speed_t rate;
if (speed < 300)
rate = B0;
@@ -62,8 +62,8 @@ void gpsd_set_speed(struct gps_device_t *session,
if (rate!=cfgetispeed(&session->ttyset) || parity!=session->gpsdata.parity || stopbits!=session->gpsdata.stopbits) {
- cfsetispeed(&session->ttyset, (speed_t)rate);
- cfsetospeed(&session->ttyset, (speed_t)rate);
+ (void)cfsetispeed(&session->ttyset, (speed_t)rate);
+ (void)cfsetospeed(&session->ttyset, (speed_t)rate);
session->ttyset.c_iflag &=~ (PARMRK | INPCK);
session->ttyset.c_cflag &=~ (CSIZE | CSTOPB | PARENB | PARODD);
session->ttyset.c_cflag |= (stopbits==2 ? CS7|CSTOPB : CS8);
@@ -81,7 +81,7 @@ void gpsd_set_speed(struct gps_device_t *session,
session->ttyset.c_cflag |= (CSIZE & (stopbits==2 ? CS7 : CS8));
if (tcsetattr(session->gpsdata.gps_fd, TCSANOW, &session->ttyset) != 0)
return;
- tcflush(session->gpsdata.gps_fd, TCIOFLUSH);
+ (void)tcflush(session->gpsdata.gps_fd, TCIOFLUSH);
}
gpsd_report(1, "speed %d, %d%c%d\n", speed, 9-stopbits, parity, stopbits);
@@ -100,12 +100,12 @@ int gpsd_open(struct gps_device_t *session)
}
session->packet_type = BAD_PACKET;
- if (isatty(session->gpsdata.gps_fd)) {
+ if (isatty(session->gpsdata.gps_fd)!=0) {
#ifdef NON_NMEA_ENABLE
struct gps_type_t **dp;
for (dp = gpsd_drivers; *dp; dp++) {
- tcflush(session->gpsdata.gps_fd, TCIOFLUSH); /* toss stale data */
+ (void)tcflush(session->gpsdata.gps_fd, TCIOFLUSH); /* toss stale data */
if ((*dp)->probe && (*dp)->probe(session)) {
gpsd_report(3, "probe found %s driver...\n", (*dp)->typename);
session->device_type = *dp;
@@ -120,7 +120,8 @@ int gpsd_open(struct gps_device_t *session)
/* Save original terminal parameters */
if (tcgetattr(session->gpsdata.gps_fd,&session->ttyset_old) != 0)
return -1;
- memcpy(&session->ttyset,&session->ttyset_old,sizeof(session->ttyset));
+ (void)memcpy(&session->ttyset,
+ &session->ttyset_old, sizeof(session->ttyset));
/*
* Tip from Chris Kuethe: the FIDI chip used in the Trip-Nav
* 200 (and possibly other USB GPSes) gets completely hosed
@@ -169,7 +170,7 @@ int gpsd_next_hunt_setting(struct gps_device_t *session)
void gpsd_close(struct gps_device_t *session)
{
if (session->gpsdata.gps_fd != -1) {
- if (isatty(session->gpsdata.gps_fd)) {
+ if (isatty(session->gpsdata.gps_fd)!=0) {
/* force hangup on close on systems that don't do HUPCL properly */
cfsetispeed(&session->ttyset, (speed_t)B0);
cfsetospeed(&session->ttyset, (speed_t)B0);
@@ -177,7 +178,7 @@ void gpsd_close(struct gps_device_t *session)
}
/* this is the clean way to do it */
session->ttyset_old.c_cflag |= HUPCL;
- tcsetattr(session->gpsdata.gps_fd,TCSANOW,&session->ttyset_old);
+ (void)tcsetattr(session->gpsdata.gps_fd,TCSANOW,&session->ttyset_old);
(void)close(session->gpsdata.gps_fd);
}
}
diff --git a/sirfmon.c b/sirfmon.c
index 34ca91da..74aa0893 100644
--- a/sirfmon.c
+++ b/sirfmon.c
@@ -796,13 +796,13 @@ static int sendpkt(unsigned char *buf, int len, char *device)
return -1;
else {
if (!serial) {
- write(controlfd, "!", 1);
- write(controlfd, device, strlen(device));
- write(controlfd, "=", 1);
+ (void)write(controlfd, "!", 1);
+ (void)write(controlfd, device, strlen(device));
+ (void)write(controlfd, "=", 1);
}
st = write(controlfd, buf,len);
if (!serial)
- read(controlfd, buf, 8); /* enough room for "ERROR\r\n\0" */
+ (void)read(controlfd, buf, 8); /* enough room for "ERROR\r\n\0" */
return (st == len);
}
}
@@ -859,7 +859,7 @@ static void command(char *buf, int len, const char *fmt, ... )
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
- write(devicefd, buf, strlen(buf));
+ (void)write(devicefd, buf, strlen(buf));
n = read(devicefd, buf, len);
if (n >= 0) {
buf[n] = '\0';
@@ -1162,8 +1162,8 @@ int main (int argc, char **argv)
display(cmdwin, 1, 0, "%s %d N %d", device,bps,stopbits);
} else {
line[0] = 'b';
- write(devicefd, line, strlen(line));
- read(devicefd, buf, sizeof(buf)); /* discard response */
+ (void)write(devicefd, line, strlen(line));
+ (void)read(devicefd, buf, sizeof(buf)); /* discard response */
}
break;