Skip to content

Commit 1730528

Browse files
author
Steven Moreland
committed
libbinder: unused-result warning
Bug: 388886755 Test: check logs on boot Change-Id: I70faf816a15574018b1df688950173af7af640bc
1 parent a17adea commit 1730528

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

libs/binder/Android.bp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ cc_defaults {
269269
"-Wzero-as-null-pointer-constant",
270270
"-Wreorder-init-list",
271271
"-Wunused-const-variable",
272+
"-Wunused-result",
272273
"-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION",
273274
"-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION",
274275
// Hide symbols by default and set the BUILDING_LIBBINDER macro so that

libs/binder/IPCThreadState.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -626,12 +626,22 @@ void IPCThreadState::flushCommands()
626626
{
627627
if (mProcess->mDriverFD < 0)
628628
return;
629-
talkWithDriver(false);
629+
630+
if (status_t res = talkWithDriver(false); res != OK) {
631+
// TODO: we may want to abort for some of these cases
632+
ALOGW("1st call to talkWithDriver returned error in flushCommands: %s",
633+
statusToString(res).c_str());
634+
}
635+
630636
// The flush could have caused post-write refcount decrements to have
631637
// been executed, which in turn could result in BC_RELEASE/BC_DECREFS
632638
// being queued in mOut. So flush again, if we need to.
633639
if (mOut.dataSize() > 0) {
634-
talkWithDriver(false);
640+
if (status_t res = talkWithDriver(false); res != OK) {
641+
// TODO: we may want to abort for some of these cases
642+
ALOGW("2nd call to talkWithDriver returned error in flushCommands: %s",
643+
statusToString(res).c_str());
644+
}
635645
}
636646
if (mOut.dataSize() > 0) {
637647
ALOGW("mOut.dataSize() > 0 after flushCommands()");
@@ -803,7 +813,11 @@ void IPCThreadState::joinThreadPool(bool isMain)
803813

804814
mOut.writeInt32(BC_EXIT_LOOPER);
805815
mIsLooper = false;
806-
talkWithDriver(false);
816+
if (status_t res = talkWithDriver(false); res != OK) {
817+
// TODO: we may want to abort for some of these cases
818+
ALOGW("call to talkWithDriver in joinThreadPool returned error: %s, FD: %d",
819+
statusToString(res).c_str(), mProcess->mDriverFD);
820+
}
807821
size_t oldCount = mProcess->mCurrentThreads.fetch_sub(1);
808822
LOG_ALWAYS_FATAL_IF(oldCount == 0,
809823
"Threadpool thread count underflowed. Thread cannot exist and exit in "
@@ -1494,7 +1508,14 @@ status_t IPCThreadState::executeCommand(int32_t cmd)
14941508
buffer.setDataSize(0);
14951509

14961510
constexpr uint32_t kForwardReplyFlags = TF_CLEAR_BUF;
1497-
sendReply(reply, (tr.flags & kForwardReplyFlags));
1511+
1512+
// TODO: we may want to abort if there is an error here, or return as 'error'
1513+
// from this function, but the impact needs to be measured
1514+
status_t error2 = sendReply(reply, (tr.flags & kForwardReplyFlags));
1515+
if (error2 != OK) {
1516+
ALOGE("error in sendReply for synchronous call: %s",
1517+
statusToString(error2).c_str());
1518+
}
14981519
} else {
14991520
if (error != OK) {
15001521
std::ostringstream logStream;

0 commit comments

Comments
 (0)