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

Commit 7d3f8ed3 authored by Mathias Agopian's avatar Mathias Agopian Committed by Android (Google) Code Review
Browse files

Merge "Fix a small bug where we could compute SharedBufferStack's tail incorrectly."

parents 3d85d27a c2e30de0
Loading
Loading
Loading
Loading
+5 −2
Original line number Original line Diff line number Diff line
@@ -132,10 +132,11 @@ String8 SharedBufferBase::dump(char const* prefix) const
    char buffer[SIZE];
    char buffer[SIZE];
    String8 result;
    String8 result;
    SharedBufferStack& stack( *mSharedStack );
    SharedBufferStack& stack( *mSharedStack );
    int tail = (mNumBuffers + stack.head - stack.available + 1) % mNumBuffers;
    snprintf(buffer, SIZE, 
    snprintf(buffer, SIZE, 
            "%s[ head=%2d, available=%2d, queued=%2d ] "
            "%s[ head=%2d, available=%2d, queued=%2d, tail=%2d ] "
            "reallocMask=%08x, inUse=%2d, identity=%d, status=%d\n",
            "reallocMask=%08x, inUse=%2d, identity=%d, status=%d\n",
            prefix, stack.head, stack.available, stack.queued, 
            prefix, stack.head, stack.available, stack.queued, tail,
            stack.reallocMask, stack.inUse, stack.identity, stack.status);
            stack.reallocMask, stack.inUse, stack.identity, stack.status);
    result.append(buffer);
    result.append(buffer);
    return result;
    return result;
@@ -269,6 +270,8 @@ int32_t SharedBufferClient::computeTail() const
    newTail = head - avail + 1;
    newTail = head - avail + 1;
    if (newTail < 0) {
    if (newTail < 0) {
        newTail += mNumBuffers;
        newTail += mNumBuffers;
    } else if (newTail >= mNumBuffers) {
        newTail -= mNumBuffers;
    }
    }
    return newTail;
    return newTail;
}
}