diff --git a/bacnet-stack/splint.sh b/bacnet-stack/splint.sh new file mode 100755 index 00000000..2e8a47df --- /dev/null +++ b/bacnet-stack/splint.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# splint is a static code checker +[ -x /usr/bin/splint ] || exit 0 + +INCLUDES="-Iinclude -Idemo/handler -Idemo/object -Iports/linux" + +directory=${1-`pwd`} +for filename in $( find $directory -name '*.c' ) +do + echo splinting ${filename} + /usr/bin/splint ${INCLUDES} ${filename} +done + diff --git a/bacnet-stack/src/abort.c b/bacnet-stack/src/abort.c index 5d78ff3d..6f998b64 100644 --- a/bacnet-stack/src/abort.c +++ b/bacnet-stack/src/abort.c @@ -61,7 +61,7 @@ int abort_decode_service_request(uint8_t * apdu, { int len = 0; - if (apdu_len) { + if (apdu_len > 0) { if (invoke_id) *invoke_id = apdu[0]; if (abort_reason) @@ -86,7 +86,7 @@ int abort_decode_apdu(uint8_t * apdu, if (!apdu) return -1; /* optional checking - most likely was already done prior to this call */ - if (apdu_len) { + if (apdu_len > 0) { if ((apdu[0] & 0xF0) != PDU_TYPE_ABORT) return -1; if (apdu[0] & 1) diff --git a/bacnet-stack/src/apdu.c b/bacnet-stack/src/apdu.c index a328502a..9269b542 100644 --- a/bacnet-stack/src/apdu.c +++ b/bacnet-stack/src/apdu.c @@ -116,9 +116,7 @@ void apdu_set_unrecognized_service_handler_handler(confirmed_function /* Unconfirmed Function Handlers */ /* If they are not set, they are not handled */ static unconfirmed_function - Unconfirmed_Function[MAX_BACNET_UNCONFIRMED_SERVICE] = { - NULL -}; + Unconfirmed_Function[MAX_BACNET_UNCONFIRMED_SERVICE]; void apdu_set_unconfirmed_handler(BACNET_UNCONFIRMED_SERVICE service_choice, unconfirmed_function pFunction)