summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2017-09-06 19:00:04 -0400
committerEric S. Raymond <esr@thyrsus.com>2017-09-06 19:00:04 -0400
commit9c7e8629876fb3ff115902e37fe562641ce9de11 (patch)
tree08ca2e4206ccc0dbda2ee946d907763ae9166aab
parentdb56959e1cf2670edb02f27f25580bb4272e9df2 (diff)
downloadgpsd-9c7e8629876fb3ff115902e37fe562641ce9de11.tar.gz
Clean up C and Python code-checker warnings.
-rw-r--r--SConstruct13
-rw-r--r--contrib/motosend.c3
-rw-r--r--driver_garmin.c2
-rw-r--r--driver_nmea0183.c4
-rw-r--r--driver_skytraq.c1
-rw-r--r--drivers.c3
-rw-r--r--gpsd.c1
-rw-r--r--gpsdclient.c3
-rw-r--r--libgpsd_core.c2
-rw-r--r--netlib.c6
-rw-r--r--ppsthread.c1
-rw-r--r--test_float.c3
-rw-r--r--test_mktime.c3
-rwxr-xr-xxgpsspeed8
14 files changed, 30 insertions, 23 deletions
diff --git a/SConstruct b/SConstruct
index 319f1bbc..03d591fd 100644
--- a/SConstruct
+++ b/SConstruct
@@ -1754,7 +1754,7 @@ Utility("scan-build", ["gpsd.h", "packet_names.h"],
"scan-build scons")
# Sanity-check Python code.
-# Bletch. We don't really want to suppress W0231 E0602 E0611, but Python 3
+# Bletch. We don't really want to suppress W0231 E0602 E0611 E1123, but Python 3
# syntax confuses a pylint running under Python 2.
if len(python_progs) > 0:
pylint = Utility(
@@ -1762,11 +1762,12 @@ if len(python_progs) > 0:
['''pylint --rcfile=/dev/null --dummy-variables-rgx='^_' '''
'''--msg-template='''
'''"{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" '''
- '''--reports=n --disable=F0001,C0103,C0111,C1001,C0301,'''
- '''C0302,C0322,C0324,C0323,C0321,C0330,R0201,R0801,R0902,R0903,'''
- '''R0904,R0911,R0912,R0913,R0914,R0915,W0110,W0201,W0121,W0123,'''
- '''W0231,W0232,W0234,W0401,W0403,W0141,W0142,W0603,W0614,W0640,'''
- '''W0621,W1504,E0602,E0611,E1101,E1102,E1103,F0401,I0011 '''
+ '''--reports=n --disable=F0001,C0103,C0111,C1001,C0301,C0302,'''
+ '''C0322,C0324,C0323,C0321,C0330,C0411,C0413,R0201,R0204,R0801,'''
+ '''R0902,R0903,R0904,R0911,R0912,R0913,R0914,R0915,W0110,W0201,'''
+ '''W0121,W0123,W0231,W0232,W0234,W0401,W0403,W0141,W0142,W0603,'''
+ '''W0614,W0640,W0621,W1504,E0602,E0611,E1101,E1102,E1103,E1123,'''
+ '''F0401,I0011 '''
'''gps/*.py *.py '''
+ " ".join(python_progs)])
diff --git a/contrib/motosend.c b/contrib/motosend.c
index 1f2a25ca..c1d555d3 100644
--- a/contrib/motosend.c
+++ b/contrib/motosend.c
@@ -31,7 +31,7 @@ int main(int argc, char **argv) {
int speed, l, fd, n;
struct termios term;
char buf[BSIZ];
- time_t s, t;
+ time_t t;
struct timespec delay;
if (argc != 5){
@@ -84,6 +84,7 @@ int main(int argc, char **argv) {
tcflush(fd, TCIOFLUSH);
t = 0; n = 0;
while (1){
+ time_t s;
/* wait 1,000 uSec */
delay.tv_sec = 0;
delay.tv_nsec = 1000000L;
diff --git a/driver_garmin.c b/driver_garmin.c
index 4ecb960b..46d3d0ad 100644
--- a/driver_garmin.c
+++ b/driver_garmin.c
@@ -236,7 +236,7 @@ typedef struct __attribute__((__packed__))
union
{
//int8_t chars[MAX_BUFFER_SIZE];
- uint8_t uchars[MAX_BUFFER_SIZE];
+ //uint8_t uchars[MAX_BUFFER_SIZE];
cpo_pvt_data pvt;
cpo_sat_data sats;
} mData;
diff --git a/driver_nmea0183.c b/driver_nmea0183.c
index 58a61156..94cf4dc3 100644
--- a/driver_nmea0183.c
+++ b/driver_nmea0183.c
@@ -1800,7 +1800,7 @@ gps_mask_t nmea_parse(char *sentence, struct gps_device_t * session)
int count;
gps_mask_t retval = 0;
unsigned int i, thistag;
- char *p, *s, *e;
+ char *p, *e;
volatile char *t;
#ifdef SKYTRAQ_ENABLE
bool skytraq_sti = false;
@@ -1866,7 +1866,7 @@ gps_mask_t nmea_parse(char *sentence, struct gps_device_t * session)
/* dispatch on field zero, the sentence tag */
for (thistag = i = 0;
i < (unsigned)(sizeof(nmea_phrase) / sizeof(nmea_phrase[0])); ++i) {
- s = session->nmea.field[0];
+ char *s = session->nmea.field[0];
if (strlen(nmea_phrase[i].name) == 3
#ifdef SKYTRAQ_ENABLE
/* $STI is special */
diff --git a/driver_skytraq.c b/driver_skytraq.c
index 14169d58..3b7e8136 100644
--- a/driver_skytraq.c
+++ b/driver_skytraq.c
@@ -48,6 +48,7 @@ static unsigned char versionprobe[] = {
0x00, 0x0d, 0x0a
};
+// cppcheck-suppress unusedFunction
static bool sky_write(struct gps_device_t *session, unsigned char *msg)
{
unsigned int crc;
diff --git a/drivers.c b/drivers.c
index ebbcc6d6..f1057ca8 100644
--- a/drivers.c
+++ b/drivers.c
@@ -1608,7 +1608,7 @@ static void path_rewrite(struct gps_device_t *session, char *prefix)
* beginning of the path attribute, followed by a # to separate it
* from the device.
*/
- char *prefloc, *sfxloc;
+ char *prefloc;
assert(prefix != NULL && session->lexer.outbuffer != NULL);
@@ -1620,6 +1620,7 @@ static void path_rewrite(struct gps_device_t *session, char *prefix)
prefloc < (char *)session->lexer.outbuffer+session->lexer.outbuflen;
prefloc++)
if (str_starts_with(prefloc, prefix)) {
+ char *sfxloc;
char copy[sizeof(session->lexer.outbuffer)+1];
(void)strlcpy(copy,
(char *)session->lexer.outbuffer,
diff --git a/gpsd.c b/gpsd.c
index 7a693ef0..ac6ce5d5 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -1774,6 +1774,7 @@ static void netgnss_autoconnect(struct gps_context_t *context,
sp->dist = DGPS_THRESHOLD;
sp->server[0] = '\0';
}
+ hold.lat = hold.lon = 0;
while (fgets(buf, (int)sizeof(buf), sfp)) {
char *cp = strchr(buf, '#');
if (cp != NULL)
diff --git a/gpsdclient.c b/gpsdclient.c
index 6d06b2d1..41f7f1e5 100644
--- a/gpsdclient.c
+++ b/gpsdclient.c
@@ -43,7 +43,6 @@ char *deg_to_str(enum deg_str_type type, double f)
{
static char str[40];
int dsec, sec, deg, min;
- long frac_deg;
double fdsec, fsec, fdeg, fmin;
if (f < 0 || f > 360) {
@@ -57,7 +56,7 @@ char *deg_to_str(enum deg_str_type type, double f)
if (deg_dd == type) {
/* DD.dddddddd */
/* cm level accuracy requires the %08ld */
- frac_deg = (long)(fmin * 100000000);
+ long frac_deg = (long)(fmin * 100000000);
(void)snprintf(str, sizeof(str), "%3d.%08ld", deg, frac_deg);
return str;
}
diff --git a/libgpsd_core.c b/libgpsd_core.c
index ddb22a6d..77992f35 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -230,7 +230,6 @@ static void gpsd_run_device_hook(struct gpsd_errout_t *errout,
char *device_name, char *hook)
{
struct stat statbuf;
- char buf[HOOK_CMD_MAX];
if (stat(DEVICEHOOKPATH, &statbuf) == -1)
gpsd_log(errout, LOG_PROG,
@@ -238,6 +237,7 @@ static void gpsd_run_device_hook(struct gpsd_errout_t *errout,
DEVICEHOOKPATH, hook);
else {
int status;
+ char buf[HOOK_CMD_MAX];
(void)snprintf(buf, sizeof(buf), "%s %s %s",
DEVICEHOOKPATH, device_name, hook);
gpsd_log(errout, LOG_INF, "running %s\n", buf);
diff --git a/netlib.c b/netlib.c
index 2939454d..4da16aaf 100644
--- a/netlib.c
+++ b/netlib.c
@@ -210,8 +210,8 @@ char *netlib_sock2ip(socket_t fd)
/* retrieve the IP address corresponding to a socket */
{
static char ip[INET6_ADDRSTRLEN];
- int r = 1;
#ifdef HAVE_INET_NTOP
+ int r;
sockaddr_t fsin;
socklen_t alen = (socklen_t) sizeof(fsin);
r = getpeername(fd, &(fsin.sa), &alen);
@@ -232,9 +232,9 @@ char *netlib_sock2ip(socket_t fd)
return ip;
}
}
+ /* Ugh... */
+ if (r != 0)
#endif /* HAVE_INET_NTOP */
- if (r != 0) {
(void)strlcpy(ip, "<unknown>", sizeof(ip));
- }
return ip;
}
diff --git a/ppsthread.c b/ppsthread.c
index cd6c883c..6819c6f1 100644
--- a/ppsthread.c
+++ b/ppsthread.c
@@ -1031,6 +1031,7 @@ static void *gpsd_ppsmonitor(void *arg)
* pulse shorter than 500 milliSec + 10%
* looks like 1.0 Hz square wave, ignore trailing edge
* except we can't tell which is which, so we guess */
+ // cppcheck-suppress knownConditionTrueFalse
if (edge == 1) {
ok = true;
log = "square\n";
diff --git a/test_float.c b/test_float.c
index cc99d4a1..df5a0e7d 100644
--- a/test_float.c
+++ b/test_float.c
@@ -275,6 +275,7 @@ int test_modulo(void) {
a = -5;
b = 2;
+ //cppcheck-suppress comparisonError
if (a % b != -1) {
printf("m1 ");
e++;
@@ -282,6 +283,7 @@ int test_modulo(void) {
a = -5;
b = -2;
+ //cppcheck-suppress comparisonError
if (a % b != -1) {
printf("m2 ");
e++;
@@ -289,6 +291,7 @@ int test_modulo(void) {
a = 5;
b = -2;
+ //cppcheck-suppress comparisonError
if (a % b != 1) {
printf("m3 ");
e++;
diff --git a/test_mktime.c b/test_mktime.c
index 878812d8..cf07dc55 100644
--- a/test_mktime.c
+++ b/test_mktime.c
@@ -86,13 +86,12 @@ int main(int argc UNUSED, char *argv[] UNUSED)
{
int i;
char tbuf[128];
- time_t ts;
bool failed = false;
(void)setenv("TZ", "GMT", 1);
for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i++) {
- ts = mktime(&tests[i].t);
+ time_t ts = mktime(&tests[i].t);
if (ts != tests[i].result) {
failed = true;
(void)strftime(tbuf, sizeof(tbuf), "%F %T", &tests[i].t);
diff --git a/xgpsspeed b/xgpsspeed
index 6f86627e..936fc65c 100755
--- a/xgpsspeed
+++ b/xgpsspeed
@@ -787,12 +787,12 @@ if __name__ == '__main__':
sys.exit(0)
target = ':'.join(args[0:])
elif options.host or options.port or options.device:
- target = [options.host or 'localhost']
+ ltarget = [options.host or 'localhost']
if options.port or options.device:
- target += [options.port or '']
+ ltarget += [options.port or '']
if options.device:
- target += [options.device]
- target = ':'.join(target)
+ ltarget += [options.device]
+ target = ':'.join(ltarget)
else:
target = ""
Main(