diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2006-08-20 16:57:55 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2006-08-20 16:57:55 +0000 |
commit | 26970286199d9c1d19a214bcf8405e63798f9496 (patch) | |
tree | 40a5b193c6f3b66f186a6b72302e873e9ccd88c2 | |
parent | f2e82b634c39a4a3e2c45590f1dcf2de4be79a7c (diff) | |
download | gpsd-26970286199d9c1d19a214bcf8405e63798f9496.tar.gz |
splint cleanup after CK's strcat()/strlcopy() cleanup.
-rw-r--r-- | bsd-base64.c | 2 | ||||
-rw-r--r-- | cgps.c | 2 | ||||
-rw-r--r-- | configure.ac | 8 | ||||
-rw-r--r-- | gps.h | 2 | ||||
-rw-r--r-- | gpsd.h | 8 | ||||
-rw-r--r-- | gpsd_dbus.c | 2 | ||||
-rw-r--r-- | gpsflash.c | 4 | ||||
-rw-r--r-- | gpsutils.c | 34 | ||||
-rw-r--r-- | libgps.c | 12 | ||||
-rw-r--r-- | nmea_parse.c | 4 | ||||
-rw-r--r-- | ntrip.c | 2 | ||||
-rw-r--r-- | rtcm.c | 2 | ||||
-rw-r--r-- | rtcmdecode.c | 2 | ||||
-rw-r--r-- | serial.c | 3 | ||||
-rw-r--r-- | sirf.c | 2 | ||||
-rw-r--r-- | sirfmon.c | 2 | ||||
-rw-r--r-- | xgps.c | 2 | ||||
-rw-r--r-- | xgpsspeed.c | 4 | ||||
-rw-r--r-- | zodiac.c | 2 |
19 files changed, 54 insertions, 45 deletions
diff --git a/bsd-base64.c b/bsd-base64.c index 37fed0c2..d110ef8e 100644 --- a/bsd-base64.c +++ b/bsd-base64.c @@ -42,6 +42,7 @@ * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. */ +#include <stdlib.h> #include "config.h" #if !defined(HAVE_B64_NTOP) && !defined(HAVE___B64_NTOP) @@ -55,7 +56,6 @@ #include <ctype.h> #include <stdio.h> -#include <stdlib.h> #include <string.h> #include "bsd-base64.h" @@ -427,10 +427,12 @@ int main(int argc, char *argv[]) l = strlen(device)+4; if ((channelcmd = (char *)malloc(l)) != NULL){ + /*@ -compdef @*/ /*@i@*/(void)strlcpy(channelcmd, "F=", l); (void)strlcpy(channelcmd+2, device, l); (void)gps_query(gpsdata, channelcmd); (void)free(channelcmd); + /*@ +compdef @*/ } } diff --git a/configure.ac b/configure.ac index 0f06361e..557faa96 100644 --- a/configure.ac +++ b/configure.ac @@ -79,6 +79,14 @@ AH_VERBATIM([_GNU_SOURCE], # define UNUSED __attribute__((unused)) /* Flag variable as unused */ #else /* not __GNUC__ */ # define UNUSED +#endif + +/* Some libc's don't have strlcat/strlcpy. Local copies are provided */ +#ifndef HAVE_STRLCAT +size_t strlcat(/*@out@*/char *dst, /*@in@*/const char *src, size_t size); +#endif +#ifndef HAVE_STRLCPY +size_t strlcpy(/*@out@*/char *dst, /*@in@*/const char *src, size_t size); #endif]) dnl Check for X libraries @@ -314,7 +314,7 @@ extern void gps_clear_fix(/*@ out @*/struct gps_fix_t *); extern void gps_merge_fix(/*@ out @*/struct gps_fix_t *, gps_mask_t, /*@ in @*/struct gps_fix_t *); -extern int gps_valid_fields(/*@ in @*/struct gps_fix_t *); +extern unsigned int gps_valid_fields(/*@ in @*/struct gps_fix_t *); extern char *gps_show_transfer(int); extern time_t mkgmtime(register struct tm *); @@ -354,12 +354,4 @@ extern float roundf(float x); void cfmakeraw(struct termios *); #endif /* defined(__CYGWIN__) */ -/* Some libc's don't have strlcat/strlcpy. Local copies are provided */ -#ifndef HAVE_STRLCAT -size_t strlcat(char *dst, const char *src, size_t size); -#endif -#ifndef HAVE_STRLCPY -size_t strlcpy(char *dst, const char *src, size_t size); -#endif - #endif /* _gpsd_h_ */ diff --git a/gpsd_dbus.c b/gpsd_dbus.c index 17c10f35..23e98493 100644 --- a/gpsd_dbus.c +++ b/gpsd_dbus.c @@ -1,7 +1,7 @@ +#include <stdio.h> #include <config.h> #ifdef DBUS_ENABLE #include <gpsd_dbus.h> -#include <stdio.h> static DBusConnection* connection = NULL; @@ -20,8 +20,8 @@ void gpsd_report(int errlevel, const char *fmt, ... ) char buf[BUFSIZ]; va_list ap; - strlcpy(buf, progname, BUFSIZ); - strlcat(buf, ": ", BUFSIZ); + (void)strlcpy(buf, progname, BUFSIZ); + (void)strlcat(buf, ": ", BUFSIZ); va_start(ap, fmt) ; (void)vsnprintf(buf + strlen(buf), sizeof(buf)-strlen(buf), fmt, ap); va_end(ap); @@ -34,16 +34,16 @@ void gps_clear_fix(/*@ out @*/struct gps_fix_t *fixp) fixp->dip = NAN; } -int gps_valid_fields(/*@ in @*/struct gps_fix_t *fixp) +unsigned int gps_valid_fields(/*@ in @*/struct gps_fix_t *fixp) { - int valid = 0; + unsigned int valid = 0; if (isnan(fixp->time) != 0) valid |= TIME_SET; if (fixp->mode != MODE_NOT_SEEN) - valid != MODE_SET; + valid |= MODE_SET; if (isnan(fixp->latitude) !=0 && isnan(fixp->longitude) !=0) - valid != LATLON_SET; + valid |= LATLON_SET; if (isnan(fixp->altitude) != 0) valid |= ALTITUDE_SET; if (isnan(fixp->track) != 0) @@ -69,35 +69,37 @@ int gps_valid_fields(/*@ in @*/struct gps_fix_t *fixp) char *gps_show_transfer(int transfer) { +/*@ -statictrans @*/ static char showbuf[100]; showbuf[0] = '\0'; if ((transfer & TIME_SET)!=0) - strlcat(showbuf, "time,", sizeof(showbuf)); + (void)strlcat(showbuf, "time,", sizeof(showbuf)); if ((transfer & LATLON_SET)!=0) - strlcat(showbuf, "latlon,", sizeof(showbuf)); + (void)strlcat(showbuf, "latlon,", sizeof(showbuf)); if ((transfer & MODE_SET)!=0) - strlcat(showbuf, "mode,", sizeof(showbuf)); + (void)strlcat(showbuf, "mode,", sizeof(showbuf)); if ((transfer & ALTITUDE_SET)!=0) - strlcat(showbuf, "altitude,", sizeof(showbuf)); + (void)strlcat(showbuf, "altitude,", sizeof(showbuf)); if ((transfer & TRACK_SET)!=0) - strlcat(showbuf, "track,", sizeof(showbuf)); + (void)strlcat(showbuf, "track,", sizeof(showbuf)); if ((transfer & SPEED_SET)!=0) - strlcat(showbuf, "speed,", sizeof(showbuf)); + (void)strlcat(showbuf, "speed,", sizeof(showbuf)); if ((transfer & CLIMB_SET)!=0) - strlcat(showbuf, "climb,", sizeof(showbuf)); + (void)strlcat(showbuf, "climb,", sizeof(showbuf)); if ((transfer & TIMERR_SET)!=0) - strlcat(showbuf, "timerr,", sizeof(showbuf)); + (void)strlcat(showbuf, "timerr,", sizeof(showbuf)); if ((transfer & HERR_SET)!=0) - strlcat(showbuf, "herr,", sizeof(showbuf)); + (void)strlcat(showbuf, "herr,", sizeof(showbuf)); if ((transfer & VERR_SET)!=0) - strlcat(showbuf, "verr,", sizeof(showbuf)); + (void)strlcat(showbuf, "verr,", sizeof(showbuf)); if ((transfer & SPEEDERR_SET)!=0) - strlcat(showbuf, "speederr,", sizeof(showbuf)); + (void)strlcat(showbuf, "speederr,", sizeof(showbuf)); if ((transfer & CLIMBERR_SET)!=0) - strlcat(showbuf, "climberr,", sizeof(showbuf)); + (void)strlcat(showbuf, "climberr,", sizeof(showbuf)); if (strlen(showbuf)>0) showbuf[strlen(showbuf)-1] = '\0'; return showbuf; +/*@ +statictrans @*/ } void gps_merge_fix(/*@ out @*/struct gps_fix_t *to, @@ -32,7 +32,7 @@ extern char *strtok_r(char *, const char *, char **); double fdsec, fsec, fdeg, fmin; if ( f < 0 || f > 360 ) { - strlcpy( str, "nan", 40); + (void)strlcpy( str, "nan", 40); return str; } @@ -621,6 +621,7 @@ int gps_del_callback(struct gps_data_t *gpsdata, pthread_t *handler) * Returns strlen(src) + MIN(siz, strlen(initial dst)). * If retval >= siz, truncation occurred. */ +/*@ -usedef -mustdefine @*/ size_t strlcat(char *dst, const char *src, size_t siz) { @@ -632,7 +633,7 @@ strlcat(char *dst, const char *src, size_t siz) /* Find the end of dst and adjust bytes left but don't go past end */ while (n-- != 0 && *d != '\0') d++; - dlen = d - dst; + dlen = (size_t)(d - dst); n = siz - dlen; if (n == 0) @@ -648,6 +649,7 @@ strlcat(char *dst, const char *src, size_t siz) return(dlen + (s - src)); /* count does not include NUL */ } +/*@ +usedef +mustdefine @*/ #endif /* HAVE_STRLCAT */ #ifndef HAVE_STRLCPY @@ -693,11 +695,11 @@ strlcpy(char *dst, const char *src, size_t siz) if (n == 0) { if (siz != 0) *d = '\0'; /* NUL-terminate dst */ - while (*s++) - ; + while (*s++ != '\0') + continue; } - return(s - src - 1); /* count does not include NUL */ + return((size_t)(s - src - 1)); /* count does not include NUL */ } #endif /* HAVE_STRLCPY */ diff --git a/nmea_parse.c b/nmea_parse.c index 9fca3cc3..73a3db37 100644 --- a/nmea_parse.c +++ b/nmea_parse.c @@ -684,10 +684,10 @@ int nmea_send(int fd, const char *fmt, ... ) (void)vsnprintf(buf, sizeof(buf)-5, fmt, ap); va_end(ap); if (fmt[0] == '$') { - strlcat(buf, "*", BUFSIZ); + (void)strlcat(buf, "*", BUFSIZ); nmea_add_checksum(buf); } else - strlcat(buf, "\r\n", BUFSIZ); + (void)strlcat(buf, "\r\n", BUFSIZ); status = (int)write(fd, buf, strlen(buf)); if (status == (int)strlen(buf)) { gpsd_report(2, "=> GPS: %s\n", buf); @@ -395,7 +395,7 @@ int ntrip_open(struct gps_context_t *context, char *caster) /*@ -boolops @*/ if ((amp = strchr(caster, '@')) != NULL) { - if ((colon = strchr(caster, ':') != NULL) && colon < amp) { + if (((colon = strchr(caster, ':')) != NULL) && colon < amp) { auth = caster; *amp = '\0'; caster = amp + 1; @@ -953,7 +953,7 @@ void rtcm_dump(struct gps_device_t *session, /*@out@*/char buf[], size_t buflen) break; case 6: /* NOP msg */ - strlcat(buf, "N\n", buflen); + (void)strlcat(buf, "N\n", buflen); break; case 7: diff --git a/rtcmdecode.c b/rtcmdecode.c index 5c07c0f1..bfd77986 100644 --- a/rtcmdecode.c +++ b/rtcmdecode.c @@ -18,7 +18,7 @@ void gpsd_report(int errlevel, const char *fmt, ... ) char buf[BUFSIZ]; va_list ap; - strlcpy(buf, "rtcmdecode: ", BUFSIZ); + (void)strlcpy(buf, "rtcmdecode: ", BUFSIZ); va_start(ap, fmt) ; (void)vsnprintf(buf + strlen(buf), sizeof(buf)-strlen(buf), fmt, ap); va_end(ap); @@ -1,9 +1,10 @@ -#include "config.h" #include <unistd.h> #include <string.h> #include <fcntl.h> #include <errno.h> #include <ctype.h> +#include "config.h" + #if defined(HAVE_SYS_MODEM_H) #include <sys/modem.h> #endif /* HAVE_SYS_MODEM_H */ @@ -491,7 +491,7 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l /* HDOP should be available at byte 89, but in 231 it's zero. */ mask |= SPEED_SET | TRACK_SET | CLIMB_SET | CYCLE_START_SET; session->gpsdata.sentence_length = 91; - strlcpy(session->gpsdata.tag, "GND",MAXTAGLEN+1); + (void)strlcpy(session->gpsdata.tag, "GND",MAXTAGLEN+1); } return mask; @@ -144,7 +144,7 @@ static int nmea_send(int fd, const char *fmt, ... ) va_start(ap, fmt) ; (void)vsnprintf(buf, sizeof(buf)-5, fmt, ap); va_end(ap); - strlcat(buf, "*", BUFLEN); + (void)strlcat(buf, "*", BUFLEN); nmea_add_checksum(buf); (void)fputs(buf, stderr); /* so user can watch the baud hunt */ status = (size_t)write(fd, buf, strlen(buf)); @@ -527,7 +527,7 @@ static void update_panel(struct gps_data_t *gpsdata, l = strlen(device)+4; if ((channelcmd = (char *)malloc(l)) != NULL){ - /*@i1@*/(void)strlcpy(channelcmd, "F=", l); + (void)strlcpy(channelcmd, "F=", l); (void)strlcpy(channelcmd+2, device, l); (void)gps_query(gpsdata, channelcmd); (void)free(channelcmd); diff --git a/xgpsspeed.c b/xgpsspeed.c index a417a161..f5453f76 100644 --- a/xgpsspeed.c +++ b/xgpsspeed.c @@ -179,10 +179,12 @@ int main(int argc, char **argv) l = strlen(device)+4; if ((channelcmd = (char *)malloc(l)) != NULL){ - /*@i1@*/(void)strlcpy(channelcmd, "F=", l); + /*@ -compdef @*/ + (void)strlcpy(channelcmd, "F=", l); (void)strlcpy(channelcmd+2, device, l); (void)gps_query(gpsdata, channelcmd); (void)free(channelcmd); + /*@ +compdef @*/ } } @@ -349,11 +349,11 @@ static gps_mask_t zodiac_analyze(struct gps_device_t *session) unsigned int id = (unsigned int)((session->outbuffer[3]<<8) | session->outbuffer[2]); if (session->packet_type != ZODIAC_PACKET) { + struct gps_type_t **dp; gpsd_report(2, "zodiac_analyze packet type %d\n",session->packet_type); // Wrong packet type ? // Maybe find a trigger just in case it's an Earthmate gpsd_report(9, "Is this a trigger: %s ?\n", (char*)session->outbuffer); - struct gps_type_t **dp; for (dp = gpsd_drivers; *dp; dp++) { char *trigger = (*dp)->trigger; |