From 5ad71b5582147f3a26a1986239e1fcd115b81b9a Mon Sep 17 00:00:00 2001 From: Andrei Homescu Date: Fri, 11 Mar 2022 03:49:12 +0000 Subject: libbinder: Return status_t from RpcTransport::peek() Result<> pulls in over 100k of extra libc++ code on Trusty so this CL replaces it with status_t as the result type of RpcTransport::peek(). Bug: 224644083 Test: atest binderRpcTest Change-Id: Idde111245794dc4afd421f3a723feacc8c3a346e --- libs/binder/RpcState.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'libs/binder/RpcState.cpp') diff --git a/libs/binder/RpcState.cpp b/libs/binder/RpcState.cpp index 2e7084e12e..173e30a2e7 100644 --- a/libs/binder/RpcState.cpp +++ b/libs/binder/RpcState.cpp @@ -660,8 +660,14 @@ status_t RpcState::getAndExecuteCommand(const sp& con status_t RpcState::drainCommands(const sp& connection, const sp& session, CommandType type) { uint8_t buf; - while (connection->rpcTransport->peek(&buf, sizeof(buf)).value_or(0) > 0) { - status_t status = getAndExecuteCommand(connection, session, type); + while (true) { + size_t num_bytes; + status_t status = connection->rpcTransport->peek(&buf, sizeof(buf), &num_bytes); + if (status == WOULD_BLOCK) break; + if (status != OK) return status; + if (!num_bytes) break; + + status = getAndExecuteCommand(connection, session, type); if (status != OK) return status; } return OK; -- cgit v1.2.3-59-g8ed1b