From dc8aee22f2682559dccb935e961d8bc946a412c4 Mon Sep 17 00:00:00 2001 From: Richard Barnes Date: Tue, 10 Dec 2024 10:43:05 -0800 Subject: [PATCH] Remove unused-variable in fboss/lib/test/PciDeviceTest.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: harshitgulati18 Differential Revision: D66978877 fbshipit-source-id: 3c681cc81fb78727ad2a0941acfc7c88c9a347a4 --- fboss/lib/test/PciDeviceTest.cpp | 6 +++--- fboss/qsfp_service/module/tests/QsfpModuleTest.cpp | 1 - fboss/thrift_cow/nodes/tests/ThriftListNodeTests.cpp | 7 ++++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fboss/lib/test/PciDeviceTest.cpp b/fboss/lib/test/PciDeviceTest.cpp index df2f070cd9599..8fa249ffdfa78 100644 --- a/fboss/lib/test/PciDeviceTest.cpp +++ b/fboss/lib/test/PciDeviceTest.cpp @@ -39,9 +39,9 @@ TEST(PciDevice, StaleDevice) { CHECK_EQ(pciDevice.isGood(), true); pciDevice.close(); EXPECT_THROW( - { auto bar0 = pciDevice.getMemoryRegionAddress(); }, std::exception); + { std::ignore = pciDevice.getMemoryRegionAddress(); }, std::exception); EXPECT_THROW( - { auto barSize0 = pciDevice.getMemoryRegionSize(); }, std::exception); + { std::ignore = pciDevice.getMemoryRegionSize(); }, std::exception); } TEST(PciDevice, TwoDevices) { @@ -57,7 +57,7 @@ TEST(PciDevice, TwoDevices) { // Close first device and access second pciDevice1.close(); - EXPECT_NO_THROW({ auto barSize0 = pciDevice2.getMemoryRegionSize(); }); + EXPECT_NO_THROW({ std::ignore = pciDevice2.getMemoryRegionSize(); }); // Close second device EXPECT_NO_THROW(pciDevice2.close()); diff --git a/fboss/qsfp_service/module/tests/QsfpModuleTest.cpp b/fboss/qsfp_service/module/tests/QsfpModuleTest.cpp index 7bc281f374d14..c0b05e2a546c0 100644 --- a/fboss/qsfp_service/module/tests/QsfpModuleTest.cpp +++ b/fboss/qsfp_service/module/tests/QsfpModuleTest.cpp @@ -491,7 +491,6 @@ TEST_F(QsfpModuleTest, verifyLaneToPortMapping) { TEST_F(QsfpModuleTest, getFirmwareUpgradeData) { qsfp_->overrideVendorPN(getFakePartNumber()); - const QsfpConfig* qsfp_config = transceiverManager_->getQsfpConfig(); // Test empty fw status transceiverManager_->refreshStateMachines(); qsfp_->useActualGetTransceiverInfo(); diff --git a/fboss/thrift_cow/nodes/tests/ThriftListNodeTests.cpp b/fboss/thrift_cow/nodes/tests/ThriftListNodeTests.cpp index 213c5706ff77e..0f3cff00d8476 100644 --- a/fboss/thrift_cow/nodes/tests/ThriftListNodeTests.cpp +++ b/fboss/thrift_cow/nodes/tests/ThriftListNodeTests.cpp @@ -528,7 +528,7 @@ TEST(ThriftListNodeTests, ThriftListConstness) { node.publish(); const auto& list = node.cref(); auto fn = [list]() { - for (const auto& item : *list) { + for ([[maybe_unused]] const auto& item : *list) { // Check failed: !isPublished() from begin } }; @@ -543,7 +543,7 @@ TEST(ThriftListNodeTests, Cref) { ASSERT_TRUE( std::is_const_v>); // ASSERT_NO_DEATH - for (auto& item : *constWrappedRef) { + for ([[maybe_unused]] auto& item : *constWrappedRef) { } ThriftStructNode anotherNode; @@ -553,7 +553,8 @@ TEST(ThriftListNodeTests, Cref) { ASSERT_DEATH(gn(), ""); auto fn = [&node]() { - for (auto& item : *(node.safe_ref())) { + for ([[maybe_unused]] auto& item : + *(node.safe_ref())) { // Check failed: !isPublished() from begin } };