From a61e28529df634963c0967e59aae673f8fc7741e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 21 Jan 2015 12:56:08 -0500 Subject: Easy splint cleanups. All regression tests pass. --- .splintrc | 1 + driver_garmin.c | 8 ++++---- driver_geostar.c | 6 +++--- driver_italk.c | 8 ++++---- driver_navcom.c | 8 ++++---- driver_nmea0183.c | 22 +++++++++++----------- driver_oncore.c | 22 +++++++++++++--------- driver_sirf.c | 13 +++++++------ driver_superstar2.c | 12 ++++++------ driver_tsip.c | 14 +++++++------- driver_ubx.c | 10 +++++----- driver_zodiac.c | 8 ++++---- gpsctl.c | 4 ++++ gpsd.h-tail | 4 ++-- gpsd_json.c | 2 +- gpsdecode.c | 2 +- gpsutils.c | 2 +- libgps_sock.c | 12 ++++++------ ntpshm.c | 2 +- strfuncs.h | 8 ++++---- 20 files changed, 89 insertions(+), 79 deletions(-) diff --git a/.splintrc b/.splintrc index 9b292835..6982b06f 100644 --- a/.splintrc +++ b/.splintrc @@ -9,6 +9,7 @@ -predboolint -nestedextern -abstract +-fixedformalarray -Ddbus_uint32_t=uint -Disgps30bits_t=uint diff --git a/driver_garmin.c b/driver_garmin.c index e9b15554..ead0ae87 100644 --- a/driver_garmin.c +++ b/driver_garmin.c @@ -564,11 +564,11 @@ gps_mask_t PrintSERPacket(struct gps_device_t *session, unsigned char pkt_id, } if ((int)sats->svid <= 32) - session->gpsdata.skyview[j].PRN = (int)sats->svid; /* GPS */ + session->gpsdata.skyview[j].PRN = (short)sats->svid; /* GPS */ else - session->gpsdata.skyview[j].PRN = (int)sats->svid + 87; /* SBAS */ - session->gpsdata.skyview[j].azimuth = (int)GPSD_LE16TOH(sats->azmth); - session->gpsdata.skyview[j].elevation = (int)sats->elev; + session->gpsdata.skyview[j].PRN = (short)sats->svid + 87; /* SBAS */ + session->gpsdata.skyview[j].azimuth = (short)GPSD_LE16TOH(sats->azmth); + session->gpsdata.skyview[j].elevation = (short)sats->elev; // Garmin does not document this. snr is in dB*100 // Known, but not seen satellites have a dB value of -1*100 session->gpsdata.skyview[j].ss = (float)(GPSD_LE16TOH(sats->snr) / 100.0); diff --git a/driver_geostar.c b/driver_geostar.c index c6c36a27..6eae5295 100644 --- a/driver_geostar.c +++ b/driver_geostar.c @@ -266,9 +266,9 @@ static gps_mask_t geostar_analyze(struct gps_device_t *session) s3 = getles16(buf, OFFSET(4) + 2 + i * 3 * 4); gpsd_report(&session->context->errout, LOG_INF, "ID %d Az %g El %g SNR %g\n", decode_channel_id(ul2), s1*0.001*RAD_2_DEG, s2*0.001*RAD_2_DEG, s3*0.1); - session->gpsdata.skyview[i].PRN = decode_channel_id(ul2); - session->gpsdata.skyview[i].azimuth = (int)round((double)s1*0.001 * RAD_2_DEG); - session->gpsdata.skyview[i].elevation = (int)round((double)s2*0.001 * RAD_2_DEG); + session->gpsdata.skyview[i].PRN = (short)decode_channel_id(ul2); + session->gpsdata.skyview[i].azimuth = (short)round((double)s1*0.001 * RAD_2_DEG); + session->gpsdata.skyview[i].elevation = (short)round((double)s2*0.001 * RAD_2_DEG); session->gpsdata.skyview[i].ss = (double)s3*0.1; session->gpsdata.skyview[i].used = (bool)(ul2 & (1<<27)); } diff --git a/driver_italk.c b/driver_italk.c index 9169e128..051376c2 100644 --- a/driver_italk.c +++ b/driver_italk.c @@ -142,11 +142,11 @@ static gps_mask_t decode_itk_prnstatus(struct gps_device_t *session, bool used; flags = (unsigned short) getleu16(buf, off); - used = flags & PRN_FLAG_USE_IN_NAV; + used = (bool)(flags & PRN_FLAG_USE_IN_NAV); session->gpsdata.skyview[st].ss = (float)(getleu16(buf, off + 2) & 0xff); - session->gpsdata.skyview[st].PRN = (int)getleu16(buf, off + 4) & 0xff; - session->gpsdata.skyview[st].elevation = (int)getles16(buf, off + 6) & 0xff; - session->gpsdata.skyview[st].azimuth = (int)getles16(buf, off + 8) & 0xff; + session->gpsdata.skyview[st].PRN = (short)(getleu16(buf, off + 4) & 0xff); + session->gpsdata.skyview[st].elevation = (short)(getles16(buf, off + 6) & 0xff); + session->gpsdata.skyview[st].azimuth = (short)(getles16(buf, off + 8) & 0xff); session->gpsdata.skyview[st].used = used; if (session->gpsdata.skyview[st].PRN > 0) { st++; diff --git a/driver_navcom.c b/driver_navcom.c index 3e08af3d..55f0a323 100644 --- a/driver_navcom.c +++ b/driver_navcom.c @@ -789,9 +789,9 @@ static gps_mask_t handle_0x86(struct gps_device_t *session) * says should be. So I check for the fact that if all three * values below are zero, one is not interested in this satellite */ if (!(ele == 0 && azm == 0 && dgps_age == 0)) { - session->gpsdata.skyview[i].PRN = (int)prn; - session->gpsdata.skyview[i].elevation = (int)ele; - session->gpsdata.skyview[i].azimuth = (int)azm; + session->gpsdata.skyview[i].PRN = (short)prn; + session->gpsdata.skyview[i].elevation = (short)ele; + session->gpsdata.skyview[i].azimuth = (short)azm; /*@ ignore @*//* splint is confused */ s = session->gpsdata.skyview[i++].ss = (p2_snr ? p2_snr : ca_snr) / 4.0; /*@ end @*/ @@ -799,7 +799,7 @@ static gps_mask_t handle_0x86(struct gps_device_t *session) if (stat == 0xff) nsu++; } - session->gpsdata.satellites_used = nsu; + session->gpsdata.satellites_used = (int)nsu; gpsd_report(&session->context->errout, LOG_DATA, "Navcom: prn = %3u, ele = %02u, azm = %03u, snr = %d (%s), " "dgps age = %.1fs, log ch = %d, hw ch = 0x%02x\n", diff --git a/driver_nmea0183.c b/driver_nmea0183.c index 653f2f88..17129ddb 100644 --- a/driver_nmea0183.c +++ b/driver_nmea0183.c @@ -503,11 +503,11 @@ static gps_mask_t processGSA(int count, char *field[], mask = MODE_SET; gpsd_report(&session->context->errout, LOG_PROG, "GPGSA sets mode %d\n", session->newdata.mode); - if (field[15][0]) + if (field[15][0] != '\0') session->gpsdata.dop.pdop = safe_atof(field[15]); - if (field[16][0]) + if (field[16][0] != '\0') session->gpsdata.dop.hdop = safe_atof(field[16]); - if (field[17][0]) + if (field[17][0] != '\0') session->gpsdata.dop.vdop = safe_atof(field[17]); session->gpsdata.satellites_used = 0; memset(session->nmea.sats_used, 0, sizeof(session->nmea.sats_used)); @@ -516,7 +516,7 @@ static gps_mask_t processGSA(int count, char *field[], int prn = atoi(field[i + 3]); if (prn > 0) session->nmea.sats_used[session->gpsdata.satellites_used++] = - prn; + (unsigned short)prn; } mask |= DOP_SET | USED_IS; gpsd_report(&session->context->errout, LOG_DATA, @@ -595,17 +595,17 @@ static gps_mask_t processGSV(int count, char *field[], break; } sp = &session->gpsdata.skyview[session->gpsdata.satellites_visible]; - sp->PRN = atoi(field[fldnum++]); + sp->PRN = (short)atoi(field[fldnum++]); // NMEA-ID (33..64) to SBAS PRN. if (sp->PRN >= 33 && sp->PRN <= 64) sp->PRN += 87; - sp->elevation = atoi(field[fldnum++]); - sp->azimuth = atoi(field[fldnum++]); + sp->elevation = (short)atoi(field[fldnum++]); + sp->azimuth = (short)atoi(field[fldnum++]); sp->ss = (float)atoi(field[fldnum++]); sp->used = false; if (sp->PRN > 0) for (n = 0; n < MAXCHANNELS; n++) - if (session->nmea.sats_used[n] == sp->PRN) { + if (session->nmea.sats_used[n] == (unsigned short)sp->PRN) { sp->used = true; break; } @@ -1077,9 +1077,9 @@ static gps_mask_t processPASHR(int c UNUSED, char *field[], int i, n = session->gpsdata.satellites_visible = atoi(field[2]); session->gpsdata.satellites_used = 0; for (i = 0, sp = session->gpsdata.skyview; sp < session->gpsdata.skyview + n; sp++, i++) { - sp->PRN = atoi(field[3 + i * 5 + 0]); - sp->azimuth = atoi(field[3 + i * 5 + 1]); - sp->elevation = atoi(field[3 + i * 5 + 2]); + sp->PRN = (short)atoi(field[3 + i * 5 + 0]); + sp->azimuth = (short)atoi(field[3 + i * 5 + 1]); + sp->elevation = (short)atoi(field[3 + i * 5 + 2]); sp->ss = safe_atof(field[3 + i * 5 + 3]); sp->used = false; if (field[3 + i * 5 + 4][0] == 'U') { diff --git a/driver_oncore.c b/driver_oncore.c index 9a2808a5..36c26de3 100644 --- a/driver_oncore.c +++ b/driver_oncore.c @@ -108,6 +108,9 @@ oncore_msg_navsol(struct gps_device_t *session, unsigned char *buf, unpacked_date.tm_min = (int)getub(buf, 9); unpacked_date.tm_sec = (int)getub(buf, 10); unpacked_date.tm_isdst = 0; +#ifdef S_SPLINT_S + unpacked_date. tm_wday = unpacked_date. tm_yday = 0; +#endif /* S_SPLINT_S */ nsec = (uint) getbeu32(buf, 11); /*@ -unrecog */ @@ -164,14 +167,14 @@ oncore_msg_navsol(struct gps_device_t *session, unsigned char *buf, "%2d %2d %2d %3d %02x\n", i, sv, mode, sn, status); if (sn) { - session->gpsdata.skyview[st].PRN = sv; + session->gpsdata.skyview[st].PRN = (short)sv; session->gpsdata.skyview[st].ss = (double)sn; for (j = 0; (int)j < session->driver.oncore.visible; j++) if (session->driver.oncore.PRN[j] == sv) { session->gpsdata.skyview[st].elevation = - session->driver.oncore.elevation[j]; + (short)session->driver.oncore.elevation[j]; session->gpsdata.skyview[st].azimuth = - session->driver.oncore.azimuth[j]; + (short)session->driver.oncore.azimuth[j]; Bbused |= 1 << j; break; } @@ -196,10 +199,11 @@ oncore_msg_navsol(struct gps_device_t *session, unsigned char *buf, for (j = 0; (int)j < session->driver.oncore.visible; j++) /*@ -boolops @*/ if (!(Bbused & (1 << j))) { - session->gpsdata.skyview[st].PRN = session->driver.oncore.PRN[j]; + session->gpsdata.skyview[st].PRN = (short)session->driver.oncore.PRN[j]; session->gpsdata.skyview[st].elevation = - session->driver.oncore.elevation[j]; - session->gpsdata.skyview[st].azimuth = session->driver.oncore.azimuth[j]; + (short)session->driver.oncore.elevation[j]; + session->gpsdata.skyview[st].azimuth = + (short)session->driver.oncore.azimuth[j]; st++; } /*@ +boolops @*/ @@ -310,9 +314,9 @@ oncore_msg_svinfo(struct gps_device_t *session, unsigned char *buf, session->driver.oncore.azimuth[i] = az; /* If it has an entry in the satellite list, update it! */ for (j = 0; j < session->gpsdata.satellites_visible; j++) - if (session->gpsdata.skyview[j].PRN == sv) { - session->gpsdata.skyview[j].elevation = el; - session->gpsdata.skyview[j].azimuth = az; + if (session->gpsdata.skyview[j].PRN == (short)sv) { + session->gpsdata.skyview[j].elevation = (short)el; + session->gpsdata.skyview[j].azimuth = (short)az; } } diff --git a/driver_sirf.c b/driver_sirf.c index d4be5f47..746ac661 100644 --- a/driver_sirf.c +++ b/driver_sirf.c @@ -580,21 +580,22 @@ static gps_mask_t sirf_msg_svinfo(struct gps_device_t *session, gpsd_zero_satellites(&session->gpsdata); for (i = st = nsv = 0; i < SIRF_CHANNELS; i++) { - int cn, prn; + int cn; + short prn; int off = 8 + 15 * i; bool good; - unsigned short stat = getbeu16(buf, off + 3); - session->gpsdata.skyview[st].PRN = prn = (int)getub(buf, off); + unsigned short stat = (unsigned short)getbeu16(buf, off + 3); + session->gpsdata.skyview[st].PRN = prn = (short)getub(buf, off); session->gpsdata.skyview[st].azimuth = - (int)(((unsigned)getub(buf, off + 1) * 3) / 2.0); + (short)(((unsigned)getub(buf, off + 1) * 3) / 2.0); session->gpsdata.skyview[st].elevation = - (int)((unsigned)getub(buf, off + 2) / 2.0); + (short)((unsigned)getub(buf, off + 2) / 2.0); cn = 0; for (j = 0; j < 10; j++) cn += (int)getub(buf, off + 5 + j); session->gpsdata.skyview[st].ss = (float)(cn / 10.0); - session->gpsdata.skyview[st].used = (stat & 0x01); + session->gpsdata.skyview[st].used = (bool)(stat & 0x01); good = session->gpsdata.skyview[st].PRN != 0 && session->gpsdata.skyview[st].azimuth != 0 && session->gpsdata.skyview[st].elevation != 0; diff --git a/driver_superstar2.c b/driver_superstar2.c index 9dd0de87..f16f38d0 100644 --- a/driver_superstar2.c +++ b/driver_superstar2.c @@ -184,15 +184,15 @@ superstar2_msg_svinfo(struct gps_device_t *session, /* get info for one channel/satellite */ int off = i * 5 + 5; unsigned int porn; + bool used = (getub(buf, off) & 0x60) == 0x60; if ((porn = (unsigned int)getub(buf, off) & 0x1f) == 0) porn = (unsigned int)(getub(buf, off + 3) >> 1) + 87; - bool used = (getub(buf, off) & 0x60) == 0x60; - session->gpsdata.skyview[i].PRN = (int)porn; + session->gpsdata.skyview[i].PRN = (short)porn; session->gpsdata.skyview[i].ss = (float)getub(buf, off + 4); - session->gpsdata.skyview[i].elevation = (int)getsb(buf, off + 1); - session->gpsdata.skyview[i].azimuth = (unsigned short)getub(buf, off + 2) + - ((unsigned short)(getub(buf, off + 3) & 0x1) << 1); + session->gpsdata.skyview[i].elevation = (short)getsb(buf, off + 1); + session->gpsdata.skyview[i].azimuth = (short)getub(buf, off + 2) + + (short)((unsigned short)(getub(buf, off + 3) & 0x1) << 1); session->gpsdata.skyview[i].used = used; /*@ +charint @*/ if (used) @@ -306,7 +306,7 @@ superstar2_msg_measurement(struct gps_device_t *session, unsigned char *buf, for (i = 0; i < n; i++) { unsigned long ul; session->gpsdata.raw.mtime[i] = t; - session->gpsdata.skyview[i].PRN = (int)getub(buf, 11 * i + 15) & 0x1f; + session->gpsdata.skyview[i].PRN = (short)(getub(buf, 11 * i + 15) & 0x1f); session->gpsdata.skyview[i].ss = (double)getub(buf, 11 * i * 15 + 1) / 4.0; session->gpsdata.raw.codephase[i] = (double)getleu32(buf, 11 * i * 15 + 2); diff --git a/driver_tsip.c b/driver_tsip.c index a3136fbd..ebf6a93d 100644 --- a/driver_tsip.c +++ b/driver_tsip.c @@ -342,7 +342,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) if ((f1 = getbef32((char *)buf, 5 * i + 2)) < 0) f1 = 0.0; for (j = 0; j < TSIP_CHANNELS; j++) - if (session->gpsdata.skyview[j].PRN == (int)u1) { + if (session->gpsdata.skyview[j].PRN == (short)u1) { session->gpsdata.skyview[j].ss = f1; break; } @@ -506,13 +506,13 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) i, u1, u2 & 7, u3, u4, f1, f2, d1, d2); if (i < TSIP_CHANNELS) { if (d1 >= 0.0) { - session->gpsdata.skyview[i].PRN = (int)u1; - session->gpsdata.skyview[i].ss = f1; - session->gpsdata.skyview[i].elevation = (int)round(d1); - session->gpsdata.skyview[i].azimuth = (int)round(d2); + session->gpsdata.skyview[i].PRN = (short)u1; + session->gpsdata.skyview[i].ss = (double)f1; + session->gpsdata.skyview[i].elevation = (short)round(d1); + session->gpsdata.skyview[i].azimuth = (short)round(d2); session->gpsdata.skyview[i].used = false; for (j = 0; j < session->gpsdata.satellites_used; j++) - if (session->gpsdata.skyview[i].PRN && session->driver.tsip.sats_used[j]) + if (session->gpsdata.skyview[i].PRN != 0 && session->driver.tsip.sats_used[j] != 0) session->gpsdata.skyview[i].used = true; } else { session->gpsdata.skyview[i].PRN = @@ -579,7 +579,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session) for (i = 0; i < count; i++) str_appendf(buf2, sizeof(buf2), " %d", session->driver.tsip.sats_used[i] = - (int)getub(buf, 17 + i)); + (short)getub(buf, 17 + i)); /*@ -charint @*/ gpsd_report(&session->context->errout, LOG_DATA, "AIVSS: 0x6d status=%d used=%d " diff --git a/driver_ubx.c b/driver_ubx.c index 616dcac7..2f2a7358 100644 --- a/driver_ubx.c +++ b/driver_ubx.c @@ -260,18 +260,18 @@ ubx_msg_nav_svinfo(struct gps_device_t *session, unsigned char *buf, nsv = 0; for (i = st = 0; i < nchan; i++) { unsigned int off = 8 + 12 * i; - bool used = getub(buf, off + 2) & 0x01; + bool used = (bool)(getub(buf, off + 2) & 0x01); if ((int)getub(buf, off + 4) == 0) continue; /* LEA-5H seems to have a bug reporting sats it does not see or hear */ - session->gpsdata.skyview[st].PRN = (int)getub(buf, off + 1); + session->gpsdata.skyview[st].PRN = (short)getub(buf, off + 1); session->gpsdata.skyview[st].ss = (float)getub(buf, off + 4); - session->gpsdata.skyview[st].elevation = (int)getsb(buf, off + 5); - session->gpsdata.skyview[st].azimuth = (int)getles16(buf, off + 6); + session->gpsdata.skyview[st].elevation = (short)getsb(buf, off + 5); + session->gpsdata.skyview[st].azimuth = (short)getles16(buf, off + 6); session->gpsdata.skyview[st].used = used; if (session->gpsdata.skyview[st].PRN == 0) continue; /*@ -predboolothers */ - if (used || session->gpsdata.skyview[st].PRN == (int)session->driver.ubx.sbas_in_use) { + if (used || session->gpsdata.skyview[st].PRN == (short)session->driver.ubx.sbas_in_use) { nsv++; session->gpsdata.skyview[st].used = true; } diff --git a/driver_zodiac.c b/driver_zodiac.c index b712503e..1c3c8731 100644 --- a/driver_zodiac.c +++ b/driver_zodiac.c @@ -239,7 +239,7 @@ static gps_mask_t handle1002(struct gps_device_t *session) if (status & 1) session->gpsdata.satellites_used++; - session->gpsdata.skyview[i].PRN = prn; + session->gpsdata.skyview[i].PRN = (short)prn; session->gpsdata.skyview[i].ss = (float)getzword(17 + (3 * i)); session->gpsdata.skyview[i].used = (bool)(status & 1); } @@ -278,13 +278,13 @@ static gps_mask_t handle1003(struct gps_device_t *session) for (i = 0; i < ZODIAC_CHANNELS; i++) { if (i < session->gpsdata.satellites_visible) { - session->gpsdata.skyview[i].PRN = (int)getzword(15 + (3 * i)); + session->gpsdata.skyview[i].PRN = (short)getzword(15 + (3 * i)); session->gpsdata.skyview[i].azimuth = - (int)(((short)getzword(16 + (3 * i))) * RAD_2_DEG * 1e-4); + (short)(((short)getzword(16 + (3 * i))) * RAD_2_DEG * 1e-4); if (session->gpsdata.skyview[i].azimuth < 0) session->gpsdata.skyview[i].azimuth += 360; session->gpsdata.skyview[i].elevation = - (int)(((short)getzword(17 + (3 * i))) * RAD_2_DEG * 1e-4); + (short)(((short)getzword(17 + (3 * i))) * RAD_2_DEG * 1e-4); } else { session->gpsdata.skyview[i].PRN = 0; session->gpsdata.skyview[i].azimuth = 0; diff --git a/gpsctl.c b/gpsctl.c index b5274f06..2cd44081 100644 --- a/gpsctl.c +++ b/gpsctl.c @@ -182,6 +182,7 @@ static void ctlhook(struct gps_device_t *device UNUSED, gps_mask_t changed UNUSE } } +/*@-mustfreeonly -observertrans -statictrans@*/ int main(int argc, char **argv) { int option, status; @@ -844,3 +845,6 @@ int main(int argc, char **argv) /*@ +mustfreeonly +immediatetrans @*/ } } +/*@+mustfreeonly +observertrans +statictrans@*/ + +/* end */ diff --git a/gpsd.h-tail b/gpsd.h-tail index 25b9e2ec..a361f403 100644 --- a/gpsd.h-tail +++ b/gpsd.h-tail @@ -1050,8 +1050,8 @@ void cfmakeraw(struct termios *); /* Needed because 4.x versions of GCC are really annoying */ #define ignore_return(funcall) \ do { \ - ssize_t result = (funcall); \ - assert(result != -23); \ + ssize_t locresult = (funcall); \ + assert(locresult != -23); \ } while (0) static /*@unused@*/ inline void memory_barrier(void) diff --git a/gpsd_json.c b/gpsd_json.c index 5adc0bf7..a8f8a950 100644 --- a/gpsd_json.c +++ b/gpsd_json.c @@ -3223,7 +3223,7 @@ void json_aivdm_dump(const struct ais_t *ais, } } str_rstrip_char(buf, ','); - strlcat(buf, "}\r\n", buflen); + (void)strlcat(buf, "}\r\n", buflen); break; case 25: /* Binary Message, Single Slot */ str_appendf(buf, buflen, diff --git a/gpsdecode.c b/gpsdecode.c index 71a071d1..f9d6965e 100644 --- a/gpsdecode.c +++ b/gpsdecode.c @@ -23,7 +23,7 @@ static bool pseudonmea = false; static bool split24 = false; static unsigned int ntypes = 0; static unsigned int typelist[32]; -struct gps_context_t context; +static struct gps_context_t context; /************************************************************************** * diff --git a/gpsutils.c b/gpsutils.c index eb70e179..65d428af 100644 --- a/gpsutils.c +++ b/gpsutils.c @@ -360,7 +360,7 @@ timestamp_t iso8601_to_unix( /*@in@*/ char *isotime) * suggests timezone is being set improperly (off by an hour). * Also timezon is not available at all on some BSDs. */ - return (timestamp_t)timegm(&tm) + usec; + /*@i1@*/return (timestamp_t)timegm(&tm) + usec; #else double usec = 0; diff --git a/libgps_sock.c b/libgps_sock.c index 8d3a8742..e5135638 100644 --- a/libgps_sock.c +++ b/libgps_sock.c @@ -273,7 +273,7 @@ int gps_unpack(char *buf, struct gps_data_t *gpsdata) #endif /* __UNUSED__ */ for (ns = buf; ns; ns = strstr(ns + 1, "GPSD")) { - if (str_starts_with(ns, "GPSD")) { + /*@i1@*/if (str_starts_with(ns, "GPSD")) { /* the following should execute each time we have a good next sp */ for (sp = ns + 5; *sp != '\0'; sp = tp + 1) { bool eol; @@ -425,11 +425,11 @@ int gps_unpack(char *buf, struct gps_data_t *gpsdata) // cppcheck-suppress invalidscanf (void)sscanf(sp, "%d %d %d %lf %d", &i1, &i2, &i3, &f4, &i5); - gpsdata->skyview[j].PRN = i1; - gpsdata->skyview[j].elevation = i2; - gpsdata->skyview[j].azimuth = i3; - gpsdata->skyview[j].ss = f4; - gpsdata->skyview[j].used = i5; + gpsdata->skyview[j].PRN = (short)i1; + gpsdata->skyview[j].elevation = (short)i2; + gpsdata->skyview[j].azimuth = (short)i3; + gpsdata->skyview[j].ss = (double)f4; + gpsdata->skyview[j].used = (bool)i5; if (i5 == 1) gpsdata->satellites_used++; } diff --git a/ntpshm.c b/ntpshm.c index 38eb4865..81f1778a 100644 --- a/ntpshm.c +++ b/ntpshm.c @@ -175,7 +175,7 @@ void ntpshm_context_init(struct gps_context_t *context) memset(context->shmTimeInuse, 0, sizeof(context->shmTimeInuse)); } -static volatile struct shmTime *ntpshm_alloc(struct gps_context_t *context) +static /*@null@*/ volatile struct shmTime *ntpshm_alloc(struct gps_context_t *context) /* allocate NTP SHM segment. return its segment number, or -1 */ { int i; diff --git a/strfuncs.h b/strfuncs.h index 7ea136fb..e38305b6 100644 --- a/strfuncs.h +++ b/strfuncs.h @@ -14,14 +14,14 @@ #include "compiler.h" -static inline bool str_starts_with(const char *str, const char *prefix) +static /*@unused@*/ inline bool str_starts_with(const char *str, const char *prefix) { return strncmp(str, prefix, strlen(prefix)) == 0; } PRINTF_FUNC(3, 4) -static inline void str_appendf(char *str, size_t alloc_size, const char *format, ...) +static /*@unused@*/ inline void str_appendf(char *str, size_t alloc_size, const char *format, ...) { va_list ap; va_start(ap, format); @@ -30,13 +30,13 @@ static inline void str_appendf(char *str, size_t alloc_size, const char *format, } -static inline void str_vappendf(char *str, size_t alloc_size, const char *format, va_list ap) +static /*@unused@*/ inline void str_vappendf(char *str, size_t alloc_size, const char *format, va_list ap) { (void) vsnprintf(str + strlen(str), alloc_size - strlen(str), format, ap); } -static inline void str_rstrip_char(char *str, char ch) +static /*@unused@*/ inline void str_rstrip_char(char *str, char ch) { if (strlen(str) != 0 && str[strlen(str) - 1] == ch) { str[strlen(str) - 1] = '\0'; -- cgit v1.2.1