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/include/hidl/Status.h b/base/include/hidl/Status.h
index 2f26ffa..c5c5bd9 100644
--- a/base/include/hidl/Status.h
+++ b/base/include/hidl/Status.h
@@ -147,7 +147,7 @@
Status mStatus {};
mutable bool mCheckedStatus = false;
protected:
- void checkStatus() const;
+ void assertOk() const;
public:
return_status() {}
return_status(Status s) : mStatus(s) {}
@@ -158,12 +158,7 @@
return_status(return_status &&other) {
*this = std::move(other);
}
- return_status &operator=(return_status &&other) {
- checkStatus();
- std::swap(mStatus, other.mStatus);
- std::swap(mCheckedStatus, other.mCheckedStatus);
- return *this;
- }
+ return_status &operator=(return_status &&other);
~return_status();
@@ -196,7 +191,7 @@
~Return() = default;
operator T() const {
- checkStatus();
+ assertOk();
return mVal;
}
@@ -222,7 +217,7 @@
~Return() = default;
operator sp<T>() const {
- checkStatus();
+ assertOk();
return mVal;
}
};