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/tests/binder_test.cpp b/tests/binder_test.cpp
index 4ed609c..9f3a88a 100644
--- a/tests/binder_test.cpp
+++ b/tests/binder_test.cpp
@@ -115,7 +115,7 @@
mNetd->networkDestroy(TEST_NETID2);
}
- bool allocateIpSecResources(bool expectOk, int32_t *spi);
+ bool allocateIpSecResources(bool expectOk, int32_t* spi);
// Static because setting up the tun interface takes about 40ms.
static void SetUpTestCase() {
@@ -312,7 +312,7 @@
#define RETURN_FALSE_IF_NEQ(_expect_, _ret_) \
do { if ((_expect_) != (_ret_)) return false; } while(false)
-bool BinderTest::allocateIpSecResources(bool expectOk, int32_t *spi) {
+bool BinderTest::allocateIpSecResources(bool expectOk, int32_t* spi) {
netdutils::Status status = XfrmController::ipSecAllocateSpi(0, "::", "::1", 123, spi);
SCOPED_TRACE(status);
RETURN_FALSE_IF_NEQ(status.ok(), expectOk);