Skip to content

Commit

Permalink
Remove unused-variable in fboss/lib/test/PciDeviceTest.cpp +3
Browse files Browse the repository at this point in the history
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
  • Loading branch information
r-barnes authored and facebook-github-bot committed Dec 10, 2024
1 parent 0164216 commit dc8aee2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions fboss/lib/test/PciDeviceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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());
Expand Down
1 change: 0 additions & 1 deletion fboss/qsfp_service/module/tests/QsfpModuleTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 4 additions & 3 deletions fboss/thrift_cow/nodes/tests/ThriftListNodeTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ TEST(ThriftListNodeTests, ThriftListConstness) {
node.publish();
const auto& list = node.cref<k::listOfPrimitives>();
auto fn = [list]() {
for (const auto& item : *list) {
for ([[maybe_unused]] const auto& item : *list) {
// Check failed: !isPublished() from begin
}
};
Expand All @@ -543,7 +543,7 @@ TEST(ThriftListNodeTests, Cref) {
ASSERT_TRUE(
std::is_const_v<std::remove_reference_t<decltype(*constWrappedRef)>>);
// ASSERT_NO_DEATH
for (auto& item : *constWrappedRef) {
for ([[maybe_unused]] auto& item : *constWrappedRef) {
}

ThriftStructNode<TestStruct> anotherNode;
Expand All @@ -553,7 +553,8 @@ TEST(ThriftListNodeTests, Cref) {
ASSERT_DEATH(gn(), "");

auto fn = [&node]() {
for (auto& item : *(node.safe_ref<k::listOfPrimitives>())) {
for ([[maybe_unused]] auto& item :
*(node.safe_ref<k::listOfPrimitives>())) {
// Check failed: !isPublished() from begin
}
};
Expand Down

0 comments on commit dc8aee2

Please sign in to comment.