From 7f1c623328afe3cd484afda2b84d32e8a7f89f55 Mon Sep 17 00:00:00 2001 From: Jonas Gorski Date: Wed, 29 May 2024 09:17:17 +0200 Subject: [PATCH 1/6] knet_manager: remove unused variables Neither rv nor port_removed are used, so remove them. Fixes the following warnings: | ../git/src/netlink/knet_manager.cc: In member function 'virtual bool basebox::knet_manager::portdev_removed(rtnl_link*)': | ../git/src/netlink/knet_manager.cc:256:7: error: unused variable 'rv' [-Werror=unused-variable] | 256 | int rv = 0; | | ^~ | ../git/src/netlink/knet_manager.cc:257:8: error: unused variable 'port_removed' [-Werror=unused-variable] | 257 | bool port_removed(false); | | ^~~~~~~~~~~~ Signed-off-by: Jonas Gorski --- src/netlink/knet_manager.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/netlink/knet_manager.cc b/src/netlink/knet_manager.cc index 08c67d12..7a2e69cc 100644 --- a/src/netlink/knet_manager.cc +++ b/src/netlink/knet_manager.cc @@ -253,8 +253,6 @@ bool knet_manager::portdev_removed(rtnl_link *link) { int ifindex(rtnl_link_get_ifindex(link)); std::string portname(rtnl_link_get_name(link)); - int rv = 0; - bool port_removed(false); std::lock_guard lock{tn_mutex}; auto ifi2id_it = ifindex_to_id.find(ifindex); From de167d0b4b79894cbddb44dc95c4b9a8ba27a95f Mon Sep 17 00:00:00 2001 From: Jonas Gorski Date: Wed, 29 May 2024 09:24:09 +0200 Subject: [PATCH 2/6] cnetlink::handle_source_mac_learn(): drop unused variable ifindex ifindex is unsed, so remove it. Fixes the following warning: | ../git/src/netlink/cnetlink.cc: In member function 'int basebox::cnetlink::handle_source_mac_learn()': | ../git/src/netlink/cnetlink.cc:962:9: error: unused variable 'ifindex' [-Werror=unused-variable] | 962 | int ifindex = port_man->get_ifindex(p.port_id); | | ^~~~~~~ Signed-off-by: Jonas Gorski --- src/netlink/cnetlink.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/netlink/cnetlink.cc b/src/netlink/cnetlink.cc index f5183c59..d964ce2d 100644 --- a/src/netlink/cnetlink.cc +++ b/src/netlink/cnetlink.cc @@ -959,7 +959,6 @@ int cnetlink::handle_source_mac_learn() { cnt < nl_proc_max && _packet_in.size() && state == NL_STATE_RUNNING; cnt++) { auto p = _packet_in.front(); - int ifindex = port_man->get_ifindex(p.port_id); // pass process packets to port_man port_man->enqueue(p.port_id, p.pkt); From 322bdd2294be9fcaac6265b0648c8248993d5744 Mon Sep 17 00:00:00 2001 From: Jonas Gorski Date: Wed, 29 May 2024 09:15:27 +0200 Subject: [PATCH 3/6] nl_bond::add_lag_member() drop set but unread variable We don't do anything with the return value of lag_members.emplace, so no need to store it. Fixes the following build warning: | ../git/src/netlink/nl_bond.cc: In member function 'int basebox::nl_bond::add_lag_member(rtnl_link*, rtnl_link*)': | ../git/src/netlink/nl_bond.cc:203:10: error: variable 'lm_rv' set but not used [-Werror=unused-but-set-variable] | 203 | auto lm_rv = lag_members.emplace(lag_id, members); | | ^~~~~ Signed-off-by: Jonas Gorski --- src/netlink/nl_bond.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/netlink/nl_bond.cc b/src/netlink/nl_bond.cc index 22d1096e..3cc16501 100644 --- a/src/netlink/nl_bond.cc +++ b/src/netlink/nl_bond.cc @@ -200,7 +200,7 @@ int nl_bond::add_lag_member(rtnl_link *bond, rtnl_link *link) { if (mem_it == lag_members.end()) { // No ports in lag std::set members; members.insert(port_id); - auto lm_rv = lag_members.emplace(lag_id, members); + lag_members.emplace(lag_id, members); } else { mem_it->second.insert(port_id); } From f41aa9f2de6424e31c21fcaf3bdfdc867116d844 Mon Sep 17 00:00:00 2001 From: Jonas Gorski Date: Wed, 29 May 2024 09:21:38 +0200 Subject: [PATCH 4/6] nl_bridge::mdb_entry_{add,remove}: fix type for port_ifindex Both rtnl_mdb_entry_get_ifindex() and nl_bridge::get_ifindex() return an int, not a uint32_t, so change the type of port_ifindex to int. Fixes the following warnings: | ../git/src/netlink/nl_bridge.cc: In member function 'int basebox::nl_bridge::mdb_entry_add(rtnl_mdb*)': | ../git/src/netlink/nl_bridge.cc:900:22: error: comparison of integer expressions of different signedness: 'uint32_t' {aka 'unsigned int'} and 'int' [-Werror=sign-compare] | 900 | if (port_ifindex == get_ifindex()) { | | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~ | ../git/src/netlink/nl_bridge.cc: In member function 'int basebox::nl_bridge::mdb_entry_remove(rtnl_mdb*)': | ../git/src/netlink/nl_bridge.cc:999:22: error: comparison of integer expressions of different signedness: 'uint32_t' {aka 'unsigned int'} and 'int' [-Werror=sign-compare] | 999 | if (port_ifindex == get_ifindex()) { | | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~ Signed-off-by: Jonas Gorski --- src/netlink/nl_bridge.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/netlink/nl_bridge.cc b/src/netlink/nl_bridge.cc index e351b307..24b54afc 100644 --- a/src/netlink/nl_bridge.cc +++ b/src/netlink/nl_bridge.cc @@ -892,7 +892,7 @@ int nl_bridge::mdb_entry_add(rtnl_mdb *mdb_entry) { &mdb); for (auto i : mdb) { - uint32_t port_ifindex = rtnl_mdb_entry_get_ifindex(i); + int port_ifindex = rtnl_mdb_entry_get_ifindex(i); uint32_t port_id = nl->get_port_id(port_ifindex); uint16_t vid = rtnl_mdb_entry_get_vid(i); unsigned char buf[ETH_ALEN]; @@ -991,7 +991,7 @@ int nl_bridge::mdb_entry_remove(rtnl_mdb *mdb_entry) { &mdb); for (auto i : mdb) { - uint32_t port_ifindex = rtnl_mdb_entry_get_ifindex(i); + int port_ifindex = rtnl_mdb_entry_get_ifindex(i); uint32_t port_id = nl->get_port_id(port_ifindex); uint16_t vid = rtnl_mdb_entry_get_vid(i); unsigned char buf[ETH_ALEN]; From a6dc612345d503307d2e3e16bce6587b228dd046 Mon Sep 17 00:00:00 2001 From: Jonas Gorski Date: Wed, 29 May 2024 09:28:08 +0200 Subject: [PATCH 5/6] nl_l3::get_neighbours_of_route(): drop unused variable dst dst is unused so drop it. Fixes the following warning: | ../git/src/netlink/nl_l3.cc: In member function 'int basebox::nl_l3::get_neighbours_of_route(rtnl_route*, std::deque*, std::deque*)': | ../git/src/netlink/nl_l3.cc:1433:8: error: unused variable 'route_dst' [-Werror=unused-variable] | 1433 | auto route_dst = rtnl_route_get_dst(route); | | ^~~~~~~~~ Signed-off-by: Jonas Gorski --- src/netlink/nl_l3.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/netlink/nl_l3.cc b/src/netlink/nl_l3.cc index 27a42233..f6362f71 100644 --- a/src/netlink/nl_l3.cc +++ b/src/netlink/nl_l3.cc @@ -1430,7 +1430,6 @@ int nl_l3::get_neighbours_of_route( rtnl_route *route, std::deque *neighs, std::deque *unresolved_nh) noexcept { - auto route_dst = rtnl_route_get_dst(route); std::deque nhs; assert(route); From 3c3267eba8bca3a69aca8e17db359bffd6b9c254 Mon Sep 17 00:00:00 2001 From: Jonas Gorski Date: Wed, 29 May 2024 09:12:14 +0200 Subject: [PATCH 6/6] build: enable Werror by default Now that we fixed all warnings, enable Werror to prevent any new ones from springing up. Signed-off-by: Jonas Gorski --- meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/meson.build b/meson.build index 69d021e5..354c6af7 100644 --- a/meson.build +++ b/meson.build @@ -5,6 +5,7 @@ project('baseboxd', 'cpp', 'b_asneeded=false', 'prefix=/usr', 'sysconfdir=/etc', + 'werror=true', ]) sources = files('''