Skip to content

Commit

Permalink
ultra pedantic warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Nov 21, 2023
1 parent 7fe2615 commit bf78f43
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
6 changes: 5 additions & 1 deletion data_tamer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ endif()
if (MSVC)
add_compile_options(/W4 /WX)
else()
add_compile_options(-Wall -Wextra -Werror -pedantic)
add_compile_options(-Wall -Wcast-align -Wconversion -Wdouble-promotion -Wextra -Wimplicit-fallthrough
-Wno-deprecated-declarations -Wno-ignored-attributes -Wno-unused-parameter
-Wnon-virtual-dtor -Wno-unused-variable -Wnull-dereference -Wold-style-cast
-Woverloaded-virtual -Wshadow -Wsign-conversion
-Werror -Wpedantic)
endif()

find_package(ament_cmake QUIET)
Expand Down
2 changes: 1 addition & 1 deletion data_tamer/benchmarks/data_tamer_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class NullSink : public DataSinkBase

static void DT_TakeSnapshot(benchmark::State& state)
{
std::vector<float> values(state.range(0));
std::vector<float> values(size_t(state.range(0)));

auto channel = ChannelsRegistry::Global().getChannel("channel");
channel->addDataSink(std::make_shared<NullSink>());
Expand Down
4 changes: 2 additions & 2 deletions data_tamer/examples/mcap_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ int main(int argc, char** argv)
for(const auto& [channel_name, msg_counts]: message_counts_per_channel)
{
std::cout << channel_name << ":" << std::endl;
for(const auto& [name, msg_counts]: msg_counts)
for(const auto& [name, count]: msg_counts)
{
std::cout << " " << name << ":" << msg_counts << std::endl;
std::cout << " " << name << ":" << count << std::endl;
}
}
return 0;
Expand Down
2 changes: 1 addition & 1 deletion data_tamer/include/data_tamer_parser/data_tamer_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ inline Schema BuilSchemaFromText(const std::string& txt)
{
// get number
std::string sub_string = line.substr(offset+1, pos - offset);
field.array_size = std::stoi(sub_string);
field.array_size = static_cast<uint16_t>(std::stoi(sub_string));
}
}
offset = line.find(' ', offset);
Expand Down
12 changes: 6 additions & 6 deletions data_tamer/tests/dt_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,24 +192,24 @@ TEST(DataTamer, Disable)
auto id_v6 = channel->registerValue("v6", &v6);
auto id_v7 = channel->registerValue("v7", &v7);

auto expected_size = sizeof(v1) + sizeof(v2) + sizeof(v3) +
sizeof(v4) + sizeof(v5) +
3 * sizeof(double) +
4 * sizeof(float) + sizeof(uint32_t);
size_t expected_size = sizeof(v1) + sizeof(v2) + sizeof(v3) +
sizeof(v4) + sizeof(v5) +
3 * sizeof(double) +
4 * sizeof(float) + sizeof(uint32_t);

channel->takeSnapshot();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
ASSERT_EQ(sink->latest_snapshot.payload.size(), expected_size);
ASSERT_EQ(sink->latest_snapshot.active_mask[0], 0b11111111);

auto checkSize = [&](const auto& id, int size)
auto checkSize = [&](const auto& id, size_t size)
{
channel->setEnabled(id, false);
channel->takeSnapshot();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
channel->setEnabled(id, true);

auto expected = expected_size - size;
size_t expected = expected_size - size;
ASSERT_EQ(sink->latest_snapshot.payload.size(), expected);
};

Expand Down

0 comments on commit bf78f43

Please sign in to comment.