From d44022f30f2444b356e6aeebac0e516c78d5f8b4 Mon Sep 17 00:00:00 2001 From: Audrow Nash Date: Tue, 1 Dec 2020 11:28:44 -0800 Subject: [PATCH] [osrf_testing_tools_cpp] Add warnings (#54) * Add easy warnings Signed-off-by: Audrow Nash --- osrf_testing_tools_cpp/CMakeLists.txt | 4 +++- .../src/memory_tools/stack_trace_impl.hpp | 8 ++++---- .../memory_tools/vendor/bombela/backward-cpp/backward.hpp | 2 +- osrf_testing_tools_cpp/src/test_runner/main.cpp | 2 +- .../test/memory_tools/test_memory_tools.cpp | 4 ++-- .../test/test_runner/assert_env_vars.cpp | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/osrf_testing_tools_cpp/CMakeLists.txt b/osrf_testing_tools_cpp/CMakeLists.txt index 55e5497..190a1cf 100644 --- a/osrf_testing_tools_cpp/CMakeLists.txt +++ b/osrf_testing_tools_cpp/CMakeLists.txt @@ -10,7 +10,9 @@ if(NOT CMAKE_CXX_STANDARD) endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-Wall -Wextra -Wpedantic -Werror) + add_compile_options(-Wall -Wextra -Wpedantic + -Wformat=2 -Wconversion -Woverloaded-virtual + -Wshadow -Wnon-virtual-dtor) endif() add_subdirectory(src) diff --git a/osrf_testing_tools_cpp/src/memory_tools/stack_trace_impl.hpp b/osrf_testing_tools_cpp/src/memory_tools/stack_trace_impl.hpp index feae051..a275c9b 100644 --- a/osrf_testing_tools_cpp/src/memory_tools/stack_trace_impl.hpp +++ b/osrf_testing_tools_cpp/src/memory_tools/stack_trace_impl.hpp @@ -39,8 +39,8 @@ namespace memory_tools struct SourceLocationImpl { SourceLocationImpl() = delete; - explicit SourceLocationImpl(const backward::ResolvedTrace::SourceLoc * source_location) - : source_location(source_location) + explicit SourceLocationImpl(const backward::ResolvedTrace::SourceLoc * sl) + : source_location(sl) {} virtual ~SourceLocationImpl() {} @@ -83,8 +83,8 @@ struct TraceImpl struct StackTraceImpl { StackTraceImpl() = delete; - explicit StackTraceImpl(backward::StackTrace stack_trace, std::thread::id thread_id) - : stack_trace(stack_trace), thread_id(thread_id) + explicit StackTraceImpl(backward::StackTrace st, std::thread::id tid) + : stack_trace(st), thread_id(tid) { trace_resolver.load_stacktrace(stack_trace); traces.reserve(stack_trace.size()); diff --git a/osrf_testing_tools_cpp/src/memory_tools/vendor/bombela/backward-cpp/backward.hpp b/osrf_testing_tools_cpp/src/memory_tools/vendor/bombela/backward-cpp/backward.hpp index 6efa46d..0370ef2 100644 --- a/osrf_testing_tools_cpp/src/memory_tools/vendor/bombela/backward-cpp/backward.hpp +++ b/osrf_testing_tools_cpp/src/memory_tools/vendor/bombela/backward-cpp/backward.hpp @@ -3199,7 +3199,7 @@ class TraceResolverDarwinImpl if (st.size() == 0) { return; } - _symbols.reset(backtrace_symbols(st.begin(), st.size())); + _symbols.reset(backtrace_symbols(st.begin(), static_cast(st.size()))); } ResolvedTrace resolve(ResolvedTrace trace) { diff --git a/osrf_testing_tools_cpp/src/test_runner/main.cpp b/osrf_testing_tools_cpp/src/test_runner/main.cpp index b4812d1..021c006 100644 --- a/osrf_testing_tools_cpp/src/test_runner/main.cpp +++ b/osrf_testing_tools_cpp/src/test_runner/main.cpp @@ -39,7 +39,7 @@ int main(int argc, char const * argv[]) { std::vector args; - args.reserve(argc); + args.reserve(static_cast(argc)); for (int i = 0; i < argc; ++i) { if (i == 0) { continue; diff --git a/osrf_testing_tools_cpp/test/memory_tools/test_memory_tools.cpp b/osrf_testing_tools_cpp/test/memory_tools/test_memory_tools.cpp index e401b10..230a69f 100644 --- a/osrf_testing_tools_cpp/test/memory_tools/test_memory_tools.cpp +++ b/osrf_testing_tools_cpp/test/memory_tools/test_memory_tools.cpp @@ -200,9 +200,9 @@ TEST(TestMemoryTools, test_example) { }, "unexpected malloc"); // There are also explicit begin/end functions if you need variables to leave the scope osrf_testing_tools_cpp::memory_tools::expect_no_malloc_begin(); - int result = my_second_function(1, 2); + int output = my_second_function(1, 2); osrf_testing_tools_cpp::memory_tools::expect_no_malloc_end(); - EXPECT_EQ(result, 3); + EXPECT_EQ(output, 3); // enable monitoring only works in the current thread, but you can enable it for all threads osrf_testing_tools_cpp::memory_tools::enable_monitoring_in_all_threads(); diff --git a/osrf_testing_tools_cpp/test/test_runner/assert_env_vars.cpp b/osrf_testing_tools_cpp/test/test_runner/assert_env_vars.cpp index 974702d..95bce34 100644 --- a/osrf_testing_tools_cpp/test/test_runner/assert_env_vars.cpp +++ b/osrf_testing_tools_cpp/test/test_runner/assert_env_vars.cpp @@ -91,7 +91,7 @@ int main(int argc, char * argv[]) { ::testing::InitGoogleTest(&argc, argv); - g_args.reserve(argc); + g_args.reserve(static_cast(argc)); for (int i = 0; i < argc; ++i) { if (i == 0) { continue;