[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gpsd-commit-watch
Subject:    [Gpsd-commit-watch] r2573 - trunk
From:       esr () sheep ! berlios ! de (Eric S !  Raymond at BerliOS)
Date:       2005-05-27 10:51:33
Message-ID: 200505271051.j4RApXgV003176 () sheep ! berlios ! de
[Download RAW message or body]

Author: esr
Date: 2005-05-27 12:51:20 +0200 (Fri, 27 May 2005)
New Revision: 2573

Modified:
   trunk/.splintrc
   trunk/gpsd.c
   trunk/gpsd.h
   trunk/libgpsd_core.c
   trunk/netlib.c
   trunk/serial.c
   trunk/sirfmon.c
   trunk/tsip.c
Log:
879 splint warnings.


Modified: trunk/.splintrc
===================================================================
--- trunk/.splintrc	2005-05-27 09:49:21 UTC (rev 2572)
+++ trunk/.splintrc	2005-05-27 10:51:20 UTC (rev 2573)
@@ -1,7 +1,11 @@
 -I. 
 +posixlib 
 +charindex
++charintliteral
+-exitarg
 -booltype bool
+-paramuse
+
 -Dfd_set=int 
 -Dpthread_t=int 
 -Dsocklen_t=ssize_t

Modified: trunk/gpsd.c
===================================================================
--- trunk/gpsd.c	2005-05-27 09:49:21 UTC (rev 2572)
+++ trunk/gpsd.c	2005-05-27 10:51:20 UTC (rev 2573)
@@ -613,13 +613,13 @@
 		else
 		    (void)strcat(phrase, "      ?");
 		(void)strcat(phrase, " ?");	/* can't yet derive track error */ 
-		if (whoami->device->gpsdata.set & SPEEDERR_SET)
+		if ((whoami->device->gpsdata.set & SPEEDERR_SET)!=0)
 		    (void)snprintf(phrase+strlen(phrase),
 			     sizeof(phrase)-strlen(phrase),
 			     " %5.2f", whoami->device->gpsdata.fix.eps);		    
 		else
 		    (void)strcat(phrase, "      ?");
-		if (whoami->device->gpsdata.set & CLIMBERR_SET)
+		if ((whoami->device->gpsdata.set & CLIMBERR_SET)!=0)
 		    (void)snprintf(phrase+strlen(phrase),
 			     sizeof(phrase)-strlen(phrase),
 			     " %5.2f", whoami->device->gpsdata.fix.epc);		    
@@ -729,7 +729,7 @@
 		(void)strcpy(phrase, ",X=?");
 	    break;
 	case 'Y':
-	    if (assign_channel(whoami) && whoami->device->gpsdata.satellites) {
+	    if (assign_channel(whoami) && whoami->device->gpsdata.satellites > 0) {
 		int used, reported = 0;
 		(void)strcpy(phrase, ",Y=");
 		if (whoami->device->gpsdata.tag[0])
@@ -777,12 +777,12 @@
 		(void)snprintf(phrase, sizeof(phrase), ",Z=?");
 		p++;		
 	    } else if (*p == '1' || *p == '+') {
-		whoami->device->gpsdata.profiling = 1;
+		whoami->device->gpsdata.profiling = true;
 		gpsd_report(3, "%d turned on profiling mode\n", cfd);
 		(void)snprintf(phrase, sizeof(phrase), ",Z=1");
 		p++;
 	    } else if (*p == '0' || *p == '-') {
-		whoami->device->gpsdata.profiling = 0;
+		whoami->device->gpsdata.profiling = false;
 		gpsd_report(3, "%d turned off profiling mode\n", cfd);
 		(void)snprintf(phrase, sizeof(phrase), ",Z=0");
 		p++;
@@ -892,7 +892,8 @@
     static struct gps_device_t *device, **channel;
     struct sockaddr_in fsin;
     fd_set rfds, control_fds;
-    int i, option, msock, cfd, dfd, go_background = 1;
+    int i, option, msock, cfd, dfd; 
+    bool go_background = true;
     struct passwd *pw;
     struct stat stb;
     struct timeval tv;
@@ -908,7 +909,7 @@
 	    control_socket = optarg;
 	    break;
 	case 'N':
-	    go_background = 0;
+	    go_background = false;
 	    break;
 	case 'S':
 	    service = optarg;
@@ -917,7 +918,7 @@
 	    dgpsserver = optarg;
 	    break;
 	case 'n':
-	    nowait = 1;
+	    nowait = true;
 	    break;
 	case 'f':
 	case 'p':
@@ -952,17 +953,17 @@
 	    gpsd_report(0,"control socket create failed, netlib error %d\n",csock);
 	    exit(2);
 	}
-	FD_SET(csock, &all_fds);
+	/*@i@*/FD_SET(csock, &all_fds);
     }
 
     if (go_background)
-	daemonize();
+	(void)daemonize();
 
     if (pid_file) {
 	FILE *fp;
 
 	if ((fp = fopen(pid_file, "w")) != NULL) {
-	    (void)fprintf(fp, "%u\n", getpid());
+	    (void)fprintf(fp, "%u\n", (unsigned int)getpid());
 	    (void)fclose(fp);
 	} else {
 	    gpsd_report(1, "Cannot create PID file: %s.\n", pid_file);
@@ -982,7 +983,7 @@
     if (dgpsserver) {
 	dsock = gpsd_open_dgps(dgpsserver);
 	if (dsock >= 0)
-	    FD_SET(dsock, &all_fds);
+	    /*@i@*/FD_SET(dsock, &all_fds);
 	else
 	    gpsd_report(1, "Can't connect to DGPS server, netlib error %d\n",dsock);
     }
@@ -1015,7 +1016,7 @@
      */
     if ((optind<argc && stat(argv[optind], &stb)==0) || stat(PROTO_TTY, &stb)==0) {
 	gpsd_report(2, "changing to group %d\n", stb.st_gid);
-	if (setgid(stb.st_gid))
+	if (setgid(stb.st_gid) != 0)
 	    gpsd_report(0, "setgid() failed, errno %s\n", strerror(errno));
     }
     gpsd_report(2, "running with effective group ID %d\n", getegid());
@@ -1047,8 +1048,8 @@
     (void)signal(SIGQUIT, onsig);
     (void)signal(SIGPIPE, SIG_IGN);
 
-    FD_SET(msock, &all_fds);
-    FD_ZERO(&control_fds);
+    /*@i@*/FD_SET(msock, &all_fds);
+    /*@i@*/FD_ZERO(&control_fds);
 
     /* optimization hack to defer having to read subframe data */
     if (time(NULL) < START_SUBFRAME)
@@ -1064,8 +1065,8 @@
 
     for (;;) {
         (void)memcpy((char *)&rfds, (char *)&all_fds, sizeof(rfds));
-	if (device && device->dsock > -1)
-	    FD_CLR(device->dsock, &rfds);
+	if (device != NULL && device->dsock > -1)
+	    /*@i@*/FD_CLR(device->dsock, &rfds);
 
 	/* 
 	 * Poll for user commands or GPS data.  The timeout doesn't
@@ -1085,7 +1086,7 @@
 	    char dbuf[BUFSIZ];
 	    dbuf[0] = '\0';
 	    for (cfd = 0; cfd < FD_SETSIZE; cfd++)
-		if (FD_ISSET(cfd, &rfds))
+		if (/*@i@*/FD_ISSET(cfd, &rfds))
 		    (void)snprintf(dbuf + strlen(dbuf), 
 				   sizeof(dbuf)-strlen(dbuf),
 				   " %d", cfd);
@@ -1094,7 +1095,7 @@
 #endif /* UNUSED */
 
 	/* always be open to new client connections */
-	if (FD_ISSET(msock, &rfds)) {
+	if (/*@i@*/FD_ISSET(msock, &rfds)) {
 	    socklen_t alen = sizeof(fsin);
 	    int ssock = accept(msock, (struct sockaddr *) &fsin, &alen);
 
@@ -1106,15 +1107,15 @@
 		if (opts >= 0)
 		    fcntl(ssock, F_SETFL, opts | O_NONBLOCK);
 		gpsd_report(3, "client connect on %d\n", ssock);
-		FD_SET(ssock, &all_fds);
+		/*@i@*/FD_SET(ssock, &all_fds);
 		subscribers[ssock].active = 1;
 		subscribers[ssock].tied = 0;
 	    }
-	    FD_CLR(msock, &rfds);
+	    /*@i@*/FD_CLR(msock, &rfds);
 	}
 
 	/* also be open to new control-socket connections */
-	if (csock > -1 && FD_ISSET(csock, &rfds)) {
+	if (csock > -1 && /*@i@*/FD_ISSET(csock, &rfds)) {
 	    socklen_t alen = sizeof(fsin);
 	    int ssock = accept(csock, (struct sockaddr *) &fsin, &alen);
 
@@ -1126,10 +1127,10 @@
 		if (opts >= 0)
 		    (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);
+		/*@i@*/FD_SET(ssock, &all_fds);
+		/*@i@*/FD_SET(ssock, &control_fds);
 	    }
-	    FD_CLR(csock, &rfds);
+	    /*@i@*/FD_CLR(csock, &rfds);
 	}
 
 	/* read any commands that came in over control sockets */
@@ -1142,8 +1143,8 @@
 		    handle_control(cfd, buf);
 		}
 		(void)close(cfd);
-		FD_CLR(cfd, &all_fds);
-		FD_CLR(cfd, &control_fds);
+		/*@i@*/FD_CLR(cfd, &all_fds);
+		/*@i@*/FD_CLR(cfd, &control_fds);
 	    }
 
 	/* poll all active devices */
@@ -1156,7 +1157,7 @@
 	    if (nowait && device->gpsdata.gps_fd == -1) {
 		gpsd_deactivate(device);
 		if (gpsd_activate(device) >= 0) {
-		    FD_SET(device->gpsdata.gps_fd, &all_fds);
+		    /*@i@*/FD_SET(device->gpsdata.gps_fd, &all_fds);
 		    notify_watchers(device, "GPSD,X=%f\r\n", timestamp());
 		}
 	    }
@@ -1168,11 +1169,11 @@
 		changed = gpsd_poll(device);
 		if (changed == ERROR_SET) {
 		    gpsd_report(3, "packet sniffer failed to sync up\n");
-		    FD_CLR(device->gpsdata.gps_fd, &all_fds);
+		    /*@i@*/FD_CLR(device->gpsdata.gps_fd, &all_fds);
 		    gpsd_deactivate(device);
 		} if (!(changed & ONLINE_SET)) {
 		    gpsd_report(3, "GPS is offline\n");
-		    FD_CLR(device->gpsdata.gps_fd, &all_fds);
+		    /*@i@*/FD_CLR(device->gpsdata.gps_fd, &all_fds);
 		    gpsd_deactivate(device);
 		    notify_watchers(device, "GPSD,X=0\r\n");
 		}
@@ -1205,7 +1206,7 @@
 
 	/* accept and execute commands for all clients */
 	for (cfd = 0; cfd < FD_SETSIZE; cfd++) {
-	    if (subscribers[cfd].active && FD_ISSET(cfd, &rfds)) {
+	    if (subscribers[cfd].active && /*@i@*/FD_ISSET(cfd, &rfds)) {
 		char buf[BUFSIZ];
 		int buflen;
 
@@ -1227,14 +1228,14 @@
 	/* close devices with no remaining subscribers */
 	for (channel = channels; channel < channels + MAXDEVICES; channel++) {
 	    if (*channel) {
-		int need_gps = 0;
+		bool need_gps = false;
 
 		for (cfd = 0; cfd < FD_SETSIZE; cfd++)
 		    if (subscribers[cfd].active&&subscribers[cfd].device==*channel)
-			need_gps++;
+			need_gps = true;
 
 		if (!nowait && !need_gps && (*channel)->gpsdata.gps_fd > -1) {
-		    FD_CLR((*channel)->gpsdata.gps_fd, &all_fds);
+		    /*@i@*/FD_CLR((*channel)->gpsdata.gps_fd, &all_fds);
 		    gpsd_deactivate(*channel);
 		}
 	    }

Modified: trunk/gpsd.h
===================================================================
--- trunk/gpsd.h	2005-05-27 09:49:21 UTC (rev 2572)
+++ trunk/gpsd.h	2005-05-27 10:51:20 UTC (rev 2573)
@@ -169,7 +169,7 @@
 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 bool 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 *, speed_t, unsigned char, unsigned int);
 extern speed_t gpsd_get_speed(struct termios *);

Modified: trunk/libgpsd_core.c
===================================================================
--- trunk/libgpsd_core.c	2005-05-27 09:49:21 UTC (rev 2572)
+++ trunk/libgpsd_core.c	2005-05-27 10:51:20 UTC (rev 2573)
@@ -336,13 +336,13 @@
 			    "packet sniff finds type %d\n", 
 			    session->packet_type);
 		if (session->packet_type == SIRF_PACKET)
-		    gpsd_switch_driver(session, "SiRF-II binary");
+		    (void)gpsd_switch_driver(session, "SiRF-II binary");
 		else if (session->packet_type == TSIP_PACKET)
-		    gpsd_switch_driver(session, "Trimble TSIP");
+		    (void)gpsd_switch_driver(session, "Trimble TSIP");
 		else if (session->packet_type == NMEA_PACKET)
-		    gpsd_switch_driver(session, "Generic NMEA");
+		    (void)gpsd_switch_driver(session, "Generic NMEA");
 		else if (session->packet_type == ZODIAC_PACKET)
-		    gpsd_switch_driver(session, "Zodiac binary");
+		    (void)gpsd_switch_driver(session, "Zodiac binary");
 		session->gpsdata.d_xmit_time = timestamp();
 	    } else if (!gpsd_next_hunt_setting(session))
 		return ERROR_SET;

Modified: trunk/netlib.c
===================================================================
--- trunk/netlib.c	2005-05-27 09:49:21 UTC (rev 2572)
+++ trunk/netlib.c	2005-05-27 10:51:20 UTC (rev 2573)
@@ -23,7 +23,7 @@
 
     if (!host)
 	host = "localhost";
-    memset((char *) &sin, '\0', sizeof(sin));
+    memset((char *) &sin, 0, sizeof(sin));
     sin.sin_family = AF_INET;
     if ((pse = getservbyname(service, protocol)))
 	sin.sin_port = htons(ntohs((unsigned short) pse->s_port));

Modified: trunk/serial.c
===================================================================
--- trunk/serial.c	2005-05-27 09:49:21 UTC (rev 2572)
+++ trunk/serial.c	2005-05-27 10:51:20 UTC (rev 2573)
@@ -148,7 +148,7 @@
  */
 #define SNIFF_RETRIES	600
 
-int gpsd_next_hunt_setting(struct gps_device_t *session)
+bool gpsd_next_hunt_setting(struct gps_device_t *session)
 /* advance to the next hunt setting  */
 {
     /* every rate we're likely to see on a GPS */
@@ -159,14 +159,14 @@
 	if (session->baudindex++ >= (unsigned int)(sizeof(rates)/sizeof(rates[0]))) {
 	    session->baudindex = 0;
 	    if (session->gpsdata.stopbits++ >= 2)
-		return 0;			/* hunt is over, no sync */
+		return false;			/* hunt is over, no sync */
 	}
 	gpsd_set_speed(session, 
 		       rates[session->baudindex],
 		       'N', session->gpsdata.stopbits);
     }
 
-    return 1;	/* keep hunting */
+    return true;	/* keep hunting */
 }
 
 void gpsd_close(struct gps_device_t *session)

Modified: trunk/sirfmon.c
===================================================================
--- trunk/sirfmon.c	2005-05-27 09:49:21 UTC (rev 2572)
+++ trunk/sirfmon.c	2005-05-27 10:51:20 UTC (rev 2573)
@@ -61,7 +61,7 @@
 static int devicefd = -1, controlfd = -1;
 static int nfix,fix[20];
 static int gmt_offset;
-static int dispmode = 0;
+static bool dispmode = false;
 static bool serial, subframe_enabled = false;
 static unsigned int stopbits, bps;
 
@@ -434,7 +434,7 @@
 	******************************************************************/
 	display(mid27win, 1, 14, "%d (%s)", getb(1), sbasvec[(int)getb(1)]);
 	for (i = j = 0; i < MAXCHANNELS; i++) {
-	    if (getb(16+2*i) != 0) {
+	    if (getb(16+2*i) != '\0') {
 		(void)wprintw(mid27win, "%d=%d ", getb(16+2*i), getb(16+2*i+1));
 		j++;
 	    }
@@ -514,10 +514,12 @@
 #endif /* __UNUSED__ */
 
     case 0xff:		/* Development Data */
+	/*@ +ignoresigns @*/
 	while (len > 0 && buf[len-1] == '\n')
 	    len--;
 	while (len > 0 && buf[len-1] == ' ')
 	    len--;
+	/*@ -ignoresigns @*/
 	buf[len] = '\0';
 	j = 1;
 	for (i = 0; verbpat[i] != NULL; i++)
@@ -573,6 +575,7 @@
     (void)tcflush(devicefd, TCIOFLUSH);	/* toss stale data */
 
     if (speed != 0) {
+	/*@ +ignoresigns @*/
 	if (speed < 300)
 	    rate = 0;
 	else if (speed < 1200)
@@ -591,6 +594,7 @@
 	    rate =  B38400;
 	else
 	    rate =  B57600;
+	/*@ -ignoresigns @*/
 
 	/*@ ignore @*/
 	(void)cfsetispeed(&ttyset, (speed_t)rate);
@@ -603,7 +607,7 @@
 	return NO_PACKET;
     (void)tcflush(devicefd, TCIOFLUSH);
 
-    fprintf(stderr, "Hunting at speed %d, %dN%d\n",
+    fprintf(stderr, "Hunting at speed %d, %dN%u\n",
 	    get_speed(&ttyset), 9-stopbits, stopbits);
 
     /* sniff for NMEA or SiRF packet */
@@ -649,7 +653,7 @@
 
 static int hunt_open(int *pstopbits)
 {
-    int stopbits, st;
+    int trystopbits, st;
     /*
      * Tip from Chris Kuethe: the FTDI chip used in the Trip-Nav
      * 200 (and possibly other USB GPSes) gets completely hosed
@@ -660,11 +664,11 @@
     ttyset.c_iflag = ttyset.c_oflag = ttyset.c_lflag = (tcflag_t) 0;
     ttyset.c_oflag = (ONLCR);
 
-    for (stopbits = 1; stopbits <= 2; stopbits++) {
-	*pstopbits = stopbits;
+    for (trystopbits = 1; trystopbits <= 2; trystopbits++) {
+	*pstopbits = trystopbits;
 	for (ip = rates; ip < rates + sizeof(rates)/sizeof(rates[0]); ip++)
 	{
-	    if ((st = set_speed(*ip, stopbits)) == SIRF_PACKET)
+	    if ((st = set_speed(*ip, trystopbits)) == SIRF_PACKET)
 		return get_speed(&ttyset);
 	    else if (st == NMEA_PACKET) {
 		fprintf(stderr, "Switching to SiRF mode...\n");
@@ -684,7 +688,7 @@
     }
     
     /* Save original terminal parameters */
-    if (tcgetattr(devicefd, &ttyset) != 0 || !(bps = hunt_open(&stopbits))) {
+    if (tcgetattr(devicefd, &ttyset) != 0 || (bps = hunt_open(&stopbits))==0) {
 	(void)fputs("Can't sync up with device!\n", stderr);
 	exit(1);
     }
@@ -775,7 +779,7 @@
     return len;
 }
 
-static int sendpkt(unsigned char *buf, int len, char *device)
+static bool sendpkt(unsigned char *buf, int len, char *device)
 {
     int i,csum, st;
 

Modified: trunk/tsip.c
===================================================================
--- trunk/tsip.c	2005-05-27 09:49:21 UTC (rev 2572)
+++ trunk/tsip.c	2005-05-27 10:51:20 UTC (rev 2573)
@@ -204,17 +204,17 @@
 	gpsd_report(4, "Receiver health %02x %02x\n",getb(0),getb(1));
 	break;
     case 0x47:		/* Signal Levels for all Satellites */
-	s1 = (int)getb(0);			/* count */
+	s1 = getb(0);			/* count */
 	if (len != (5*s1 + 1))
 	    break;
 	gpsd_zero_satellites(&session->gpsdata);
 	session->gpsdata.satellites = s1;
 	buf2[0] = '\0';
 	for (i = 0; i < s1; i++) {
-	    session->gpsdata.PRN[i] = s2 = (int)getb(5*i + 1);
+	    session->gpsdata.PRN[i] = s2 = getb(5*i + 1);
 	    session->gpsdata.ss[i] = f1 = getf(5*i + 2);
-	    snprintf(buf2+strlen(buf2), sizeof(buf2)-strlen(buf2),
-		     " %d=%.1f",s2,f1);
+	    (void)snprintf(buf2+strlen(buf2), sizeof(buf2)-strlen(buf2),
+			   " %d=%.1f",s2,f1);
 	}
 	gpsd_report(4, "Signal Levels (%d):%s\n",s1,buf2);
 	mask |= SATELLITE_SET;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic