From 17f96b837e5aec95ee2e6b00a1ebaa25330ea2f3 Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Wed, 5 Jun 2019 19:58:47 +0300 Subject: [PATCH] More linux warning removals --- CMakeLists.txt | 2 +- components/common/cpp/include/loguru.hpp | 2 +- components/common/cpp/src/configuration.cpp | 1 + components/common/cpp/src/loguru.cpp | 3 ++- components/net/cpp/include/ftl/net/peer.hpp | 1 + components/net/cpp/test/peer_unit.cpp | 8 ++++---- components/rgbd-sources/include/ftl/rgbd_source.hpp | 3 ++- components/rgbd-sources/src/disparity.hpp | 1 + 8 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b81d81565..54cae954b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,7 +125,7 @@ check_include_file_cxx("opencv2/cudastereo.hpp" HAVE_OPENCVCUDA) find_program(CPPCHECK_FOUND cppcheck) if (CPPCHECK_FOUND) message(STATUS "Found cppcheck: will perform source checks") - set(CMAKE_CXX_CPPCHECK "cppcheck" "--enable=style" "--suppress=*:*catch.hpp" "--suppress=*:*elas*" "--suppress=*:*json.hpp") + set(CMAKE_CXX_CPPCHECK "cppcheck" "--enable=warning,performance,portability,style" "--inline-suppr" "--std=c++11" "--suppress=*:*catch.hpp" "--suppress=*:*elas*" "--suppress=*:*json.hpp" "--quiet") endif() # include_directories(${PROJECT_SOURCE_DIR}/common/cpp/include) diff --git a/components/common/cpp/include/loguru.hpp b/components/common/cpp/include/loguru.hpp index 2bfe8e0e2..ec3dc9746 100644 --- a/components/common/cpp/include/loguru.hpp +++ b/components/common/cpp/include/loguru.hpp @@ -536,7 +536,7 @@ namespace loguru class LOGURU_EXPORT LogScopeRAII { public: - LogScopeRAII() : _file(nullptr) {} // No logging + LogScopeRAII() : _file(nullptr), _line(0), _indent_stderr(false), _start_time_ns(0), _name({}) {} // No logging LogScopeRAII(Verbosity verbosity, const char* file, unsigned line, LOGURU_FORMAT_STRING_TYPE format, ...) LOGURU_PRINTF_LIKE(5, 6); ~LogScopeRAII(); diff --git a/components/common/cpp/src/configuration.cpp b/components/common/cpp/src/configuration.cpp index 3f1bcd213..c4369bd00 100644 --- a/components/common/cpp/src/configuration.cpp +++ b/components/common/cpp/src/configuration.cpp @@ -143,6 +143,7 @@ static bool mergeConfig(const string path) { } catch (...) { LOG(ERROR) << "Unknown error opening config file"; } + return false; } else { return false; } diff --git a/components/common/cpp/src/loguru.cpp b/components/common/cpp/src/loguru.cpp index 7e2c748ed..b481a411e 100644 --- a/components/common/cpp/src/loguru.cpp +++ b/components/common/cpp/src/loguru.cpp @@ -510,6 +510,7 @@ namespace loguru Text errno_as_text() { + // cppcheck-suppress unusedVariable char buff[256]; #if defined(__GLIBC__) && defined(_GNU_SOURCE) // GNU Version @@ -1069,7 +1070,7 @@ namespace loguru i - skip, int(2 + sizeof(void*) * 2), callstack[i], status == 0 ? demangled : info.dli_sname == 0 ? symbols[i] : info.dli_sname, - static_cast<char*>(callstack[i]) - static_cast<char*>(info.dli_saddr)); + (ssize_t)(static_cast<char*>(callstack[i]) - static_cast<char*>(info.dli_saddr))); free(demangled); } else { snprintf(buf, sizeof(buf), "%-3d %*p %s\n", diff --git a/components/net/cpp/include/ftl/net/peer.hpp b/components/net/cpp/include/ftl/net/peer.hpp index 07cffaf51..6d28d3b84 100644 --- a/components/net/cpp/include/ftl/net/peer.hpp +++ b/components/net/cpp/include/ftl/net/peer.hpp @@ -269,6 +269,7 @@ R Peer::call(const std::string &name, ARGS... args) { template <typename T, typename... ARGS> int Peer::asyncCall( const std::string &name, + // cppcheck-suppress * std::function<void(const T&)> cb, ARGS... args) { auto args_obj = std::make_tuple(args...); diff --git a/components/net/cpp/test/peer_unit.cpp b/components/net/cpp/test/peer_unit.cpp index dd846a961..d72d96791 100644 --- a/components/net/cpp/test/peer_unit.cpp +++ b/components/net/cpp/test/peer_unit.cpp @@ -238,8 +238,8 @@ TEST_CASE("Peer::call()", "[rpc]") { std::thread thr([&s]() { while (fakedata[0].size() == 0) std::this_thread::sleep_for(std::chrono::milliseconds(20)); - auto [id,value] = readRPC<tuple<>>(0); - auto res_obj = std::make_tuple(1,id,"__return__",77); + auto res = readRPC<tuple<>>(0); + auto res_obj = std::make_tuple(1,std::get<0>(res),"__return__",77); std::stringstream buf; msgpack::pack(buf, res_obj); fakedata[0] = buf.str(); @@ -263,9 +263,9 @@ TEST_CASE("Peer::call()", "[rpc]") { std::thread thr([&s]() { while (fakedata[0].size() == 0) std::this_thread::sleep_for(std::chrono::milliseconds(20)); - auto [id,value] = readRPC<tuple<>>(0); + auto res = readRPC<tuple<>>(0); vector<int> data = {44,55,66}; - auto res_obj = std::make_tuple(1,id,"__return__",data); + auto res_obj = std::make_tuple(1,std::get<0>(res),"__return__",data); std::stringstream buf; msgpack::pack(buf, res_obj); fakedata[0] = buf.str(); diff --git a/components/rgbd-sources/include/ftl/rgbd_source.hpp b/components/rgbd-sources/include/ftl/rgbd_source.hpp index e6ca35418..aa5748324 100644 --- a/components/rgbd-sources/include/ftl/rgbd_source.hpp +++ b/components/rgbd-sources/include/ftl/rgbd_source.hpp @@ -19,7 +19,7 @@ namespace rgbd { */ class RGBDSource : public ftl::Configurable { public: - RGBDSource(nlohmann::json &config); + explicit RGBDSource(nlohmann::json &config); RGBDSource(nlohmann::json &config, ftl::net::Universe *net); virtual ~RGBDSource(); @@ -57,6 +57,7 @@ class RGBDSource : public ftl::Configurable { */ class Register { public: + // cppcheck-suppress * Register(const std::string &n, std::function<RGBDSource*(nlohmann::json&,ftl::net::Universe*)> f) { RGBDSource::_register(n,f); }; diff --git a/components/rgbd-sources/src/disparity.hpp b/components/rgbd-sources/src/disparity.hpp index c8e363692..cb25e2895 100644 --- a/components/rgbd-sources/src/disparity.hpp +++ b/components/rgbd-sources/src/disparity.hpp @@ -37,6 +37,7 @@ class Disparity : public ftl::Configurable { */ class Register { public: + // cppcheck-suppress * Register(const std::string &n, std::function<Disparity*(ftl::Configurable *, const std::string &)> f) { Disparity::_register(n,f); }; -- GitLab