From 6c972e6ba5170d62ac2e1d2abbbdd623c1fc82a2 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Sun, 3 Aug 2014 14:27:33 +0400 Subject: [PATCH] cppcheck warning suppressions --- libuavcan/include/uavcan/build_config.hpp | 2 +- libuavcan/include/uavcan/marshal/float_spec.hpp | 2 +- libuavcan/include/uavcan/marshal/integer_spec.hpp | 2 +- libuavcan/include/uavcan/node/service_server.hpp | 2 +- libuavcan/include/uavcan/node/subscriber.hpp | 2 +- libuavcan/src/marshal/uc_float_spec.cpp | 1 + libuavcan/test/node/test_node.hpp | 5 ++--- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libuavcan/include/uavcan/build_config.hpp b/libuavcan/include/uavcan/build_config.hpp index 1c2ce9e91e..1a686df550 100644 --- a/libuavcan/include/uavcan/build_config.hpp +++ b/libuavcan/include/uavcan/build_config.hpp @@ -168,7 +168,7 @@ struct UAVCAN_EXPORT IsDynamicallyAllocatable { static void check() { - char dummy[(sizeof(T) <= MemPoolBlockSize) ? 1 : -1]; + char dummy[(sizeof(T) <= MemPoolBlockSize) ? 1 : -1] = { '0' }; (void)dummy; } }; diff --git a/libuavcan/include/uavcan/marshal/float_spec.hpp b/libuavcan/include/uavcan/marshal/float_spec.hpp index 5fb1c93e58..f43d5a39da 100644 --- a/libuavcan/include/uavcan/marshal/float_spec.hpp +++ b/libuavcan/include/uavcan/marshal/float_spec.hpp @@ -210,7 +210,7 @@ class UAVCAN_EXPORT YamlStreamer > typedef typename FloatSpec::StorageType StorageType; public: - template + template // cppcheck-suppress passedByValue static void stream(Stream& s, const StorageType value, int) { s << value; diff --git a/libuavcan/include/uavcan/marshal/integer_spec.hpp b/libuavcan/include/uavcan/marshal/integer_spec.hpp index 179aaee3b0..01327b9889 100644 --- a/libuavcan/include/uavcan/marshal/integer_spec.hpp +++ b/libuavcan/include/uavcan/marshal/integer_spec.hpp @@ -153,7 +153,7 @@ class UAVCAN_EXPORT YamlStreamer > typedef typename RawType::StorageType StorageType; public: - template + template // cppcheck-suppress passedByValue static void stream(Stream& s, const StorageType value, int) { // Get rid of character types - we want its integer representation, not ASCII code diff --git a/libuavcan/include/uavcan/node/service_server.hpp b/libuavcan/include/uavcan/node/service_server.hpp index 6130773202..5ca6f970b5 100644 --- a/libuavcan/include/uavcan/node/service_server.hpp +++ b/libuavcan/include/uavcan/node/service_server.hpp @@ -76,7 +76,7 @@ private: uint32_t response_failure_count_; ResponseType response_; - void handleReceivedDataStruct(ReceivedDataStructure& request) + virtual void handleReceivedDataStruct(ReceivedDataStructure& request) { UAVCAN_ASSERT(request.getTransferType() == TransferTypeServiceRequest); if (try_implicit_cast(callback_, true)) diff --git a/libuavcan/include/uavcan/node/subscriber.hpp b/libuavcan/include/uavcan/node/subscriber.hpp index 75ed388fbf..62b15e11b7 100644 --- a/libuavcan/include/uavcan/node/subscriber.hpp +++ b/libuavcan/include/uavcan/node/subscriber.hpp @@ -69,7 +69,7 @@ private: Callback callback_; - void handleReceivedDataStruct(ReceivedDataStructure& msg) + virtual void handleReceivedDataStruct(ReceivedDataStructure& msg) { if (try_implicit_cast(callback_, true)) { diff --git a/libuavcan/src/marshal/uc_float_spec.cpp b/libuavcan/src/marshal/uc_float_spec.cpp index 49bd7c5413..acfaaf65b2 100644 --- a/libuavcan/src/marshal/uc_float_spec.cpp +++ b/libuavcan/src/marshal/uc_float_spec.cpp @@ -41,6 +41,7 @@ static inline bool isnan(T arg) #if UAVCAN_CPP_VERSION >= UAVCAN_CPP11 return std::isnan(arg); #else + // cppcheck-suppress duplicateExpression return arg != arg; #endif } diff --git a/libuavcan/test/node/test_node.hpp b/libuavcan/test/node/test_node.hpp index e287b8e3d5..02edfc3576 100644 --- a/libuavcan/test/node/test_node.hpp +++ b/libuavcan/test/node/test_node.hpp @@ -73,7 +73,7 @@ struct PairableCanDriver : public uavcan::ICanDriver, public uavcan::ICanIface assert(other); if (inout_masks.read == 1) { - inout_masks.read = (read_queue.size() || loopback_queue.size()) ? 1 : 0; + inout_masks.read = (!read_queue.empty() || !loopback_queue.empty()) ? 1 : 0; } if (inout_masks.read || inout_masks.write) { @@ -160,8 +160,7 @@ struct InterlinkedTestNodes nspins2 = nspins2 ? nspins2 : 1; while (nspins2 --> 0) { - int ret = -1; - ret = a.spin(uavcan::MonotonicDuration::fromMSec(1)); + int ret = a.spin(uavcan::MonotonicDuration::fromMSec(1)); if (ret < 0) { return ret;