summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2015-01-22 22:44:48 -0500
committerEric S. Raymond <esr@thyrsus.com>2015-01-22 22:46:20 -0500
commit78c5fe3fe60be3645e080ff14c5c843c811c82da (patch)
tree754f2bc8945acbdd288ad960d48285767ea2416b
parent842cb2f0004842e48b064786a3e258d9cd5f9b0f (diff)
downloadgpsd-78c5fe3fe60be3645e080ff14c5c843c811c82da.tar.gz
cppcheck cleanup.
-rw-r--r--cgps.c2
-rw-r--r--driver_garmin.c2
-rw-r--r--driver_geostar.c2
-rw-r--r--driver_navcom.c4
-rw-r--r--driver_sirf.c3
-rw-r--r--driver_tsip.c3
-rw-r--r--gpsd.c6
-rw-r--r--matrix.c5
-rw-r--r--monitor_garmin.c7
-rw-r--r--subframe.c2
-rw-r--r--test_matrix.c4
11 files changed, 25 insertions, 15 deletions
diff --git a/cgps.c b/cgps.c
index ab8530ca..f86a1533 100644
--- a/cgps.c
+++ b/cgps.c
@@ -411,7 +411,6 @@ static void update_compass_panel(struct gps_data_t *gpsdata)
static void update_gps_panel(struct gps_data_t *gpsdata)
/* This gets called once for each new GPS sentence. */
{
- int i;
int newstate;
char scr[128], *s;
@@ -420,6 +419,7 @@ static void update_gps_panel(struct gps_data_t *gpsdata)
* available screen size, or may only show satellites used for the
* fix. */
if (gpsdata->satellites_visible != 0) {
+ int i;
if (display_sats >= MAX_POSSIBLE_SATS) {
for (i = 0; i < MAX_POSSIBLE_SATS; i++) {
if (i < gpsdata->satellites_visible) {
diff --git a/driver_garmin.c b/driver_garmin.c
index ead0ae87..d9d4888d 100644
--- a/driver_garmin.c
+++ b/driver_garmin.c
@@ -237,7 +237,7 @@ typedef struct
uint32_t mDataSize;
union
{
- int8_t chars[MAX_BUFFER_SIZE];
+ //int8_t chars[MAX_BUFFER_SIZE];
uint8_t uchars[MAX_BUFFER_SIZE];
cpo_pvt_data pvt;
cpo_sat_data sats;
diff --git a/driver_geostar.c b/driver_geostar.c
index 6eae5295..11e9ad78 100644
--- a/driver_geostar.c
+++ b/driver_geostar.c
@@ -127,7 +127,6 @@ static gps_mask_t geostar_analyze(struct gps_device_t *session)
int i, len;
gps_mask_t mask = 0;
unsigned int id;
- int16_t s1, s2, s3;
uint16_t uw1, uw2;
uint32_t ul1, ul2, ul3, ul4, ul5;
double d1, d2, d3, d4, d5;
@@ -260,6 +259,7 @@ static gps_mask_t geostar_analyze(struct gps_device_t *session)
session->gpsdata.satellites_visible = (int)ul1;
if(ul1 > GEOSTAR_CHANNELS) ul1 = GEOSTAR_CHANNELS;
for(i = 0; (uint32_t)i < ul1; i++) {
+ int16_t s1, s2, s3;
ul2 = getleu32(buf, OFFSET(2) + i * 3 * 4);
s1 = getles16(buf, OFFSET(3) + i * 3 * 4);
s2 = getles16(buf, OFFSET(3) + 2 + i * 3 * 4);
diff --git a/driver_navcom.c b/driver_navcom.c
index 57566d7f..925b7b61 100644
--- a/driver_navcom.c
+++ b/driver_navcom.c
@@ -701,8 +701,6 @@ static gps_mask_t handle_0x81(struct gps_device_t *session)
static gps_mask_t handle_0x86(struct gps_device_t *session)
{
size_t n, i, nsu;
- uint8_t prn, ele, ca_snr, p2_snr, log_channel, hw_channel, s, stat;
- uint16_t azm, dgps_age;
unsigned char *buf = session->lexer.outbuffer + 3;
size_t msg_len = (size_t) getleu16(buf, 1);
uint16_t week = getleu16(buf, 3);
@@ -747,6 +745,8 @@ static gps_mask_t handle_0x86(struct gps_device_t *session)
/* Satellite details */
i = nsu = 0;
for (n = 17; n < msg_len; n += 14) {
+ uint8_t prn, ele, ca_snr, p2_snr, log_channel, hw_channel, s, stat;
+ uint16_t azm, dgps_age;
if (i >= MAXCHANNELS) {
gpsd_report(&session->context->errout, LOG_ERROR,
"Navcom: packet type 0x86: too many satellites!\n");
diff --git a/driver_sirf.c b/driver_sirf.c
index 9ec40e82..10cd8d78 100644
--- a/driver_sirf.c
+++ b/driver_sirf.c
@@ -581,11 +581,10 @@ 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;
- short prn;
int off = 8 + 15 * i;
bool good;
unsigned short stat = (unsigned short)getbeu16(buf, off + 3);
- session->gpsdata.skyview[st].PRN = prn = (short)getub(buf, off);
+ session->gpsdata.skyview[st].PRN = (short)getub(buf, off);
session->gpsdata.skyview[st].azimuth =
(short)(((unsigned)getub(buf, off + 1) * 3) / 2.0);
session->gpsdata.skyview[st].elevation =
diff --git a/driver_tsip.c b/driver_tsip.c
index ebf6a93d..6134e3d9 100644
--- a/driver_tsip.c
+++ b/driver_tsip.c
@@ -128,7 +128,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session)
int i, j, len, count;
gps_mask_t mask = 0;
unsigned int id;
- uint8_t u1, u2, u3, u4, u5, u6, u7;
+ uint8_t u1, u2, u3, u4, u5;
int16_t s1, s2, s3, s4;
int32_t sl1, sl2, sl3;
uint32_t ul1, ul2;
@@ -194,6 +194,7 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session)
*/
u1 = (uint8_t) getub(buf, 0);
if (u1 == 0x81) { /* Software Version Information */
+ uint8_t u6, u7;
u2 = getub(buf, 2); /* Major version */
u3 = getub(buf, 3); /* Minor version */
u4 = getub(buf, 4); /* Build number */
diff --git a/gpsd.c b/gpsd.c
index f2f8e658..40a3952d 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -2218,8 +2218,10 @@ int main(int argc, char *argv[])
/*
* Adaptive delay to prevent buzzing if the tty layer returns data
- * one character at a time and too fast. This has been observed as
- * a problem on the Raspberry Pi. It pushes CPU usage up and eats power.
+ * one character at a time and too fast. This pushes CPU usage up and
+ * eats power. This has been directly observed as a problem on the
+ * Raspberry Pi, and is probably behind occasional reports of
+ * GPSD-related excessive power drain on Android phones.
*/
(void) adaptive_delay();
diff --git a/matrix.c b/matrix.c
index 53fee223..45f524e3 100644
--- a/matrix.c
+++ b/matrix.c
@@ -101,15 +101,16 @@ bool matrix_invert(double mat[4][4], /*@out@*/ double inverse[4][4])
/*@ +fixedformalarray +mustdefine @*/
#ifdef __UNUSED_
+// cppcheck-suppress unusedFunction
void matrix_symmetrize(double mat[4][4], /*@out@*/ double prod[4][4])
/* symmetrize a matrix, multiply it by its transpose */
{
- int i, j, k, n;
+ int i, j, k;
for (i = 0; i < 4; ++i) { //< rows
for (j = 0; j < 4; ++j) { //< cols
prod[i][j] = 0.0;
- for (k = 0; k < n; ++k) {
+ for (k = 0; k < 4; ++k) {
prod[i][j] += mat[k][i] * mat[k][j];
}
}
diff --git a/monitor_garmin.c b/monitor_garmin.c
index bfcc8102..779086d5 100644
--- a/monitor_garmin.c
+++ b/monitor_garmin.c
@@ -57,20 +57,27 @@ typedef struct
/* Receiver Measurement Record */
typedef struct
{
+ // cppcheck-suppress unusedStructMember
uint32_t cycles;
// cppcheck-suppress unusedStructMember
double pr;
+ // cppcheck-suppress unusedStructMember
uint16_t phase;
+ // cppcheck-suppress unusedStructMember
int8_t slp_dtct;
+ // cppcheck-suppress unusedStructMember
uint8_t snr_dbhz;
uint8_t svid;
+ // cppcheck-suppress unusedStructMember
int8_t valid;
} cpo_rcv_sv_data;
typedef struct
{
// cppcheck-suppress unusedStructMember
double rcvr_tow;
+ // cppcheck-suppress unusedStructMember
int16_t rcvr_wn;
+ // cppcheck-suppress unusedStructMember
cpo_rcv_sv_data sv[GARMIN_CHANNELS];
} cpo_rcv_data;
diff --git a/subframe.c b/subframe.c
index 802bfce6..c7c19a4e 100644
--- a/subframe.c
+++ b/subframe.c
@@ -16,7 +16,6 @@ gps_mask_t gpsd_interpret_subframe_raw(struct gps_device_t *session,
{
unsigned int i;
uint8_t preamble;
- uint32_t parity;
if (session->subframe_count++ == 0) {
speed_t speed = gpsd_get_speed(session);
@@ -64,6 +63,7 @@ gps_mask_t gpsd_interpret_subframe_raw(struct gps_device_t *session,
for (i = 1; i < 10; i++) {
int invert;
+ uint32_t parity;
/* D30* says invert */
invert = (words[i] & 0x40000000) ? 1 : 0;
/* inverted data, invert it back */
diff --git a/test_matrix.c b/test_matrix.c
index c6d043fd..eb5ca493 100644
--- a/test_matrix.c
+++ b/test_matrix.c
@@ -69,12 +69,12 @@ static bool check_diag(int n, double a[4][4], double b[4][4])
int main(int argc UNUSED, char *argv[] UNUSED)
{
- size_t i;
+ unsigned int i;
for (i = 0; i < sizeof(inverses) / sizeof(inverses[0]); i++) {
double inverse[4][4];
if (!matrix_invert(inverses[i].mat, inverse)) {
- printf("Vanishing determinant in test %zd\n", i);
+ printf("Vanishing determinant in test %u\n", i);
}
if (!check_diag(i, inverse, inverses[i].inv))
break;