summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2005-08-17 18:46:11 +0000
committerEric S. Raymond <esr@thyrsus.com>2005-08-17 18:46:11 +0000
commit62606bbe2abe04d3acc30fd809124b711c9dfe48 (patch)
tree438e0e7db900297356e41fc0f9da9388245e82f0
parent606c667f37b2202517905fab0e585171d4bc76a7 (diff)
downloadgpsd-62606bbe2abe04d3acc30fd809124b711c9dfe48.tar.gz
splint cleanup after integrating cgps.
-rw-r--r--Makefile.am2
-rw-r--r--cgps.c192
-rw-r--r--libgps.c12
3 files changed, 106 insertions, 100 deletions
diff --git a/Makefile.am b/Makefile.am
index 03be47a0..587801c0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -252,6 +252,8 @@ splint:
-splint -redef $(gpsd_SOURCES) $(libgps_c_sources)
@echo "Running splint on xgps..."
-splint -exportlocal $(xgps_SOURCES)
+ @echo "Running splint on cgps..."
+ -splint -exportlocal $(cgps_SOURCES)
@echo "Running splint on xgpsspeed..."
-splint -exportlocal $(xgpsspeed_c_sources)
@echo "Running splint on sirfmon..."
diff --git a/cgps.c b/cgps.c
index 069f82eb..93f7154b 100644
--- a/cgps.c
+++ b/cgps.c
@@ -51,20 +51,20 @@ static char *altunits = "ft";
static char *speedunits = "mph";
/* Function to call when we're all done. Does a bit of clean-up. */
-static void die(void)
+static void die(sig UNUSED)
{
/* Ignore signals. */
- signal(SIGINT,SIG_IGN);
+ (void)signal(SIGINT,SIG_IGN);
/* Move the cursor to the bottom left corner. */
- mvcur(0,COLS-1,LINES-1,0);
+ (void)mvcur(0,COLS-1,LINES-1,0);
/* Put input attributes back the way they were. */
- echo();
- noraw();
+ (void)echo();
+ (void)noraw();
/* Done with curses. */
- endwin();
+ (void)endwin();
/* We're done talking to gpsd. */
(void)gps_close(gpsdata);
@@ -79,155 +79,155 @@ static void update_panel(struct gps_data_t *gpsdata,
size_t len UNUSED,
int level UNUSED)
{
- unsigned int i;
+ int i;
int newstate;
char s[128];
/* Do the initial field label setup. */
- move(0,5);
- printw("Time:");
- move(1,5);
- printw("Latitude:");
- move(2,5);
- printw("Longitude:");
- move(3,5);
- printw("Altitude:");
- move(4,5);
- printw("Speed:");
- move(5,5);
- printw("Heading:");
- move(6,5);
- printw("HPE:");
- move(7,5);
- printw("VPE:");
- move(8,5);
- printw("Climb:");
- move(9,5);
- printw("Status:");
- move(10,5);
- printw("Change:");
- move(0,45);
- printw("PRN: Elev: Azim: SNR: Used:");
+ (void)move(0,5);
+ (void)printw("Time:");
+ (void)move(1,5);
+ (void)printw("Latitude:");
+ (void)move(2,5);
+ (void)printw("Longitude:");
+ (void)move(3,5);
+ (void)printw("Altitude:");
+ (void)move(4,5);
+ (void)printw("Speed:");
+ (void)move(5,5);
+ (void)printw("Heading:");
+ (void)move(6,5);
+ (void)printw("HPE:");
+ (void)move(7,5);
+ (void)printw("VPE:");
+ (void)move(8,5);
+ (void)printw("Climb:");
+ (void)move(9,5);
+ (void)printw("Status:");
+ (void)move(10,5);
+ (void)printw("Change:");
+ (void)move(0,45);
+ (void)printw("PRN: Elev: Azim: SNR: Used:");
/* This is for the satellite status display. Lifted almost verbatim
from xgps.c. */
if (gpsdata->satellites) {
for (i = 0; i < MAXCHANNELS; i++) {
- if (i < (unsigned int)gpsdata->satellites) {
- move(i+1,45);
- printw(" %3d %02d %03d %02d %c ",
+ if (i < gpsdata->satellites) {
+ (void)move(i+1,45);
+ (void)printw(" %3d %02d %03d %02d %c ",
gpsdata->PRN[i],
gpsdata->elevation[i], gpsdata->azimuth[i],
gpsdata->ss[i], gpsdata->used[i] ? 'Y' : 'N');
} else {
- move(i+1,45);
- printw(" ");
+ (void)move(i+1,45);
+ (void)printw(" ");
}
}
}
/* TODO: Make this work. */
if (isnan(gpsdata->fix.time)==0) {
- move(0,17);
- printw("%s",unix_to_iso8601(gpsdata->fix.time, s, (int)sizeof(s)));
+ (void)move(0,17);
+ (void)printw("%s",unix_to_iso8601(gpsdata->fix.time, s, (int)sizeof(s)));
} else {
- move(0,17);
- printw("n/a ");
+ (void)move(0,17);
+ (void)printw("n/a ");
}
/* Fill in the latitude. */
if (gpsdata->fix.mode >= MODE_2D) {
- move(1,17);
- printw("%lf %c ", fabs(gpsdata->fix.latitude), (gpsdata->fix.latitude < 0) ? 'S' : 'N');
+ (void)move(1,17);
+ (void)printw("%lf %c ", fabs(gpsdata->fix.latitude), (gpsdata->fix.latitude < 0) ? 'S' : 'N');
} else {
- move(1,17);
- printw("n/a ");
+ (void)move(1,17);
+ (void)printw("n/a ");
}
/* Fill in the longitude. */
if (gpsdata->fix.mode >= MODE_2D) {
- move(2,17);
- printw("%lf %c ", fabs(gpsdata->fix.longitude), (gpsdata->fix.longitude < 0) ? 'W' : 'E');
+ (void)move(2,17);
+ (void)printw("%lf %c ", fabs(gpsdata->fix.longitude), (gpsdata->fix.longitude < 0) ? 'W' : 'E');
} else {
- move(2,17);
- printw("n/a ");
+ (void)move(2,17);
+ (void)printw("n/a ");
}
/* Fill in the altitude. */
if (gpsdata->fix.mode == MODE_3D) {
- move(3,17);
- printw("%.1f %s ",gpsdata->fix.altitude*altfactor, altunits);
+ (void)move(3,17);
+ (void)printw("%.1f %s ",gpsdata->fix.altitude*altfactor, altunits);
} else {
- move(3,17);
- printw("n/a ");
+ (void)move(3,17);
+ (void)printw("n/a ");
}
/* Fill in the speed */
if (gpsdata->fix.mode >= MODE_2D && isnan(gpsdata->fix.track)==0) {
- move(4,17);
- printw("%.1f %s ", gpsdata->fix.speed*speedfactor, speedunits);
+ (void)move(4,17);
+ (void)printw("%.1f %s ", gpsdata->fix.speed*speedfactor, speedunits);
} else {
- move(4,17);
- printw("n/a ");
+ (void)move(4,17);
+ (void)printw("n/a ");
}
/* Fill in the heading. */
if (gpsdata->fix.mode >= MODE_2D && isnan(gpsdata->fix.track)==0) {
- move(5,17);
- printw("%.1f degrees \n", gpsdata->fix.track);
+ (void)move(5,17);
+ (void)printw("%.1f degrees \n", gpsdata->fix.track);
} else {
- move(5,17);
- printw("n/a ");
+ (void)move(5,17);
+ (void)printw("n/a ");
}
/* Fill in the estimated horizontal position error. */
if (isnan(gpsdata->fix.eph)==0) {
- move(6,17);
- printw("%d ft ", (int) (gpsdata->fix.eph * altfactor));
+ (void)move(6,17);
+ (void)printw("%d ft ", (int) (gpsdata->fix.eph * altfactor));
} else {
- move(6,17);
- printw("n/a ");
+ (void)move(6,17);
+ (void)printw("n/a ");
}
/* Fill in the estimated vertical position error. */
if (isnan(gpsdata->fix.epv)==0) {
- move(7,17);
- printw("%d ft ", (int)(gpsdata->fix.epv * altfactor));
+ (void)move(7,17);
+ (void)printw("%d ft ", (int)(gpsdata->fix.epv * altfactor));
} else {
- move(7,17);
- printw("n/a ");
+ (void)move(7,17);
+ (void)printw("n/a ");
}
/* Fill in the rate of climb. */
/* TODO: Factor are probably wrong. */
if (gpsdata->fix.mode == MODE_3D && isnan(gpsdata->fix.climb)==0) {
- move(8,17);
- printw("%.1f ft/min ", gpsdata->fix.climb * METERS_TO_FEET * 60);
+ (void)move(8,17);
+ (void)printw("%.1f ft/min ", gpsdata->fix.climb * METERS_TO_FEET * 60);
} else {
- move(8,17);
- printw("n/a ");
+ (void)move(8,17);
+ (void)printw("n/a ");
}
/* Fill in the GPS status */
if (gpsdata->online == 0) {
newstate = 0;
- move(9,17);
- printw("OFFLINE ");
+ (void)move(9,17);
+ (void)printw("OFFLINE ");
} else {
newstate = gpsdata->fix.mode;
switch (gpsdata->fix.mode) {
case MODE_2D:
- move(9,17);
- printw("2D %sFIX ",(gpsdata->status==STATUS_DGPS_FIX)?"DIFF ":"");
+ (void)move(9,17);
+ (void)printw("2D %sFIX ",(gpsdata->status==STATUS_DGPS_FIX)?"DIFF ":"");
break;
case MODE_3D:
- move(9,17);
- printw("3D %sFIX ",(gpsdata->status==STATUS_DGPS_FIX)?"DIFF ":"");
+ (void)move(9,17);
+ (void)printw("3D %sFIX ",(gpsdata->status==STATUS_DGPS_FIX)?"DIFF ":"");
break;
default:
- move(9,17);
- printw("NO FIX ");
+ (void)move(9,17);
+ (void)printw("NO FIX ");
break;
}
}
@@ -237,11 +237,11 @@ static void update_panel(struct gps_data_t *gpsdata,
timer = time(NULL);
state = newstate;
}
- move(10,17);
- printw("(%d secs) ", (int) (time(NULL) - timer));
+ (void)move(10,17);
+ (void)printw("(%d secs) ", (int) (time(NULL) - timer));
/* Update the screen. */
- refresh();
+ (void)refresh();
}
int main(int argc, char *argv[])
@@ -263,9 +263,10 @@ int main(int argc, char *argv[])
}
/* Grok the server, port, and device. */
+ /*@ -branchstate @*/
if (optind < argc) {
arg = strdup(argv[optind]);
- colon1 = strchr(arg, ':');
+ /*@i@*/colon1 = strchr(arg, ':');
server = arg;
if (colon1 != NULL) {
if (colon1 == arg)
@@ -284,7 +285,9 @@ int main(int argc, char *argv[])
}
colon1 = colon2 = NULL;
}
+ /*@ +branchstate @*/
+ /*@ -observertrans @*/
switch (gpsd_units())
{
case imperial:
@@ -309,9 +312,10 @@ int main(int argc, char *argv[])
/* leave the default alone */
break;
}
+ /*@ +observertrans @*/
/* Open the stream to gpsd. */
- gpsdata = gps_open(server, port);
+ /*@i@*/gpsdata = gps_open(server, port);
if (!gpsdata) {
switch ( errno ) {
case NL_NOSERVICE: err_str = "can't get service entry"; break;
@@ -333,10 +337,10 @@ int main(int argc, char *argv[])
timer = time(NULL);
/* Set up the curses screen (if using curses). */
- initscr();
- raw();
- noecho();
- /* signal(SIGINT,die); */
+ (void)initscr();
+ (void)raw();
+ (void)noecho();
+ (void)signal(SIGINT,die);
/* Here's where updates go. */
gps_set_raw_hook(gpsdata, update_panel);
@@ -346,7 +350,7 @@ int main(int argc, char *argv[])
char *channelcmd = (char *)malloc(strlen(device)+3);
if (channelcmd) {
- (void)strcpy(channelcmd, "F=");
+ /*@i@*/(void)strcpy(channelcmd, "F=");
(void)strcpy(channelcmd+2, device);
(void)gps_query(gpsdata, channelcmd);
(void)free(channelcmd);
@@ -359,11 +363,11 @@ int main(int argc, char *argv[])
/* Loop and poll once per second (this could be less than optimal
for a receiver that updates > 1hz, or for a user using a *really*
slow ancient serial terminal). */
- while(1) {
- gps_poll(gpsdata);
- sleep(1);
+ for(;;) {
+ (void)gps_poll(gpsdata);
+ (void)sleep(1);
}
- die();
+ //die();
}
diff --git a/libgps.c b/libgps.c
index 691e344c..a2a12cfe 100644
--- a/libgps.c
+++ b/libgps.c
@@ -46,7 +46,7 @@ enum unit gpsd_units(void)
{
char *envu = NULL;
- if ((envu = getenv("GPSD_UNITS")) && *envu) {
+ if ((envu = getenv("GPSD_UNITS")) != NULL && *envu != NULL) {
if (strcasecmp(envu, "imperial")) {
return imperial;
}
@@ -58,11 +58,11 @@ enum unit gpsd_units(void)
}
/* unrecognized, ignore it */
}
- if (((envu = getenv("LC_MEASUREMENT")) && *envu)
- || ((envu = getenv("LANG")) && *envu)) {
- if ( strstr(envu, "_US")
- || strcasecmp(envu, "C")
- || strcasecmp(envu, "POSIX")) {
+ if (((envu = getenv("LC_MEASUREMENT")) != NULL && *envu !=NULL)
+ || ((envu = getenv("LANG")) != NULL && *envu != NULL)) {
+ if (strstr(envu, "_US")!=0
+ || strcasecmp(envu, "C")!=0
+ || strcasecmp(envu, "POSIX")!=0) {
return imperial;
}
/* Other, must be metric */