Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[osrf_testing_tools_cpp] Add warnings #54

Merged
merged 4 commits into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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);
clalancette marked this conversation as resolved.
Show resolved Hide resolved

// 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