Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ae7d9e6e authored by Nate Myren's avatar Nate Myren
Browse files

Put brackets around AIDL_RETURN macro

This makes the VALUE_OR_RETURN_ILLEGAL_ARG_STATUS if statement
work correctly. Also removes needless double conversion

Fixes: 182788325
Test: Launch OboeTester, run "TEST OUTPUT" with MMAP checked
Change-Id: I3d441645bee735c58b0c7c234032ec76a238928d
parent da52d866
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ using namespace android;
using namespace aaudio;

#define MAX_STREAMS_PER_PROCESS   8
#define AIDL_RETURN(x) *_aidl_return = (x); return Status::ok();
#define AIDL_RETURN(x) { *_aidl_return = (x); return Status::ok(); }

#define VALUE_OR_RETURN_ILLEGAL_ARG_STATUS(x) \
    ({ auto _tmp = (x); \
@@ -116,12 +116,11 @@ AAudioService::openStream(const StreamRequest &_request, StreamParameters* _para

    // Enforce limit on client processes.
    Identity callingIdentity = request.getIdentity();
    pid_t pid = IPCThreadState::self()->getCallingPid();
    callingIdentity.pid = VALUE_OR_RETURN_ILLEGAL_ARG_STATUS(
        legacy2aidl_pid_t_int32_t(IPCThreadState::self()->getCallingPid()));
        legacy2aidl_pid_t_int32_t(pid));
    callingIdentity.uid = VALUE_OR_RETURN_ILLEGAL_ARG_STATUS(
        legacy2aidl_uid_t_int32_t(IPCThreadState::self()->getCallingUid()));
    pid_t pid = VALUE_OR_RETURN_ILLEGAL_ARG_STATUS(
        aidl2legacy_int32_t_pid_t(callingIdentity.pid));
    if (callingIdentity.pid != mAudioClient.identity.pid) {
        int32_t count = AAudioClientTracker::getInstance().getStreamCount(pid);
        if (count >= MAX_STREAMS_PER_PROCESS) {