From 494bdad6b849d18ce86437d9193edfe3d1211710 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 15 Dec 2010 11:13:08 -0500 Subject: Partial splint cleanup. All regression tests pass. --- driver_geostar.c | 30 ++++++++++++++++++++---------- gpsd.c | 4 ++-- lcdgps.c | 2 ++ net_dgpsip.c | 2 +- netlib.c | 6 +++--- subframe.c | 6 +++--- 6 files changed, 31 insertions(+), 19 deletions(-) diff --git a/driver_geostar.c b/driver_geostar.c index 3aede248..b2715843 100644 --- a/driver_geostar.c +++ b/driver_geostar.c @@ -28,16 +28,16 @@ #define OFFSET(n) ((n)*4+4) -static int decode_channel_id (unsigned long ch_id) { +static int decode_channel_id (uint32_t ch_id) { int num = 0; - num = ch_id & 0x1F; /* SV ID */ + num = (int)(ch_id & 0x1F); /* SV ID */ if((ch_id & (1<<30)) == 0) num += 32; /* GLONASS SV */ else if (num == 0 ) num = 32; /* GPS SV */ return num; } static int geostar_write(struct gps_device_t *session, - unsigned int id,/*@null@*/ unsigned char *data, size_t len) + unsigned int id, unsigned char *data, size_t len) { int i; unsigned long cs = 0; @@ -47,8 +47,10 @@ static int geostar_write(struct gps_device_t *session, putbyte(session->msgbuf, 2, 'G'); putbyte(session->msgbuf, 3, 'G'); + /*@-shiftimplementation +ignoresigns@*/ putbeword(session->msgbuf, 4, id); putbeword(session->msgbuf, 6, len); + /*@+shiftimplementation -ignoresigns@*/ /* Copy content */ memcpy(session->msgbuf + 8, data, len * sizeof(long)); @@ -60,7 +62,9 @@ static int geostar_write(struct gps_device_t *session, cs ^= getleul(session->msgbuf, i * sizeof(long)); } + /*@-shiftimplementation +ignoresigns@*/ putlelong(session->msgbuf, len * sizeof(long), cs); + /*@+shiftimplementation -ignoresigns@*/ len += 1; /* Checksum */ @@ -95,9 +99,9 @@ static bool geostar_detect(struct gps_device_t *session) myfd = session->gpsdata.gps_fd; /* request firmware revision and look for a valid response */ - /*@+ignoresigns@*/ + /*@-shiftimplementation +ignoresigns@*/ putbelong(buf, 0, 0); - /*@+ignoresigns@*/ + /*@+shiftimplementation +ignoresigns@*/ if (geostar_write(session, 0xc1, buf, 1) == 0) { for (n = 0; n < 3; n++) { FD_ZERO(&fdset); @@ -155,7 +159,7 @@ static gps_mask_t geostar_analyze(struct gps_device_t *session) } /*@ -charint @*/ - id = getleuw(session->packet.outbuffer, OFFSET(0)); + id = (unsigned int)getleuw(session->packet.outbuffer, OFFSET(0)); (void)snprintf(session->gpsdata.tag, sizeof(session->gpsdata.tag), "ID%02x", id); @@ -250,9 +254,9 @@ static gps_mask_t geostar_analyze(struct gps_device_t *session) case 0x22: ul1 = getleul(buf, OFFSET(1)); gpsd_report(LOG_INF, "SVs in view %d\n", ul1); - session->gpsdata.satellites_visible = ul1; + session->gpsdata.satellites_visible = (int)ul1; if(ul1 > GEOSTAR_CHANNELS) ul1 = GEOSTAR_CHANNELS; - for(i = 0, j = 0; (unsigned int)i < ul1; i++) { + for(i = 0, j = 0; (uint32_t)i < ul1; i++) { ul2 = getleul(buf, OFFSET(2) + i * 3 * sizeof(long)); s1 = getlesw(buf, OFFSET(3) + i * 3 * sizeof(long)); s2 = getlesw(buf, OFFSET(3) + 2 + i * 3 * sizeof(long)); @@ -356,7 +360,7 @@ static gps_mask_t geostar_analyze(struct gps_device_t *session) gpsd_report(LOG_INF, "Response to Query output data rate\n"); break; case 0x86: - session->driver.geostar.physical_port = getleul(buf, OFFSET(1)); + session->driver.geostar.physical_port = (unsigned int)getleul(buf, OFFSET(1)); gpsd_report(LOG_INF, "Response to Query data protocol assignment to communication port\n"); gpsd_report(LOG_INF, "Connected to physical port %d\n", session->driver.geostar.physical_port); @@ -464,6 +468,7 @@ static void geostar_event_hook(struct gps_device_t *session, event_t event) { unsigned char buf[2 * sizeof(long)]; + /*@-shiftimplementation +ignoresigns@*/ if (event == event_identified && event == event_reactivate) { /* Select binary packets */ putbelong(buf, 0, 0xffff0000); @@ -500,6 +505,7 @@ static void geostar_event_hook(struct gps_device_t *session, event_t event) putbelong(buf, 0, 3); (void)geostar_write(session, 0xc2, buf, 1); } + /*@+shiftimplementation -ignoresigns@*/ } #ifdef ALLOW_RECONFIGURE @@ -524,10 +530,12 @@ static bool geostar_speed_switch(struct gps_device_t *session, break; } + /*@-shiftimplementation@*/ putbelong(buf, 0, session->driver.geostar.physical_port); putbelong(buf, 4, speed); putbelong(buf, 8, stopbits); putbelong(buf, 12, parity); + /*@+shiftimplementation@*/ (void)geostar_write(session, 0x41, buf, 4); return true; /* it would be nice to error-check this */ @@ -537,16 +545,18 @@ static void geostar_mode(struct gps_device_t *session, int mode) { unsigned char buf[1 * sizeof(long)]; + /*@-shiftimplementation@*/ if (mode == MODE_NMEA) { /* Switch to NMEA mode */ putbelong(buf, 0, (session->driver.geostar.physical_port == 0) ? 1 : 0); - geostar_write(session, 0x46, buf, 1); + (void)geostar_write(session, 0x46, buf, 1); } else if (mode == MODE_BINARY) { /* Switch to binary mode */ (void)nmea_send(session, "$GPSGG,SWPROT"); } else { gpsd_report(LOG_ERROR, "unknown mode %i requested\n", mode); } + /*@+shiftimplementation@*/ } #endif /* ALLOW_RECONFIGURE */ diff --git a/gpsd.c b/gpsd.c index 54892dc9..a61db30b 100644 --- a/gpsd.c +++ b/gpsd.c @@ -8,7 +8,6 @@ #include #include -#include #include #include #include @@ -24,6 +23,7 @@ #include #include #ifndef S_SPLINT_S +#include #include #endif /* S_SPLINT_S */ @@ -423,7 +423,7 @@ static int filesock(char *filename) return -1; } (void)strlcpy(addr.sun_path, filename, 104); /* from sys/un.h */ - addr.sun_family = AF_UNIX; + addr.sun_family = (sa_family_t)AF_UNIX; (void)bind(sock, (struct sockaddr *)&addr, (socklen_t)sizeof(addr)); if (listen(sock, QLEN) == -1) { gpsd_report(LOG_ERROR, "can't listen on local socket %s\n", filename); diff --git a/lcdgps.c b/lcdgps.c index 03a0ca92..4829d12c 100644 --- a/lcdgps.c +++ b/lcdgps.c @@ -37,9 +37,11 @@ #include #include #include +#ifndef S_SPLINT_S #ifndef AF_UNSPEC #include #endif /* AF_UNSPEC */ +#endif /* S_SPLINT_S */ #ifndef INADDR_ANY #include #endif /* INADDR_ANY */ diff --git a/net_dgpsip.c b/net_dgpsip.c index a6646ae2..eed60c3d 100644 --- a/net_dgpsip.c +++ b/net_dgpsip.c @@ -4,12 +4,12 @@ * BSD terms apply: see the file COPYING in the distribution root for details. */ #include -#include #include #include #include #include #ifndef S_SPLINT_S +#include #include #endif /* S_SPLINT_S */ diff --git a/netlib.c b/netlib.c index 618a9b9b..f368d41d 100644 --- a/netlib.c +++ b/netlib.c @@ -149,7 +149,7 @@ char *netlib_sock2ip(int fd) int r; r = getpeername(fd, &(fsin.sa), &alen); - /*@ -branchstate -unrecog @*/ + /*@ -branchstate -unrecog +boolint @*/ if (r == 0) { switch (fsin.sa.sa_family) { case AF_INET: @@ -158,7 +158,7 @@ char *netlib_sock2ip(int fd) break; #ifdef IPV6_ENABLE case AF_INET6: - r = !inet_ntop(fsin.sa_in6.sin6_family, &(fsin.sa_in6.sin6_addr), + r = !inet_ntop((int)fsin.sa_in6.sin6_family, &(fsin.sa_in6.sin6_addr), ip, sizeof(ip)); break; #endif @@ -174,6 +174,6 @@ char *netlib_sock2ip(int fd) strerror(errno), errno); (void)strlcpy(ip, "", sizeof(ip)); } - /*@ +branchstate +unrecog @*/ + /*@ +branchstate +unrecog -boolint @*/ return ip; } diff --git a/subframe.c b/subframe.c index 4b0d2367..85d921c0 100644 --- a/subframe.c +++ b/subframe.c @@ -134,11 +134,11 @@ void gpsd_interpret_subframe(struct gps_device_t *session, /* subframe 1: clock parameters */ /* get Week Number WN) from subframe 1 */ { - session->context->gps_week = - (unsigned short)((words[2] & 0xffc000) >> 14); unsigned int tgd = (words[6] & 0x0000FF); unsigned int toc = (words[7] & 0x00FFFF); unsigned int af1 = (words[8] & 0x00FFFF); + session->context->gps_week = + (unsigned short)((words[2] & 0xffc000) >> 14); gpsd_report(LOG_PROG, "50B: Subframe 1 WN: %u Tgd:%u toc:%u " " af1:%u\n", session->context->gps_week, tgd, toc, af1); @@ -305,7 +305,7 @@ void gpsd_interpret_subframe(struct gps_device_t *session, unsigned int e = (words[2] & 0x00FFFF); unsigned int toa = (words[3] & 0xFF0000) >> 16; unsigned int deltai = (words[3] & 0x00FFFF); - unsigned int Omega = (words[4] & 0xFFFF00) >> 8; + //unsigned int Omega = (words[4] & 0xFFFF00) >> 8; unsigned int svh = (words[4] & 0x0000FF); unsigned int sqrtA = (words[5] & 0xFFFFFF); unsigned int Omega0 = (words[6] & 0xFFFFFF); -- cgit v1.2.1