From 9adfeaf07d46772fdae3512cbfee8082689ee967 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 21 Jan 2022 17:22:09 -0800 Subject: Fix building libbinder against musl musl libc uses the posix definition of msg_iovlen as int. Change the niovs argument to an int, make sure it is not negative, and cast it to size_t if necessary. Bug: 190084016 Test: m USE_HOST_MUSL=true host-native Change-Id: I6ff9206e9e7396f2f89622735f790b4fac18f76c --- libs/binder/RpcState.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'libs/binder/RpcState.cpp') diff --git a/libs/binder/RpcState.cpp b/libs/binder/RpcState.cpp index 6286c9c7bc..4ddbce71a8 100644 --- a/libs/binder/RpcState.cpp +++ b/libs/binder/RpcState.cpp @@ -310,9 +310,9 @@ RpcState::CommandData::CommandData(size_t size) : mSize(size) { } status_t RpcState::rpcSend(const sp& connection, - const sp& session, const char* what, iovec* iovs, - size_t niovs, const std::function& altPoll) { - for (size_t i = 0; i < niovs; i++) { + const sp& session, const char* what, iovec* iovs, int niovs, + const std::function& altPoll) { + for (int i = 0; i < niovs; i++) { LOG_RPC_DETAIL("Sending %s on RpcTransport %p: %s", what, connection->rpcTransport.get(), android::base::HexString(iovs[i].iov_base, iovs[i].iov_len).c_str()); } @@ -321,7 +321,7 @@ status_t RpcState::rpcSend(const sp& connection, connection->rpcTransport->interruptableWriteFully(session->mShutdownTrigger.get(), iovs, niovs, altPoll); status != OK) { - LOG_RPC_DETAIL("Failed to write %s (%zu iovs) on RpcTransport %p, error: %s", what, niovs, + LOG_RPC_DETAIL("Failed to write %s (%d iovs) on RpcTransport %p, error: %s", what, niovs, connection->rpcTransport.get(), statusToString(status).c_str()); (void)session->shutdownAndWait(false); return status; @@ -331,19 +331,18 @@ status_t RpcState::rpcSend(const sp& connection, } status_t RpcState::rpcRec(const sp& connection, - const sp& session, const char* what, iovec* iovs, - size_t niovs) { + const sp& session, const char* what, iovec* iovs, int niovs) { if (status_t status = connection->rpcTransport->interruptableReadFully(session->mShutdownTrigger.get(), iovs, niovs, {}); status != OK) { - LOG_RPC_DETAIL("Failed to read %s (%zu iovs) on RpcTransport %p, error: %s", what, niovs, + LOG_RPC_DETAIL("Failed to read %s (%d iovs) on RpcTransport %p, error: %s", what, niovs, connection->rpcTransport.get(), statusToString(status).c_str()); (void)session->shutdownAndWait(false); return status; } - for (size_t i = 0; i < niovs; i++) { + for (int i = 0; i < niovs; i++) { LOG_RPC_DETAIL("Received %s on RpcTransport %p: %s", what, connection->rpcTransport.get(), android::base::HexString(iovs[i].iov_base, iovs[i].iov_len).c_str()); } -- cgit v1.2.3-59-g8ed1b