Check for ignored Status results
This change makes error-checking more explicit for anything that
returns a Status object and adds a grep-friendly ignoreError() method
for those situations where you really didn't care.
The C++17 [[nodiscard]] attribute is equivalent to the pre-existing
GNU extension __attribute__((warn_unused_result)).
A number of sites where errors were previously being ignored had to be
adjusted to either ignore the error explicitly, handling it or
propagating it to the caller. The latter two actions could potentially
introduce regressions, so please double-check in case I guessed wrong.
Finally, I added a few tests to verify that Status objects can be
cheaply moved around without copying the embedded std::string object,
since this happens at every function call boundary.
Test: atest netd_integration_test
Test: atest netd_unit_test
Test: atest netd_benchmark netdutils_test
Test: m netd ndc bpfloader libnetd_client
Change-Id: I1015c916bf6c6e3b038a683a2a126a01417d3a1c
diff --git a/server/WakeupControllerTest.cpp b/server/WakeupControllerTest.cpp
index 0b3b374..ff99b98 100644
--- a/server/WakeupControllerTest.cpp
+++ b/server/WakeupControllerTest.cpp
@@ -74,7 +74,7 @@
.WillOnce(DoAll(SaveArg<2>(&mMessageHandler), Return(ok)));
EXPECT_CALL(mListener,
unsubscribe(NetlinkManager::NFLOG_WAKEUP_GROUP)).WillOnce(Return(ok));
- mController.init(&mListener);
+ EXPECT_OK(mController.init(&mListener));
}
StrictMock<MockNetdEventListener> mEventListener;
@@ -291,7 +291,7 @@
" -j NFLOG --nflog-prefix wlan8 --nflog-group 3 --nflog-threshold 8"
" -m mark --mark 0x12345678/0x0f0f0f0f -m limit --limit 10/s\nCOMMIT\n";
EXPECT_CALL(mIptables, execute(V4V6, kExpected, _)).WillOnce(Return(0));
- mController.addInterface(kPrefix, kIfName, kMark, kMask);
+ EXPECT_OK(mController.addInterface(kPrefix, kIfName, kMark, kMask));
}
TEST_F(WakeupControllerTest, delInterface) {
@@ -304,7 +304,7 @@
" -j NFLOG --nflog-prefix wlan8 --nflog-group 3 --nflog-threshold 8"
" -m mark --mark 0x12345678/0xf0f0f0f0 -m limit --limit 10/s\nCOMMIT\n";
EXPECT_CALL(mIptables, execute(V4V6, kExpected, _)).WillOnce(Return(0));
- mController.delInterface(kPrefix, kIfName, kMark, kMask);
+ EXPECT_OK(mController.delInterface(kPrefix, kIfName, kMark, kMask));
}
} // namespace net