From 7dd6d3fdea6b0cb658904b5a38fee74d8ad8868a Mon Sep 17 00:00:00 2001 From: Richard Barnes Date: Tue, 10 Dec 2024 10:53:23 -0800 Subject: [PATCH] Remove unused-variable in fboss/agent/hw/sai/hw_test/HwTestFlowletSwitchingUtils.cpp +3 Summary: LLVM-15 has a warning `-Wunused-variable` which we treat as an error because it's so often diagnostic of a code issue. Unused variables can compromise readability or, worse, performance. This diff either (a) removes an unused variable and, possibly, it's associated code or (b) qualifies the variable with `[[maybe_unused]]`. - If you approve of this diff, please use the "Accept & Ship" button :-) Reviewed By: msomasundaran Differential Revision: D66978908 fbshipit-source-id: 73b8d4d462e6db19a7cc586d52affd8803472dea --- .../sai/hw_test/HwTestFlowletSwitchingUtils.cpp | 16 +++++++--------- fboss/agent/hw/sai/hw_test/SaiSwitchEnsemble.cpp | 2 +- .../state/tests/SwitchStatePruningTests.cpp | 5 ----- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/fboss/agent/hw/sai/hw_test/HwTestFlowletSwitchingUtils.cpp b/fboss/agent/hw/sai/hw_test/HwTestFlowletSwitchingUtils.cpp index b03a03d6021ba..9d54a413cd004 100644 --- a/fboss/agent/hw/sai/hw_test/HwTestFlowletSwitchingUtils.cpp +++ b/fboss/agent/hw/sai/hw_test/HwTestFlowletSwitchingUtils.cpp @@ -103,9 +103,8 @@ void verifyPortArsAttributes( PortSaiId portSaiId, const cfg::PortFlowletConfig& cfg, bool enable) { - auto& portApi = SaiApiTable::getInstance()->portApi(); - #if SAI_API_VERSION >= SAI_VERSION(1, 14, 0) + auto& portApi = SaiApiTable::getInstance()->portApi(); auto arsEnable = portApi.getAttribute(portSaiId, SaiPortTraits::Attributes::ArsEnable()); EXPECT_EQ(enable, arsEnable); @@ -124,11 +123,10 @@ void verifyPortArsAttributes( bool validateFlowletSwitchingEnabled( const HwSwitch* hw, const cfg::FlowletSwitchingConfig& flowletCfg) { +#if SAI_API_VERSION >= SAI_VERSION(1, 14, 0) const auto saiSwitch = static_cast(hw); SwitchSaiId switchId = saiSwitch->managerTable()->switchManager().getSwitchSaiId(); - -#if SAI_API_VERSION >= SAI_VERSION(1, 14, 0) auto arsProfileId = SaiApiTable::getInstance()->switchApi().getAttribute( switchId, SaiSwitchTraits::Attributes::ArsProfile()); @@ -157,11 +155,11 @@ bool verifyEcmpForFlowletSwitching( const cfg::FlowletSwitchingConfig& flowletCfg, const cfg::PortFlowletConfig& cfg, const bool flowletEnable) { - const auto saiSwitch = static_cast(hw); - auto nextHopGroupSaiId = getNextHopGroupSaiId(saiSwitch, ip); bool isVerified = true; #if SAI_API_VERSION >= SAI_VERSION(1, 14, 0) + const auto saiSwitch = static_cast(hw); + auto nextHopGroupSaiId = getNextHopGroupSaiId(saiSwitch, ip); auto arsId = SaiApiTable::getInstance()->nextHopGroupApi().getAttribute( nextHopGroupSaiId, SaiNextHopGroupTraits::Attributes::ArsObjectId()); @@ -182,11 +180,11 @@ bool verifyEcmpForNonFlowlet( const HwSwitch* hw, const folly::CIDRNetwork& ip, const bool flowletEnable) { - const auto saiSwitch = static_cast(hw); - auto nextHopGroupSaiId = getNextHopGroupSaiId(saiSwitch, ip); bool isVerified = true; #if SAI_API_VERSION >= SAI_VERSION(1, 14, 0) + const auto saiSwitch = static_cast(hw); + auto nextHopGroupSaiId = getNextHopGroupSaiId(saiSwitch, ip); auto arsId = SaiApiTable::getInstance()->nextHopGroupApi().getAttribute( nextHopGroupSaiId, SaiNextHopGroupTraits::Attributes::ArsObjectId()); @@ -214,11 +212,11 @@ bool validatePortFlowletQuality( } bool validateFlowletSwitchingDisabled(const HwSwitch* hw) { +#if SAI_API_VERSION >= SAI_VERSION(1, 14, 0) const auto saiSwitch = static_cast(hw); SwitchSaiId switchId = saiSwitch->managerTable()->switchManager().getSwitchSaiId(); -#if SAI_API_VERSION >= SAI_VERSION(1, 14, 0) auto arsProfileId = SaiApiTable::getInstance()->switchApi().getAttribute( switchId, SaiSwitchTraits::Attributes::ArsProfile()); diff --git a/fboss/agent/hw/sai/hw_test/SaiSwitchEnsemble.cpp b/fboss/agent/hw/sai/hw_test/SaiSwitchEnsemble.cpp index 9293d8c472117..f8fb92e72a03f 100644 --- a/fboss/agent/hw/sai/hw_test/SaiSwitchEnsemble.cpp +++ b/fboss/agent/hw/sai/hw_test/SaiSwitchEnsemble.cpp @@ -179,8 +179,8 @@ void SaiSwitchEnsemble::init( hwAsicTableEntry->setDefaultStreamType( getPlatform()->getAsic()->getDefaultStreamType()); getPlatform()->initLEDs(); - auto hw = static_cast(getHwSwitch()); #if !defined(CHENAB_SDK) + auto hw = static_cast(getHwSwitch()); // TODO(pshaikh): hacking to skip this for Chenab for now diagShell_ = std::make_unique(hw); diagCmdServer_ = std::make_unique(hw, diagShell_.get()); diff --git a/fboss/agent/state/tests/SwitchStatePruningTests.cpp b/fboss/agent/state/tests/SwitchStatePruningTests.cpp index 3cff2750004aa..045748454c70c 100644 --- a/fboss/agent/state/tests/SwitchStatePruningTests.cpp +++ b/fboss/agent/state/tests/SwitchStatePruningTests.cpp @@ -299,7 +299,6 @@ void verifyAddNeighborEntry( auto host2ip = IPAddressV6("face:b00c:0:21::2"); auto host2mac = MacAddress("fa:ce:b0:0c:21:02"); auto host2port = PortDescriptor(PortID(1)); - auto host2intf = InterfaceID(21); addNeighborEntry( &state2, &host2ip, &host2mac, &host2VlanOrIntf, &host2port); @@ -677,10 +676,6 @@ void verifyModifyArpTableMultipleTimes( // ... add host1 to vlan21 // state2 - auto host1ip = IPAddressV4("10.0.21.1"); - auto host1mac = MacAddress("fa:ce:b0:0c:21:01"); - auto host1port = PortDescriptor(PortID(1)); - auto arp1 = getVlansOrIntfs(state1) ->getNode(host1VlanOrIntf) ->getArpTable();