Skip to content

Commit

Permalink
[osrf_testing_tools_cpp] Add warnings (#54)
Browse files Browse the repository at this point in the history
* Add easy warnings

Signed-off-by: Audrow Nash <audrow.nash@gmail.com>
  • Loading branch information
audrow authored Dec 1, 2020
1 parent 129e75f commit d44022f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
4 changes: 3 additions & 1 deletion osrf_testing_tools_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions osrf_testing_tools_cpp/src/memory_tools/stack_trace_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3199,7 +3199,7 @@ class TraceResolverDarwinImpl<trace_resolver_tag::backtrace_symbol>
if (st.size() == 0) {
return;
}
_symbols.reset(backtrace_symbols(st.begin(), st.size()));
_symbols.reset(backtrace_symbols(st.begin(), static_cast<int>(st.size())));
}

ResolvedTrace resolve(ResolvedTrace trace) {
Expand Down
2 changes: 1 addition & 1 deletion osrf_testing_tools_cpp/src/test_runner/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int
main(int argc, char const * argv[])
{
std::vector<std::string> args;
args.reserve(argc);
args.reserve(static_cast<size_t>(argc));
for (int i = 0; i < argc; ++i) {
if (i == 0) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ int main(int argc, char * argv[])
{
::testing::InitGoogleTest(&argc, argv);

g_args.reserve(argc);
g_args.reserve(static_cast<size_t>(argc));
for (int i = 0; i < argc; ++i) {
if (i == 0) {
continue;
Expand Down

0 comments on commit d44022f

Please sign in to comment.