summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2024-10-22 00:01:25 +0000
committer Steven Moreland <smoreland@google.com> 2024-10-22 00:02:52 +0000
commitc4fe2466bea56ee8531c31f3b8b990713499ecd8 (patch)
treebd433ace0a8d4fd11454771226b6008a99a1aa79
parent326593b0ca2e2e02e595774bf274e249e46a1587 (diff)
libbinder: statusToString for status_t errors
'-status' for status=UNKNOWN_ERROR is UB, since that is min integer. To avoid this, use the better function which will also avoid this area. Only the cases that matter are cleaned up. Fixes: 354371732 Test: build Change-Id: I0a71cd2c04680221191c7d926a64bda08012951f
-rw-r--r--libs/binder/IMemory.cpp4
-rw-r--r--libs/binder/Parcel.cpp3
-rw-r--r--libs/binder/RpcServer.cpp2
-rw-r--r--libs/binder/RpcSession.cpp2
4 files changed, 6 insertions, 5 deletions
diff --git a/libs/binder/IMemory.cpp b/libs/binder/IMemory.cpp
index c6b0cb7b01..bb03e89c9d 100644
--- a/libs/binder/IMemory.cpp
+++ b/libs/binder/IMemory.cpp
@@ -330,8 +330,8 @@ void BpMemoryHeap::assertReallyMapped() const
if (err != NO_ERROR || // failed transaction
size != size64 || offset != offset64) { // ILP32 size check
ALOGE("binder=%p transaction failed fd=%d, size=%zu, err=%d (%s)",
- IInterface::asBinder(this).get(),
- parcel_fd, size, err, strerror(-err));
+ IInterface::asBinder(this).get(), parcel_fd, size, err,
+ statusToString(err).c_str());
return;
}
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 37113629a8..2d65cf53c8 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -668,7 +668,8 @@ status_t Parcel::appendFrom(const Parcel* parcel, size_t offset, size_t len) {
// FD was unowned in the source parcel.
int newFd = -1;
if (status_t status = binder::os::dupFileDescriptor(oldFd, &newFd); status != OK) {
- ALOGW("Failed to duplicate file descriptor %d: %s", oldFd, strerror(-status));
+ ALOGW("Failed to duplicate file descriptor %d: %s", oldFd,
+ statusToString(status).c_str());
}
rpcFields->mFds->emplace_back(unique_fd(newFd));
// Fixup the index in the data.
diff --git a/libs/binder/RpcServer.cpp b/libs/binder/RpcServer.cpp
index b8742af1f9..c7851dc3fb 100644
--- a/libs/binder/RpcServer.cpp
+++ b/libs/binder/RpcServer.cpp
@@ -503,7 +503,7 @@ void RpcServer::establishConnection(
auto status = binder::os::getRandomBytes(sessionId.data(), sessionId.size());
if (status != OK) {
- ALOGE("Failed to read random session ID: %s", strerror(-status));
+ ALOGE("Failed to read random session ID: %s", statusToString(status).c_str());
return;
}
} while (server->mSessions.end() != server->mSessions.find(sessionId));
diff --git a/libs/binder/RpcSession.cpp b/libs/binder/RpcSession.cpp
index cd21a91d2c..16023ffa82 100644
--- a/libs/binder/RpcSession.cpp
+++ b/libs/binder/RpcSession.cpp
@@ -164,7 +164,7 @@ status_t RpcSession::setupUnixDomainSocketBootstrapClient(unique_fd bootstrapFd)
status_t status = mBootstrapTransport->interruptableWriteFully(mShutdownTrigger.get(), &iov,
1, std::nullopt, &fds);
if (status != OK) {
- ALOGE("Failed to send fd over bootstrap transport: %s", strerror(-status));
+ ALOGE("Failed to send fd over bootstrap transport: %s", statusToString(status).c_str());
return status;
}