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

Commit 1927ee04 authored by Pawin Vongmasa's avatar Pawin Vongmasa Committed by android-build-team Robot
Browse files

Zero-initialize HIDL structs before passing

Test: make cts -j123 && cts-tradefed run cts-dev -m \
CtsMediaTestCases --compatibility:module-arg \
CtsMediaTestCases:include-annotation:\
android.platform.test.annotations.RequiresDevice

Bug: 131267328
Bug: 131356202
Change-Id: Ie91b7946f8f4406fd06e9cb4ad883b3a2704f366
Merged-In: I2f696aa85143f74f753fbb0320dce5aee88846c4
(cherry picked from commit cad25f33)
parent 13b64c45
Loading
Loading
Loading
Loading
+12 −12
Original line number Original line Diff line number Diff line
@@ -68,7 +68,7 @@ struct TWGraphicBufferProducer : public BASE {
    Return<void> requestBuffer(int32_t slot, HGraphicBufferProducer::requestBuffer_cb _hidl_cb) override {
    Return<void> requestBuffer(int32_t slot, HGraphicBufferProducer::requestBuffer_cb _hidl_cb) override {
        sp<GraphicBuffer> buf;
        sp<GraphicBuffer> buf;
        status_t status = mBase->requestBuffer(slot, &buf);
        status_t status = mBase->requestBuffer(slot, &buf);
        AnwBuffer anwBuffer;
        AnwBuffer anwBuffer{};
        if (buf != nullptr) {
        if (buf != nullptr) {
            ::android::conversion::wrapAs(&anwBuffer, *buf);
            ::android::conversion::wrapAs(&anwBuffer, *buf);
        }
        }
@@ -89,15 +89,15 @@ struct TWGraphicBufferProducer : public BASE {
            uint32_t width, uint32_t height,
            uint32_t width, uint32_t height,
            ::android::hardware::graphics::common::V1_0::PixelFormat format, uint32_t usage,
            ::android::hardware::graphics::common::V1_0::PixelFormat format, uint32_t usage,
            bool getFrameTimestamps, HGraphicBufferProducer::dequeueBuffer_cb _hidl_cb) override {
            bool getFrameTimestamps, HGraphicBufferProducer::dequeueBuffer_cb _hidl_cb) override {
        int slot;
        int slot{};
        sp<Fence> fence;
        sp<Fence> fence;
        ::android::FrameEventHistoryDelta outTimestamps;
        ::android::FrameEventHistoryDelta outTimestamps;
        status_t status = mBase->dequeueBuffer(
        status_t status = mBase->dequeueBuffer(
            &slot, &fence, width, height,
            &slot, &fence, width, height,
            static_cast<::android::PixelFormat>(format), usage, nullptr,
            static_cast<::android::PixelFormat>(format), usage, nullptr,
            getFrameTimestamps ? &outTimestamps : nullptr);
            getFrameTimestamps ? &outTimestamps : nullptr);
        hidl_handle tFence;
        hidl_handle tFence{};
        HGraphicBufferProducer::FrameEventHistoryDelta tOutTimestamps;
        HGraphicBufferProducer::FrameEventHistoryDelta tOutTimestamps{};


        native_handle_t* nh = nullptr;
        native_handle_t* nh = nullptr;
        if ((fence == nullptr) || !::android::conversion::wrapAs(&tFence, &nh, *fence)) {
        if ((fence == nullptr) || !::android::conversion::wrapAs(&tFence, &nh, *fence)) {
@@ -144,8 +144,8 @@ struct TWGraphicBufferProducer : public BASE {
        sp<GraphicBuffer> outBuffer;
        sp<GraphicBuffer> outBuffer;
        sp<Fence> outFence;
        sp<Fence> outFence;
        status_t status = mBase->detachNextBuffer(&outBuffer, &outFence);
        status_t status = mBase->detachNextBuffer(&outBuffer, &outFence);
        AnwBuffer tBuffer;
        AnwBuffer tBuffer{};
        hidl_handle tFence;
        hidl_handle tFence{};


        if (outBuffer == nullptr) {
        if (outBuffer == nullptr) {
            LOG(ERROR) << "TWGraphicBufferProducer::detachNextBuffer - "
            LOG(ERROR) << "TWGraphicBufferProducer::detachNextBuffer - "
@@ -185,7 +185,7 @@ struct TWGraphicBufferProducer : public BASE {
    Return<void> queueBuffer(
    Return<void> queueBuffer(
            int32_t slot, const HGraphicBufferProducer::QueueBufferInput& input,
            int32_t slot, const HGraphicBufferProducer::QueueBufferInput& input,
            HGraphicBufferProducer::queueBuffer_cb _hidl_cb) override {
            HGraphicBufferProducer::queueBuffer_cb _hidl_cb) override {
        HGraphicBufferProducer::QueueBufferOutput tOutput;
        HGraphicBufferProducer::QueueBufferOutput tOutput{};
        BGraphicBufferProducer::QueueBufferInput lInput(
        BGraphicBufferProducer::QueueBufferInput lInput(
                0, false, HAL_DATASPACE_UNKNOWN,
                0, false, HAL_DATASPACE_UNKNOWN,
                ::android::Rect(0, 0, 1, 1),
                ::android::Rect(0, 0, 1, 1),
@@ -246,7 +246,7 @@ struct TWGraphicBufferProducer : public BASE {
                producerControlledByApp,
                producerControlledByApp,
                &lOutput);
                &lOutput);


        HGraphicBufferProducer::QueueBufferOutput tOutput;
        HGraphicBufferProducer::QueueBufferOutput tOutput{};
        std::vector<std::vector<native_handle_t*> > nhAA;
        std::vector<std::vector<native_handle_t*> > nhAA;
        if (!::android::conversion::wrapAs(&tOutput, &nhAA, lOutput)) {
        if (!::android::conversion::wrapAs(&tOutput, &nhAA, lOutput)) {
            LOG(ERROR) << "TWGraphicBufferProducer::connect - "
            LOG(ERROR) << "TWGraphicBufferProducer::connect - "
@@ -320,11 +320,11 @@ struct TWGraphicBufferProducer : public BASE {
        status_t status = mBase->getLastQueuedBuffer(
        status_t status = mBase->getLastQueuedBuffer(
                &lOutBuffer, &lOutFence, lOutTransformMatrix);
                &lOutBuffer, &lOutFence, lOutTransformMatrix);


        AnwBuffer tOutBuffer;
        AnwBuffer tOutBuffer{};
        if (lOutBuffer != nullptr) {
        if (lOutBuffer != nullptr) {
            ::android::conversion::wrapAs(&tOutBuffer, *lOutBuffer);
            ::android::conversion::wrapAs(&tOutBuffer, *lOutBuffer);
        }
        }
        hidl_handle tOutFence;
        hidl_handle tOutFence{};
        native_handle_t* nh = nullptr;
        native_handle_t* nh = nullptr;
        if ((lOutFence == nullptr) || !::android::conversion::wrapAs(&tOutFence, &nh, *lOutFence)) {
        if ((lOutFence == nullptr) || !::android::conversion::wrapAs(&tOutFence, &nh, *lOutFence)) {
            LOG(ERROR) << "TWGraphicBufferProducer::getLastQueuedBuffer - "
            LOG(ERROR) << "TWGraphicBufferProducer::getLastQueuedBuffer - "
@@ -346,7 +346,7 @@ struct TWGraphicBufferProducer : public BASE {
        ::android::FrameEventHistoryDelta lDelta;
        ::android::FrameEventHistoryDelta lDelta;
        mBase->getFrameTimestamps(&lDelta);
        mBase->getFrameTimestamps(&lDelta);


        HGraphicBufferProducer::FrameEventHistoryDelta tDelta;
        HGraphicBufferProducer::FrameEventHistoryDelta tDelta{};
        std::vector<std::vector<native_handle_t*> > nhAA;
        std::vector<std::vector<native_handle_t*> > nhAA;
        if (!::android::conversion::wrapAs(&tDelta, &nhAA, lDelta)) {
        if (!::android::conversion::wrapAs(&tDelta, &nhAA, lDelta)) {
            LOG(ERROR) << "TWGraphicBufferProducer::getFrameTimestamps - "
            LOG(ERROR) << "TWGraphicBufferProducer::getFrameTimestamps - "
@@ -365,7 +365,7 @@ struct TWGraphicBufferProducer : public BASE {
    }
    }


    Return<void> getUniqueId(HGraphicBufferProducer::getUniqueId_cb _hidl_cb) override {
    Return<void> getUniqueId(HGraphicBufferProducer::getUniqueId_cb _hidl_cb) override {
        uint64_t outId;
        uint64_t outId{};
        status_t status = mBase->getUniqueId(&outId);
        status_t status = mBase->getUniqueId(&outId);
        _hidl_cb(static_cast<int32_t>(status), outId);
        _hidl_cb(static_cast<int32_t>(status), outId);
        return Void();
        return Void();