Skip to content

Commit

Permalink
Avoid g++ false werrors
Browse files Browse the repository at this point in the history
  • Loading branch information
kyechou committed Jul 24, 2024
1 parent 1c8aef9 commit 77d969c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
6 changes: 6 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ target_link_libraries(neotests PRIVATE
tomlplusplus::tomlplusplus
)

# # NOTE: Add `-Wno-maybe-uninitialized` for g++ because g++ doesn't work well
# # with Catch2 macros. Consider removing this if later switching to googletest.
# if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# target_compile_options(neotests PRIVATE -Wno-maybe-uninitialized)
# endif()

# target_link_libraries(main PRIVATE GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main)

# add_custom_target(neotests-setcap ALL
Expand Down
4 changes: 2 additions & 2 deletions tests/driver/docker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ TEST_CASE("docker") {
mutex mtx; // lock for recv_pkts
condition_variable cv; // for reading recv_pkts
unique_lock<mutex> lck(mtx);
Interface *eth0;
Interface *eth1;
Interface *eth0 = nullptr;
Interface *eth1 = nullptr;
REQUIRE_NOTHROW(eth0 = node->get_intfs().at("eth0"));
REQUIRE_NOTHROW(eth1 = node->get_intfs().at("eth1"));

Expand Down
12 changes: 6 additions & 6 deletions tests/dropmon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ TEST_CASE("dropmon") {
const string inputfn = test_data_dir + "/docker-drop.toml";
REQUIRE_NOTHROW(ConfigParser().parse(inputfn, plankton));
const auto &network = plankton.network();
DockerNode *node;
DockerNode *node = nullptr;
REQUIRE_NOTHROW(node = static_cast<DockerNode *>(network.nodes().at("fw")));
REQUIRE(node);
Interface *eth0;
Interface *eth1;
Interface *eth0 = nullptr;
Interface *eth1 = nullptr;
REQUIRE_NOTHROW(eth0 = node->get_intfs().at("eth0"));
REQUIRE_NOTHROW(eth1 = node->get_intfs().at("eth1"));
REQUIRE(eth0);
Expand Down Expand Up @@ -85,11 +85,11 @@ TEST_CASE("dropmon") {
REQUIRE_NOTHROW(dm.start_listening_for(pkt, &docker));
// Send the ping packet
REQUIRE_NOTHROW(docker.unpause());
size_t nwrite;
size_t nwrite = 0;
REQUIRE_NOTHROW(nwrite = docker.inject_packet(pkt));
CHECK(nwrite == 42);
// Get the kernel drop timestamp (blocking)
uint64_t drop_ts;
uint64_t drop_ts = 0;
REQUIRE_NOTHROW(drop_ts = dm.get_drop_ts(timeout));
CHECK(drop_ts > 0);
REQUIRE_NOTHROW(docker.pause());
Expand Down Expand Up @@ -186,7 +186,7 @@ TEST_CASE("dropmon") {
REQUIRE_NOTHROW(start_dm_thread());
// Send the ping packet
REQUIRE_NOTHROW(docker.unpause());
size_t nwrite;
size_t nwrite = 0;
REQUIRE_NOTHROW(nwrite = docker.inject_packet(pkt));
CHECK(nwrite == 42);
// Get the kernel drop timestamp (blocking)
Expand Down
12 changes: 6 additions & 6 deletions tests/droptrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ TEST_CASE("droptrace") {
const string inputfn = test_data_dir + "/docker-drop.toml";
REQUIRE_NOTHROW(ConfigParser().parse(inputfn, plankton));
const auto &network = plankton.network();
DockerNode *node;
DockerNode *node = nullptr;
REQUIRE_NOTHROW(node = static_cast<DockerNode *>(network.nodes().at("fw")));
REQUIRE(node);
Interface *eth0;
Interface *eth1;
Interface *eth0 = nullptr;
Interface *eth1 = nullptr;
REQUIRE_NOTHROW(eth0 = node->get_intfs().at("eth0"));
REQUIRE_NOTHROW(eth1 = node->get_intfs().at("eth1"));
REQUIRE(eth0);
Expand Down Expand Up @@ -84,8 +84,8 @@ TEST_CASE("droptrace") {
REQUIRE_NOTHROW(dt.start()); // Open and load the BPF program

Packet pkt;
size_t nwrite;
uint64_t drop_ts;
size_t nwrite = 0;
uint64_t drop_ts = 0;

// Ping request packet from node1 to node2
pkt = Packet(eth0, "192.168.1.2", "192.168.2.2", 0, 0, 0, 0,
Expand Down Expand Up @@ -207,7 +207,7 @@ TEST_CASE("droptrace") {
};

Packet pkt;
size_t nwrite;
size_t nwrite = 0;

// Ping request packet from node1 to node2
pkt = Packet(eth0, "192.168.1.2", "192.168.2.2", 0, 0, 0, 0,
Expand Down

0 comments on commit 77d969c

Please sign in to comment.