From 944914be5fcb4c176279a8fc8cd14a07eeb46822 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 19 Nov 2013 16:11:52 -0500 Subject: Code is now static-checker clean with splint, cppcheck, and Coverity. All regression tests pass. PPS is live. --- SConstruct | 6 ++++-- driver_garmin.c | 6 +++++- gpsmon.c | 4 ++-- isgps.c | 2 ++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/SConstruct b/SConstruct index f731c89a..d0b4e654 100644 --- a/SConstruct +++ b/SConstruct @@ -1447,8 +1447,10 @@ splint_table = [ for (target,sources,description,params) in splint_table: env.Alias('splint',Splint(target,sources,description,params)) +# Putting in all these -U flags speeds up cppcheck and allows it to look +# at configurations we actually care about. Utility("cppcheck", ["gpsd.h", "packet_names.h"], - "cppcheck -U__UNUSED__ -UAF_UNSPEC -UINADDR_ANY -UFIXED_PORT_SPEED -UFIXED_STOP_BITS -U_WIN32 -U__CYGWIN__ --template gcc --enable=all --inline-suppr --suppress='*:driver_proto.c' --force $SRCDIR") + "cppcheck -U__UNUSED__ -US_SPLINT_S -U__COVERITY__ -U__future__ -ULIMITED_MAX_CLIENTS -ULIMITED_MAX_DEVICES -UAF_UNSPEC -UINADDR_ANY -UFIXED_PORT_SPEED -UFIXED_STOP_BITS -U_WIN32 -U__CYGWIN__ -UPATH_MAX -UHAVE_STRLCAT -UHAVE_STRLCPY --template gcc --enable=all --inline-suppr --suppress='*:driver_proto.c' --force $SRCDIR") # Experimental check with clang analyzer Utility("scan-build", ["gpsd.h", "packet_names.h"], @@ -1456,7 +1458,7 @@ Utility("scan-build", ["gpsd.h", "packet_names.h"], # Sanity-check Python code. pylint = Utility("pylint", ["jsongen.py", "maskaudit.py", python_built_extensions], - ['''pylint --output-format=parseable --reports=n --include-ids=y --disable=F0001,C0103,C0111,C0301,C0302,C0322,C0324,C0323,C0321,R0201,R0801,R0902,R0903,R0904,R0911,R0912,R0913,R0914,R0915,R0924,W0201,W0401,W0403,W0141,W0142,W0603,W0614,W0621,E1101,E1102 jsongen.py leapsecond.py maskaudit.py gpsprof.py gpscat.py gpsfake.py gegps.py gps/*.py xgps''']) + ['''pylint --output-format=parseable --reports=n --include-ids=y --disable=F0001,C0103,C0111,C0301,C0302,C0322,C0324,C0323,C0321,R0201,R0801,R0902,R0903,R0904,R0911,R0912,R0913,R0914,R0915,R0924,W0201,W0401,W0403,W0141,W0142,W0603,W0614,W0621,E1101,E1102,F0401 jsongen.py leapsecond.py maskaudit.py gpsprof.py gpscat.py gpsfake.py gegps.py gps/*.py xgps''']) # Check the documentation for bogons, too Utility("xmllint", glob.glob("*.xml"), diff --git a/driver_garmin.c b/driver_garmin.c index e3768e85..f6e46155 100644 --- a/driver_garmin.c +++ b/driver_garmin.c @@ -622,8 +622,10 @@ gps_mask_t PrintSERPacket(struct gps_device_t *session, unsigned char pkt_id, /*@ -branchstate @*/ -// For debugging, decodes and prints some known packets. +// This works around cppcheck not looking into enough config branches +// cppcheck-suppress unusedFunction static gps_mask_t PrintUSBPacket(struct gps_device_t *session, Packet_t * pkt) +/* For debugging, decodes and prints some known packets */ { gps_mask_t mask = 0; int maj_ver; @@ -844,6 +846,8 @@ static void Build_Send_SER_Packet(struct gps_device_t *session, * libudev: http://www.kernel.org/pub/linux/utils/kernel/hotplug/libudev/ */ /*@-compdef -usedef -nullpass@*/ +// This works around cppcheck not looking into enough config branches +// cppcheck-suppress unusedFunction static bool is_usb_device(const char *path UNUSED, int vendor, int product, const int debug) { diff --git a/gpsmon.c b/gpsmon.c index 667019c1..88d05c48 100644 --- a/gpsmon.c +++ b/gpsmon.c @@ -325,13 +325,13 @@ void monitor_log(const char *fmt, ...) } } -static const char *promptgen(void) +static /*@observer@*/ const char *promptgen(void) { static char buf[sizeof(session.gpsdata.dev.path)]; if (serial) (void)snprintf(buf, sizeof(buf), - "%s %u %d%c%d", + "%s %u %u%c%u", session.gpsdata.dev.path, session.gpsdata.dev.baudrate, 9 - session.gpsdata.dev.stopbits, diff --git a/isgps.c b/isgps.c index 1e094f26..59d48699 100644 --- a/isgps.c +++ b/isgps.c @@ -177,6 +177,8 @@ void isgps_init( /*@out@*/ struct gps_packet_t *session) } /*@ -usereleased -compdef @*/ +// This works around cppcheck not looking into enough config branches +// cppcheck-suppress unusedFunction enum isgpsstat_t isgps_decode(struct gps_packet_t *session, bool(*preamble_match) (isgps30bits_t *), bool(*length_check) (struct gps_packet_t *), -- cgit v1.2.1