Loading libs/binder/Binder.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ #include <binder/Parcel.h> #include <binder/RecordedTransaction.h> #include <binder/RpcServer.h> #include <cutils/compiler.h> #include <private/android_filesystem_config.h> #include <pthread.h> #include <utils/misc.h> Loading Loading @@ -402,7 +401,7 @@ status_t BBinder::transact( } } if (CC_UNLIKELY(kEnableKernelIpc && mRecordingOn && code != START_RECORDING_TRANSACTION)) { if (kEnableKernelIpc && mRecordingOn && code != START_RECORDING_TRANSACTION) [[unlikely]] { Extras* e = mExtras.load(std::memory_order_acquire); AutoMutex lock(e->mLock); if (mRecordingOn) { Loading libs/binder/BpBinder.cpp +17 −13 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ #include <binder/IResultReceiver.h> #include <binder/RpcSession.h> #include <binder/Stability.h> #include <cutils/compiler.h> #include <utils/Log.h> #include <stdio.h> Loading Loading @@ -161,7 +160,7 @@ sp<BpBinder> BpBinder::create(int32_t handle) { trackedUid = IPCThreadState::self()->getCallingUid(); AutoMutex _l(sTrackingLock); uint32_t trackedValue = sTrackingMap[trackedUid]; if (CC_UNLIKELY(trackedValue & LIMIT_REACHED_MASK)) { if (trackedValue & LIMIT_REACHED_MASK) [[unlikely]] { if (sBinderProxyThrottleCreate) { return nullptr; } Loading Loading @@ -347,7 +346,7 @@ status_t BpBinder::transact( Stability::Level required = privateVendor ? Stability::VENDOR : Stability::getLocalLevel(); if (CC_UNLIKELY(!Stability::check(stability, required))) { if (!Stability::check(stability, required)) [[unlikely]] { ALOGE("Cannot do a user transaction on a %s binder (%s) in a %s context.", Stability::levelString(stability).c_str(), String8(getInterfaceDescriptor()).c_str(), Loading @@ -357,7 +356,7 @@ status_t BpBinder::transact( } status_t status; if (CC_UNLIKELY(isRpcBinder())) { if (isRpcBinder()) [[unlikely]] { status = rpcSession()->transact(sp<IBinder>::fromExisting(this), code, data, reply, flags); } else { Loading Loading @@ -572,7 +571,9 @@ BpBinder* BpBinder::remoteBinder() } BpBinder::~BpBinder() { if (CC_UNLIKELY(isRpcBinder())) return; if (isRpcBinder()) [[unlikely]] { return; } if constexpr (!kEnableKernelIpc) { LOG_ALWAYS_FATAL("Binder kernel driver disabled at build time"); Loading @@ -586,14 +587,13 @@ BpBinder::~BpBinder() { if (mTrackedUid >= 0) { AutoMutex _l(sTrackingLock); uint32_t trackedValue = sTrackingMap[mTrackedUid]; if (CC_UNLIKELY((trackedValue & COUNTING_VALUE_MASK) == 0)) { if ((trackedValue & COUNTING_VALUE_MASK) == 0) [[unlikely]] { ALOGE("Unexpected Binder Proxy tracking decrement in %p handle %d\n", this, binderHandle()); } else { if (CC_UNLIKELY( (trackedValue & LIMIT_REACHED_MASK) && ((trackedValue & COUNTING_VALUE_MASK) <= sBinderProxyCountLowWatermark) )) { auto countingValue = trackedValue & COUNTING_VALUE_MASK; if ((trackedValue & LIMIT_REACHED_MASK) && (countingValue <= sBinderProxyCountLowWatermark)) [[unlikely]] { ALOGI("Limit reached bit reset for uid %d (fewer than %d proxies from uid %d held)", getuid(), sBinderProxyCountLowWatermark, mTrackedUid); sTrackingMap[mTrackedUid] &= ~LIMIT_REACHED_MASK; Loading @@ -612,7 +612,9 @@ BpBinder::~BpBinder() { } void BpBinder::onFirstRef() { if (CC_UNLIKELY(isRpcBinder())) return; if (isRpcBinder()) [[unlikely]] { return; } if constexpr (!kEnableKernelIpc) { LOG_ALWAYS_FATAL("Binder kernel driver disabled at build time"); Loading @@ -625,7 +627,7 @@ void BpBinder::onFirstRef() { } void BpBinder::onLastStrongRef(const void* /*id*/) { if (CC_UNLIKELY(isRpcBinder())) { if (isRpcBinder()) [[unlikely]] { (void)rpcSession()->sendDecStrong(this); return; } Loading Loading @@ -666,7 +668,9 @@ void BpBinder::onLastStrongRef(const void* /*id*/) { bool BpBinder::onIncStrongAttempted(uint32_t /*flags*/, const void* /*id*/) { // RPC binder doesn't currently support inc from weak binders if (CC_UNLIKELY(isRpcBinder())) return false; if (isRpcBinder()) [[unlikely]] { return false; } if constexpr (!kEnableKernelIpc) { LOG_ALWAYS_FATAL("Binder kernel driver disabled at build time"); Loading libs/binder/Parcel.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ #include <android-base/scopeguard.h> #include <cutils/ashmem.h> #include <cutils/compiler.h> #include <utils/Flattenable.h> #include <utils/Log.h> #include <utils/String16.h> Loading libs/binder/include/binder/SafeInterface.h +15 −16 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ #include <binder/IInterface.h> #include <binder/Parcel.h> #include <cutils/compiler.h> // Set to 1 to enable CallStacks when logging errors #define SI_DUMP_CALLSTACKS 0 Loading Loading @@ -218,7 +217,7 @@ private: template <typename Function> status_t callParcel(const char* name, Function f) const { status_t error = f(); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { ALOG(LOG_ERROR, mLogTag, "Failed to %s, (%d: %s)", name, error, strerror(-error)); #if SI_DUMP_CALLSTACKS CallStack callStack(mLogTag); Loading Loading @@ -265,7 +264,7 @@ protected: data.writeInterfaceToken(this->getInterfaceDescriptor()); status_t error = writeInputs(&data, std::forward<Args>(args)...); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { // A message will have been logged by writeInputs return error; } Loading @@ -273,7 +272,7 @@ protected: // Send the data Parcel to the remote and retrieve the reply parcel Parcel reply; error = this->remote()->transact(static_cast<uint32_t>(tag), data, &reply); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { ALOG(LOG_ERROR, mLogTag, "Failed to transact (%d)", error); #if SI_DUMP_CALLSTACKS CallStack callStack(mLogTag); Loading @@ -283,7 +282,7 @@ protected: // Read the outputs from the reply Parcel into the output arguments error = readOutputs(reply, std::forward<Args>(args)...); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { // A message will have been logged by readOutputs return error; } Loading @@ -291,7 +290,7 @@ protected: // Retrieve the result code from the reply Parcel status_t result = NO_ERROR; error = reply.readInt32(&result); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { ALOG(LOG_ERROR, mLogTag, "Failed to obtain result"); #if SI_DUMP_CALLSTACKS CallStack callStack(mLogTag); Loading @@ -315,7 +314,7 @@ protected: Parcel data; data.writeInterfaceToken(this->getInterfaceDescriptor()); status_t error = writeInputs(&data, std::forward<Args>(args)...); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { // A message will have been logged by writeInputs return; } Loading @@ -324,7 +323,7 @@ protected: Parcel reply; error = this->remote()->transact(static_cast<uint32_t>(tag), data, &reply, IBinder::FLAG_ONEWAY); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { ALOG(LOG_ERROR, mLogTag, "Failed to transact (%d)", error); #if SI_DUMP_CALLSTACKS CallStack callStack(mLogTag); Loading Loading @@ -406,7 +405,7 @@ private: template <typename T, typename... Remaining> status_t writeInputs(Parcel* data, T&& t, Remaining&&... remaining) const { status_t error = writeIfInput(data, std::forward<T>(t)); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { // A message will have been logged by writeIfInput return error; } Loading @@ -429,7 +428,7 @@ private: template <typename T, typename... Remaining> status_t readOutputs(const Parcel& reply, T&& t, Remaining&&... remaining) const { status_t error = readIfOutput(reply, std::forward<T>(t)); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { // A message will have been logged by readIfOutput return error; } Loading Loading @@ -458,7 +457,7 @@ protected: // Read the inputs from the data Parcel into the argument tuple status_t error = InputReader<ParamTuple>{mLogTag}.readInputs(data, &rawArgs); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { // A message will have been logged by read return error; } Loading @@ -468,14 +467,14 @@ protected: // Extract the outputs from the argument tuple and write them into the reply Parcel error = OutputWriter<ParamTuple>{mLogTag}.writeOutputs(reply, &rawArgs); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { // A message will have been logged by write return error; } // Return the result code in the reply Parcel error = reply->writeInt32(result); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { ALOG(LOG_ERROR, mLogTag, "Failed to write result"); #if SI_DUMP_CALLSTACKS CallStack callStack(mLogTag); Loading @@ -500,7 +499,7 @@ protected: // Read the inputs from the data Parcel into the argument tuple status_t error = InputReader<ParamTuple>{mLogTag}.readInputs(data, &rawArgs); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { // A message will have been logged by read return error; } Loading Loading @@ -596,7 +595,7 @@ private: typename std::enable_if<(I < sizeof...(Params)), status_t>::type dispatchArg( const Parcel& data, RawTuple* args) { status_t error = readIfInput<I>(data, args); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { // A message will have been logged in read return error; } Loading Loading @@ -694,7 +693,7 @@ private: typename std::enable_if<(I < sizeof...(Params)), status_t>::type dispatchArg( Parcel* reply, RawTuple* args) { status_t error = writeIfOutput<I>(reply, args); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { // A message will have been logged in read return error; } Loading libs/binder/tests/unit_fuzzers/BpBinderFuzzFunctions.h +0 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ #include <binder/Parcel.h> #include <binder/Stability.h> #include <cutils/compiler.h> #include <utils/KeyedVector.h> #include <utils/Log.h> #include <utils/Mutex.h> Loading Loading
libs/binder/Binder.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ #include <binder/Parcel.h> #include <binder/RecordedTransaction.h> #include <binder/RpcServer.h> #include <cutils/compiler.h> #include <private/android_filesystem_config.h> #include <pthread.h> #include <utils/misc.h> Loading Loading @@ -402,7 +401,7 @@ status_t BBinder::transact( } } if (CC_UNLIKELY(kEnableKernelIpc && mRecordingOn && code != START_RECORDING_TRANSACTION)) { if (kEnableKernelIpc && mRecordingOn && code != START_RECORDING_TRANSACTION) [[unlikely]] { Extras* e = mExtras.load(std::memory_order_acquire); AutoMutex lock(e->mLock); if (mRecordingOn) { Loading
libs/binder/BpBinder.cpp +17 −13 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ #include <binder/IResultReceiver.h> #include <binder/RpcSession.h> #include <binder/Stability.h> #include <cutils/compiler.h> #include <utils/Log.h> #include <stdio.h> Loading Loading @@ -161,7 +160,7 @@ sp<BpBinder> BpBinder::create(int32_t handle) { trackedUid = IPCThreadState::self()->getCallingUid(); AutoMutex _l(sTrackingLock); uint32_t trackedValue = sTrackingMap[trackedUid]; if (CC_UNLIKELY(trackedValue & LIMIT_REACHED_MASK)) { if (trackedValue & LIMIT_REACHED_MASK) [[unlikely]] { if (sBinderProxyThrottleCreate) { return nullptr; } Loading Loading @@ -347,7 +346,7 @@ status_t BpBinder::transact( Stability::Level required = privateVendor ? Stability::VENDOR : Stability::getLocalLevel(); if (CC_UNLIKELY(!Stability::check(stability, required))) { if (!Stability::check(stability, required)) [[unlikely]] { ALOGE("Cannot do a user transaction on a %s binder (%s) in a %s context.", Stability::levelString(stability).c_str(), String8(getInterfaceDescriptor()).c_str(), Loading @@ -357,7 +356,7 @@ status_t BpBinder::transact( } status_t status; if (CC_UNLIKELY(isRpcBinder())) { if (isRpcBinder()) [[unlikely]] { status = rpcSession()->transact(sp<IBinder>::fromExisting(this), code, data, reply, flags); } else { Loading Loading @@ -572,7 +571,9 @@ BpBinder* BpBinder::remoteBinder() } BpBinder::~BpBinder() { if (CC_UNLIKELY(isRpcBinder())) return; if (isRpcBinder()) [[unlikely]] { return; } if constexpr (!kEnableKernelIpc) { LOG_ALWAYS_FATAL("Binder kernel driver disabled at build time"); Loading @@ -586,14 +587,13 @@ BpBinder::~BpBinder() { if (mTrackedUid >= 0) { AutoMutex _l(sTrackingLock); uint32_t trackedValue = sTrackingMap[mTrackedUid]; if (CC_UNLIKELY((trackedValue & COUNTING_VALUE_MASK) == 0)) { if ((trackedValue & COUNTING_VALUE_MASK) == 0) [[unlikely]] { ALOGE("Unexpected Binder Proxy tracking decrement in %p handle %d\n", this, binderHandle()); } else { if (CC_UNLIKELY( (trackedValue & LIMIT_REACHED_MASK) && ((trackedValue & COUNTING_VALUE_MASK) <= sBinderProxyCountLowWatermark) )) { auto countingValue = trackedValue & COUNTING_VALUE_MASK; if ((trackedValue & LIMIT_REACHED_MASK) && (countingValue <= sBinderProxyCountLowWatermark)) [[unlikely]] { ALOGI("Limit reached bit reset for uid %d (fewer than %d proxies from uid %d held)", getuid(), sBinderProxyCountLowWatermark, mTrackedUid); sTrackingMap[mTrackedUid] &= ~LIMIT_REACHED_MASK; Loading @@ -612,7 +612,9 @@ BpBinder::~BpBinder() { } void BpBinder::onFirstRef() { if (CC_UNLIKELY(isRpcBinder())) return; if (isRpcBinder()) [[unlikely]] { return; } if constexpr (!kEnableKernelIpc) { LOG_ALWAYS_FATAL("Binder kernel driver disabled at build time"); Loading @@ -625,7 +627,7 @@ void BpBinder::onFirstRef() { } void BpBinder::onLastStrongRef(const void* /*id*/) { if (CC_UNLIKELY(isRpcBinder())) { if (isRpcBinder()) [[unlikely]] { (void)rpcSession()->sendDecStrong(this); return; } Loading Loading @@ -666,7 +668,9 @@ void BpBinder::onLastStrongRef(const void* /*id*/) { bool BpBinder::onIncStrongAttempted(uint32_t /*flags*/, const void* /*id*/) { // RPC binder doesn't currently support inc from weak binders if (CC_UNLIKELY(isRpcBinder())) return false; if (isRpcBinder()) [[unlikely]] { return false; } if constexpr (!kEnableKernelIpc) { LOG_ALWAYS_FATAL("Binder kernel driver disabled at build time"); Loading
libs/binder/Parcel.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ #include <android-base/scopeguard.h> #include <cutils/ashmem.h> #include <cutils/compiler.h> #include <utils/Flattenable.h> #include <utils/Log.h> #include <utils/String16.h> Loading
libs/binder/include/binder/SafeInterface.h +15 −16 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ #include <binder/IInterface.h> #include <binder/Parcel.h> #include <cutils/compiler.h> // Set to 1 to enable CallStacks when logging errors #define SI_DUMP_CALLSTACKS 0 Loading Loading @@ -218,7 +217,7 @@ private: template <typename Function> status_t callParcel(const char* name, Function f) const { status_t error = f(); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { ALOG(LOG_ERROR, mLogTag, "Failed to %s, (%d: %s)", name, error, strerror(-error)); #if SI_DUMP_CALLSTACKS CallStack callStack(mLogTag); Loading Loading @@ -265,7 +264,7 @@ protected: data.writeInterfaceToken(this->getInterfaceDescriptor()); status_t error = writeInputs(&data, std::forward<Args>(args)...); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { // A message will have been logged by writeInputs return error; } Loading @@ -273,7 +272,7 @@ protected: // Send the data Parcel to the remote and retrieve the reply parcel Parcel reply; error = this->remote()->transact(static_cast<uint32_t>(tag), data, &reply); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { ALOG(LOG_ERROR, mLogTag, "Failed to transact (%d)", error); #if SI_DUMP_CALLSTACKS CallStack callStack(mLogTag); Loading @@ -283,7 +282,7 @@ protected: // Read the outputs from the reply Parcel into the output arguments error = readOutputs(reply, std::forward<Args>(args)...); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { // A message will have been logged by readOutputs return error; } Loading @@ -291,7 +290,7 @@ protected: // Retrieve the result code from the reply Parcel status_t result = NO_ERROR; error = reply.readInt32(&result); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { ALOG(LOG_ERROR, mLogTag, "Failed to obtain result"); #if SI_DUMP_CALLSTACKS CallStack callStack(mLogTag); Loading @@ -315,7 +314,7 @@ protected: Parcel data; data.writeInterfaceToken(this->getInterfaceDescriptor()); status_t error = writeInputs(&data, std::forward<Args>(args)...); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { // A message will have been logged by writeInputs return; } Loading @@ -324,7 +323,7 @@ protected: Parcel reply; error = this->remote()->transact(static_cast<uint32_t>(tag), data, &reply, IBinder::FLAG_ONEWAY); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { ALOG(LOG_ERROR, mLogTag, "Failed to transact (%d)", error); #if SI_DUMP_CALLSTACKS CallStack callStack(mLogTag); Loading Loading @@ -406,7 +405,7 @@ private: template <typename T, typename... Remaining> status_t writeInputs(Parcel* data, T&& t, Remaining&&... remaining) const { status_t error = writeIfInput(data, std::forward<T>(t)); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { // A message will have been logged by writeIfInput return error; } Loading @@ -429,7 +428,7 @@ private: template <typename T, typename... Remaining> status_t readOutputs(const Parcel& reply, T&& t, Remaining&&... remaining) const { status_t error = readIfOutput(reply, std::forward<T>(t)); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { // A message will have been logged by readIfOutput return error; } Loading Loading @@ -458,7 +457,7 @@ protected: // Read the inputs from the data Parcel into the argument tuple status_t error = InputReader<ParamTuple>{mLogTag}.readInputs(data, &rawArgs); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { // A message will have been logged by read return error; } Loading @@ -468,14 +467,14 @@ protected: // Extract the outputs from the argument tuple and write them into the reply Parcel error = OutputWriter<ParamTuple>{mLogTag}.writeOutputs(reply, &rawArgs); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { // A message will have been logged by write return error; } // Return the result code in the reply Parcel error = reply->writeInt32(result); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { ALOG(LOG_ERROR, mLogTag, "Failed to write result"); #if SI_DUMP_CALLSTACKS CallStack callStack(mLogTag); Loading @@ -500,7 +499,7 @@ protected: // Read the inputs from the data Parcel into the argument tuple status_t error = InputReader<ParamTuple>{mLogTag}.readInputs(data, &rawArgs); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { // A message will have been logged by read return error; } Loading Loading @@ -596,7 +595,7 @@ private: typename std::enable_if<(I < sizeof...(Params)), status_t>::type dispatchArg( const Parcel& data, RawTuple* args) { status_t error = readIfInput<I>(data, args); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { // A message will have been logged in read return error; } Loading Loading @@ -694,7 +693,7 @@ private: typename std::enable_if<(I < sizeof...(Params)), status_t>::type dispatchArg( Parcel* reply, RawTuple* args) { status_t error = writeIfOutput<I>(reply, args); if (CC_UNLIKELY(error != NO_ERROR)) { if (error != NO_ERROR) [[unlikely]] { // A message will have been logged in read return error; } Loading
libs/binder/tests/unit_fuzzers/BpBinderFuzzFunctions.h +0 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ #include <binder/Parcel.h> #include <binder/Stability.h> #include <cutils/compiler.h> #include <utils/KeyedVector.h> #include <utils/Log.h> #include <utils/Mutex.h> Loading