diff --git a/common/include/villas/exceptions.hpp b/common/include/villas/exceptions.hpp index afe8a88ad..79c4f4ed1 100644 --- a/common/include/villas/exceptions.hpp +++ b/common/include/villas/exceptions.hpp @@ -101,6 +101,8 @@ protected: json_t *setting; json_error_t error; + std::string msg; + public: template ConfigError(json_t *s, const std::string &i, const std::string &what = "Failed to parse configuration") : @@ -143,18 +145,17 @@ public: virtual const char * what() const noexcept { - std::stringstream ss; + if (msg.empty()) { + std::stringstream ss; - ss << std::runtime_error::what() << std::endl; - ss << " Please consult the user documentation for details: " << docUri(); + ss << std::runtime_error::what() << std::endl; + ss << " Please consult the user documentation for details: " << docUri(); - if (error.position >= 0) { - ss << std::endl << " " << error.text << " in " << error.source << ":" << error.line << ":" << error.column; + if (error.position >= 0) + ss << std::endl << " " << error.text << " in " << error.source << ":" << error.line << ":" << error.column; } - auto str = new std::string(ss.str()); - - return str->c_str(); + return msg.c_str(); } }; diff --git a/common/include/villas/table.hpp b/common/include/villas/table.hpp index fa52e2055..27729e088 100644 --- a/common/include/villas/table.hpp +++ b/common/include/villas/table.hpp @@ -49,6 +49,7 @@ protected: public: TableColumn(int w, enum Alignment a, const std::string &t, const std::string &f, const std::string &u = "") : + _width(0), width(w), title(t), format(f), diff --git a/common/tests/unit/advio.cpp b/common/tests/unit/advio.cpp index ce4e2c631..a97e282a4 100644 --- a/common/tests/unit/advio.cpp +++ b/common/tests/unit/advio.cpp @@ -33,6 +33,7 @@ using namespace villas; * The Sciebo share is read/write accessible via WebDAV. */ #define BASE_URI "https://1Nrd46fZX8HbggT:badpass@rwth-aachen.sciebo.de/public.php/webdav/node/tests" +// cppcheck-suppress unknownMacro TestSuite(advio, .description = "Advanced file IO" ); diff --git a/common/tests/unit/base64.cpp b/common/tests/unit/base64.cpp index 4ffe3b8ae..7ea4cea7f 100644 --- a/common/tests/unit/base64.cpp +++ b/common/tests/unit/base64.cpp @@ -28,6 +28,7 @@ using namespace villas::utils::base64; +// cppcheck-suppress unknownMacro TestSuite(base64, .description = "Base64 En/decoder"); static std::vector vec(const char *str) diff --git a/common/tests/unit/graph.cpp b/common/tests/unit/graph.cpp index 6a560ab7a..cc7f1f232 100644 --- a/common/tests/unit/graph.cpp +++ b/common/tests/unit/graph.cpp @@ -29,6 +29,7 @@ using namespace villas; +// cppcheck-suppress unknownMacro TestSuite(graph, .description = "Graph library"); Test(graph, basic, .description = "DirectedGraph") diff --git a/common/tests/unit/hist.cpp b/common/tests/unit/hist.cpp index ee7a57ed6..d020f9fba 100644 --- a/common/tests/unit/hist.cpp +++ b/common/tests/unit/hist.cpp @@ -31,6 +31,7 @@ const std::array test_data = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; using namespace villas; +// cppcheck-suppress unknownMacro TestSuite(hist, .description = "Histogram"); Test(hist, simple) { diff --git a/common/tests/unit/json_buffer.cpp b/common/tests/unit/json_buffer.cpp index 6f2b0af68..e90863654 100644 --- a/common/tests/unit/json_buffer.cpp +++ b/common/tests/unit/json_buffer.cpp @@ -32,6 +32,7 @@ using namespace villas; using villas::JsonBuffer; +// cppcheck-suppress unknownMacro TestSuite(buffer, .description = "Buffer datastructure"); Test(json_buffer, decode) diff --git a/common/tests/unit/kernel.cpp b/common/tests/unit/kernel.cpp index 9d5aa0009..a77953e5a 100644 --- a/common/tests/unit/kernel.cpp +++ b/common/tests/unit/kernel.cpp @@ -26,6 +26,7 @@ using namespace villas::kernel; +// cppcheck-suppress unknownMacro TestSuite(kernel, .description = "Kernel features"); #if defined(__x86_64__) || defined(__i386__) diff --git a/common/tests/unit/list.cpp b/common/tests/unit/list.cpp index 7d54815ec..56997074e 100644 --- a/common/tests/unit/list.cpp +++ b/common/tests/unit/list.cpp @@ -37,6 +37,7 @@ struct data { int data; }; +// cppcheck-suppress unknownMacro TestSuite(list, .description = "List datastructure"); Test(list, vlist_lookup_name) diff --git a/common/tests/unit/popen.cpp b/common/tests/unit/popen.cpp index ec10b71ae..4889043a3 100644 --- a/common/tests/unit/popen.cpp +++ b/common/tests/unit/popen.cpp @@ -27,6 +27,7 @@ using namespace villas::utils; +// cppcheck-suppress unknownMacro TestSuite(popen, .description = "Bi-directional popen"); Test(popen, no_shell) diff --git a/common/tests/unit/task.cpp b/common/tests/unit/task.cpp index b10200dfd..9c60b00f9 100644 --- a/common/tests/unit/task.cpp +++ b/common/tests/unit/task.cpp @@ -27,6 +27,7 @@ #include #include +// cppcheck-suppress unknownMacro TestSuite(task, .description = "Periodic timer tasks"); Test(task, rate, .timeout = 10) diff --git a/common/tests/unit/timing.cpp b/common/tests/unit/timing.cpp index 00345d449..b6233f0c2 100644 --- a/common/tests/unit/timing.cpp +++ b/common/tests/unit/timing.cpp @@ -26,6 +26,7 @@ #include +// cppcheck-suppress unknownMacro TestSuite(timing, .description = "Time measurements"); Test(timing, time_now) diff --git a/common/tests/unit/tsc.cpp b/common/tests/unit/tsc.cpp index c73e7392d..5fa47f7fd 100644 --- a/common/tests/unit/tsc.cpp +++ b/common/tests/unit/tsc.cpp @@ -28,6 +28,7 @@ #define CNT (1 << 18) +// cppcheck-suppress unknownMacro TestSuite(tsc, .description = "Timestamp counters"); Test(tsc, increasing) diff --git a/common/tests/unit/utils.cpp b/common/tests/unit/utils.cpp index b0ffba2ae..86f2649ce 100644 --- a/common/tests/unit/utils.cpp +++ b/common/tests/unit/utils.cpp @@ -30,6 +30,7 @@ using namespace villas::utils; +// cppcheck-suppress unknownMacro TestSuite(utils, .description = "Utilities"); /* Simple normality test for 1,2,3s intervals */