From f8c286cb234f14e2aab146c8eeb8c857a7ac98dc Mon Sep 17 00:00:00 2001 From: zhangyichix Date: Tue, 17 Oct 2023 10:42:58 +0800 Subject: [PATCH] Fixed few static analysis issues<2> 1. In function main(int, char **) an exception of type std::__1::system_error is thrown and never caught. 2. Assigning value MFX_ERR_INVALID_HANDLE to mfx_res here, but that stored value is overwritten before it can be used. Tracked-On: OAM-112437 Signed-off-by: zhangyichix --- c2_store/src/mfx_c2_service.cpp | 8 ++++---- c2_utils/src/mfx_va_frame_pool_allocator.cpp | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/c2_store/src/mfx_c2_service.cpp b/c2_store/src/mfx_c2_service.cpp index 0b5d9104..eeaaa90c 100755 --- a/c2_store/src/mfx_c2_service.cpp +++ b/c2_store/src/mfx_c2_service.cpp @@ -106,11 +106,11 @@ int main(int /* argc */, char** /* argv */) { android::hardware::configureRpcThreadpool(8, true /* callerWillJoin */); RegisterC2Service(); + + android::hardware::joinRpcThreadpool(); + } catch(const std::exception& ex) { - // ALOGE("hardware.intel.media.c2@1.0-service exception: %s", ex.what()); - return 0; + ALOGE("hardware.intel.media.c2@1.0-service exception: %s", ex.what()); } - - android::hardware::joinRpcThreadpool(); return 0; } diff --git a/c2_utils/src/mfx_va_frame_pool_allocator.cpp b/c2_utils/src/mfx_va_frame_pool_allocator.cpp index ba1c8ef7..a2e0a124 100755 --- a/c2_utils/src/mfx_va_frame_pool_allocator.cpp +++ b/c2_utils/src/mfx_va_frame_pool_allocator.cpp @@ -25,6 +25,7 @@ #include "mfx_c2_utils.h" #include "mfx_debug.h" +#include "mfx_msdk_debug.h" #include @@ -155,6 +156,13 @@ mfxStatus MfxVaFramePoolAllocator::AllocFrames(mfxFrameAllocRequest *request, } MFX_DEBUG_TRACE_I32(response->NumFrameActual); + if (MFX_ERR_NONE != mfx_res) { + MFX_DEBUG_TRACE_MSG("Fatal error occurred while allocating memory"); + + MFX_DEBUG_TRACE__mfxStatus(mfx_res); + return mfx_res; + } + if (response->NumFrameActual >= request->NumFrameMin) { response->mids = mids.release(); m_pool = std::make_unique>(); //release graphic buffer @@ -172,6 +180,7 @@ mfxStatus MfxVaFramePoolAllocator::AllocFrames(mfxFrameAllocRequest *request, mfx_res = AllocFrames(request, response); } + MFX_DEBUG_TRACE__mfxStatus(mfx_res); return mfx_res; }