Running cppcheck with every build

This commit is contained in:
Pavel Kirienko
2014-02-01 17:04:56 +04:00
parent d77d2967e0
commit b385ffb12e
4 changed files with 25 additions and 3 deletions
+9 -2
View File
@@ -26,7 +26,7 @@ add_library(uavcan SHARED ${LIBUAVCAN_CXX_FILES})
# TODO installation rules # TODO installation rules
# #
# Test # Unit tests with gtest (optional)
# #
find_package(GTest QUIET) find_package(GTest QUIET)
if (GTEST_FOUND) if (GTEST_FOUND)
@@ -47,8 +47,15 @@ if (GTEST_FOUND)
# Tests run automatically upon successful build # Tests run automatically upon successful build
# If failing tests need to be investigated with debugger, use 'make --ignore-errors' # If failing tests need to be investigated with debugger, use 'make --ignore-errors'
add_custom_command(TARGET libuavcan_test POST_BUILD add_custom_command(TARGET libuavcan_test POST_BUILD
COMMAND "./libuavcan_test" COMMAND ./libuavcan_test
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
else (GTEST_FOUND) else (GTEST_FOUND)
message(">> Google test library is not found, you will not be able to run tests") message(">> Google test library is not found, you will not be able to run tests")
endif (GTEST_FOUND) endif (GTEST_FOUND)
#
# Static analysis with cppcheck (required), both library and unit test sources
#
add_custom_command(TARGET uavcan PRE_BUILD
COMMAND ./cppcheck.sh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+10
View File
@@ -0,0 +1,10 @@
#!/bin/sh
#
# cppcheck static analysis
# For Debian based: apt-get install cppcheck
#
# TODO: with future versions of cppcheck, add --library=glibc
cppcheck . --error-exitcode=1 --quiet --enable=all --platform=unix64 --std=c99 --std=c++11 \
--inconclusive --inline-suppr --force --template=gcc \
-Iinclude $@
+3 -1
View File
@@ -30,7 +30,9 @@ struct CanFrame
CanFrame() CanFrame()
: id(0) : id(0)
, dlc(0) , dlc(0)
{ } {
std::memset(data, 0, sizeof(data));
}
CanFrame(uint32_t id, const uint8_t* data, unsigned int dlc) CanFrame(uint32_t id, const uint8_t* data, unsigned int dlc)
: id(id) : id(id)
+3
View File
@@ -82,7 +82,10 @@ public:
return 1; return 1;
} }
// cppcheck-suppress unusedFunction
// cppcheck-suppress functionConst
int configureFilters(const uavcan::CanFilterConfig* filter_configs, int num_configs) { return -1; } int configureFilters(const uavcan::CanFilterConfig* filter_configs, int num_configs) { return -1; }
// cppcheck-suppress unusedFunction
int getNumFilters() const { return 0; } int getNumFilters() const { return 0; }
uint64_t getNumErrors() const { return num_errors; } uint64_t getNumErrors() const { return num_errors; }
}; };