summaryrefslogtreecommitdiff
path: root/libs/binder/Parcel.cpp
diff options
context:
space:
mode:
author Jooyung Han <jooyung@google.com> 2021-12-24 05:18:25 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2021-12-24 05:18:25 +0000
commitc5da00e08e24c03e5d2a5953db28af6552cec22c (patch)
tree0d5d097f2ed5ca549ca8b2dcdfb889dca60dff06 /libs/binder/Parcel.cpp
parent4d95851db86d5c51eb3b03382f516f21485fb8f7 (diff)
parentd23f9500efa59d46c57db423a630b111e889a680 (diff)
Merge "libbinder: added enforceNoDataAvail()"
Diffstat (limited to 'libs/binder/Parcel.cpp')
-rw-r--r--libs/binder/Parcel.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 7027a4b0a3..6fb189cd70 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -739,6 +739,17 @@ bool Parcel::enforceInterface(const char16_t* interface,
}
}
+binder::Status Parcel::enforceNoDataAvail() const {
+ const auto n = dataAvail();
+ if (n == 0) {
+ return binder::Status::ok();
+ }
+ return binder::Status::
+ fromExceptionCode(binder::Status::Exception::EX_BAD_PARCELABLE,
+ String8::format("Parcel data not fully consumed, unread size: %zu",
+ n));
+}
+
size_t Parcel::objectsCount() const
{
return mObjectsSize;