return_status::checkStatus => assertOk
checkStatus doesn't really set mCheckStatus to true, and hence is
a misnomer. Change it to assertOk (correspond to isOk()).
And hence the move assignment operator should not call checkStatus
(because it is valid to move into a Return<T> object that !isOk()
but has mCheckedStatus to true), because caller is fully aware of
the error that will be overwritten.
Test: libhidl_test
Change-Id: I86a44967b68619d1467d2cc9caaa39124b156121
diff --git a/base/Status.cpp b/base/Status.cpp
index 8367fb8..e7320a8 100644
--- a/base/Status.cpp
+++ b/base/Status.cpp
@@ -98,7 +98,7 @@
}
namespace details {
- void return_status::checkStatus() const {
+ void return_status::assertOk() const {
if (!isOk()) {
LOG(FATAL) << "Attempted to retrieve value from failed HIDL call: " << description();
}
@@ -110,6 +110,16 @@
LOG(FATAL) << "Failed HIDL return status not checked: " << description();
}
}
+
+ return_status &return_status::operator=(return_status &&other) {
+ if (!mCheckedStatus && !isOk()) {
+ LOG(FATAL) << "Failed HIDL return status not checked: " << description();
+ }
+ std::swap(mStatus, other.mStatus);
+ std::swap(mCheckedStatus, other.mCheckedStatus);
+ return *this;
+ }
+
} // namespace details
} // namespace hardware