From e37cccb8a65bb7d3276a3189546e7db81cb1700a Mon Sep 17 00:00:00 2001 From: pengxin99 Date: Mon, 13 Nov 2023 15:08:47 +0800 Subject: [PATCH] [Deocde] fix some covierty issues * [Deocde] fix some covierty issues --- .../codec/hal/codechal_kernel_olp_mdf_xe_xpm.cpp | 16 ++++++++++++++-- .../common/codec/ddi/media_libva_decoder.cpp | 12 ++++-------- .../linux/common/ddi/media_libva_caps.cpp | 4 ++-- .../codec/ddi/dec/ddi_decode_functions.cpp | 6 ++---- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/media_driver/agnostic/Xe_M/Xe_XPM/codec/hal/codechal_kernel_olp_mdf_xe_xpm.cpp b/media_driver/agnostic/Xe_M/Xe_XPM/codec/hal/codechal_kernel_olp_mdf_xe_xpm.cpp index 69a850e0ee1..dd8a8cee162 100644 --- a/media_driver/agnostic/Xe_M/Xe_XPM/codec/hal/codechal_kernel_olp_mdf_xe_xpm.cpp +++ b/media_driver/agnostic/Xe_M/Xe_XPM/codec/hal/codechal_kernel_olp_mdf_xe_xpm.cpp @@ -163,7 +163,13 @@ MOS_STATUS CodechalKernelOlpMdf::Execute(PMOS_SURFACE src, uint16_t *srcMemory_o CODECHAL_DECODE_CHK_STATUS_RETURN(m_cmTask->AddKernel(m_cmKernels[0])); if (!m_SingleTaskPhase) { - CODECHAL_DECODE_CHK_STATUS_RETURN(m_cmQueue->EnqueueWithGroup(m_cmTask, event)); + auto sts = m_cmQueue->EnqueueWithGroup(m_cmTask, event); + MOS_STATUS stmtStatus = (MOS_STATUS)(sts); + if (stmtStatus != MOS_STATUS_SUCCESS) + { + event = CM_NO_EVENT; + return stmtStatus; + } CODECHAL_ENCODE_CHK_STATUS_RETURN(m_cmTask->Reset()); } @@ -174,7 +180,13 @@ MOS_STATUS CodechalKernelOlpMdf::Execute(PMOS_SURFACE src, uint16_t *srcMemory_o CODECHAL_DECODE_CHK_STATUS_RETURN(m_cmDevice->CreateThreadGroupSpace(1, 1, threadWidth, threadHeight, m_threadGroupSpaces[1])); CODECHAL_DECODE_CHK_STATUS_RETURN(m_cmKernels[1]->AssociateThreadGroupSpace(m_threadGroupSpaces[1])); CODECHAL_DECODE_CHK_STATUS_RETURN(m_cmTask->AddKernel(m_cmKernels[1])); - CODECHAL_DECODE_CHK_STATUS_RETURN(m_cmQueue->EnqueueWithGroup(m_cmTask, event)); + auto sts = m_cmQueue->EnqueueWithGroup(m_cmTask, event); + MOS_STATUS stmtStatus = (MOS_STATUS)(sts); + if (stmtStatus != MOS_STATUS_SUCCESS) + { + event = CM_NO_EVENT; + return stmtStatus; + } CODECHAL_ENCODE_CHK_STATUS_RETURN(m_cmTask->Reset()); return MOS_STATUS_SUCCESS; diff --git a/media_driver/linux/common/codec/ddi/media_libva_decoder.cpp b/media_driver/linux/common/codec/ddi/media_libva_decoder.cpp index 6dc130d6ca3..7317a79b735 100755 --- a/media_driver/linux/common/codec/ddi/media_libva_decoder.cpp +++ b/media_driver/linux/common/codec/ddi/media_libva_decoder.cpp @@ -411,11 +411,9 @@ VAStatus DdiDecode_StatusReport(PDDI_MEDIA_CONTEXT mediaCtx, CodechalDecode *dec PDDI_MEDIA_SURFACE_HEAP_ELEMENT mediaSurfaceHeapElmt = (PDDI_MEDIA_SURFACE_HEAP_ELEMENT)mediaCtx->pSurfaceHeap->pHeapBase; uint32_t j = 0; - for (j = 0; j < mediaCtx->pSurfaceHeap->uiAllocatedHeapElements; j++, mediaSurfaceHeapElmt++) + for (j = 0; j < mediaCtx->pSurfaceHeap->uiAllocatedHeapElements && mediaSurfaceHeapElmt != nullptr; j++, mediaSurfaceHeapElmt++) { - if (mediaSurfaceHeapElmt != nullptr && - mediaSurfaceHeapElmt->pSurface != nullptr && - bo == mediaSurfaceHeapElmt->pSurface->bo) + if (mediaSurfaceHeapElmt->pSurface != nullptr && bo == mediaSurfaceHeapElmt->pSurface->bo) { mediaSurfaceHeapElmt->pSurface->curStatusReport.decode.status = (uint32_t)tempNewReport.m_codecStatus; mediaSurfaceHeapElmt->pSurface->curStatusReport.decode.errMbNum = (uint32_t)tempNewReport.m_numMbsAffected; @@ -498,11 +496,9 @@ VAStatus DdiDecode_StatusReport(PDDI_MEDIA_CONTEXT mediaCtx, DecodePipelineAdapt PDDI_MEDIA_SURFACE_HEAP_ELEMENT mediaSurfaceHeapElmt = (PDDI_MEDIA_SURFACE_HEAP_ELEMENT)mediaCtx->pSurfaceHeap->pHeapBase; uint32_t j = 0; - for (j = 0; j < mediaCtx->pSurfaceHeap->uiAllocatedHeapElements; j++, mediaSurfaceHeapElmt++) + for (j = 0; j < mediaCtx->pSurfaceHeap->uiAllocatedHeapElements && mediaSurfaceHeapElmt != nullptr; j++, mediaSurfaceHeapElmt++) { - if (mediaSurfaceHeapElmt != nullptr && - mediaSurfaceHeapElmt->pSurface != nullptr && - bo == mediaSurfaceHeapElmt->pSurface->bo) + if (mediaSurfaceHeapElmt->pSurface != nullptr && bo == mediaSurfaceHeapElmt->pSurface->bo) { mediaSurfaceHeapElmt->pSurface->curStatusReport.decode.status = (uint32_t)tempNewReport.codecStatus; mediaSurfaceHeapElmt->pSurface->curStatusReport.decode.errMbNum = (uint32_t)tempNewReport.numMbsAffected; diff --git a/media_driver/linux/common/ddi/media_libva_caps.cpp b/media_driver/linux/common/ddi/media_libva_caps.cpp index 4ef8e631cb0..048185c0a9c 100755 --- a/media_driver/linux/common/ddi/media_libva_caps.cpp +++ b/media_driver/linux/common/ddi/media_libva_caps.cpp @@ -3428,8 +3428,8 @@ std::string MediaLibvaCaps::GetEncodeCodecKey(VAProfile profile, VAEntrypoint en bool MediaLibvaCaps::IsDecConfigId(VAConfigID configId) { - return ((configId >= DDI_CODEC_GEN_CONFIG_ATTRIBUTES_DEC_BASE) && - (configId < (DDI_CODEC_GEN_CONFIG_ATTRIBUTES_DEC_BASE + m_decConfigs.size()))); + // configId >= DDI_CODEC_GEN_CONFIG_ATTRIBUTES_DEC_BASE always be true + return configId < (DDI_CODEC_GEN_CONFIG_ATTRIBUTES_DEC_BASE + m_decConfigs.size()); } bool MediaLibvaCaps::IsEncConfigId(VAConfigID configId) diff --git a/media_softlet/linux/common/codec/ddi/dec/ddi_decode_functions.cpp b/media_softlet/linux/common/codec/ddi/dec/ddi_decode_functions.cpp index 5fe54688ad3..4455111a7ae 100644 --- a/media_softlet/linux/common/codec/ddi/dec/ddi_decode_functions.cpp +++ b/media_softlet/linux/common/codec/ddi/dec/ddi_decode_functions.cpp @@ -1068,11 +1068,9 @@ VAStatus DdiDecodeFunctions::StatusReport( PDDI_MEDIA_SURFACE_HEAP_ELEMENT mediaSurfaceHeapElmt = (PDDI_MEDIA_SURFACE_HEAP_ELEMENT)mediaCtx->pSurfaceHeap->pHeapBase; uint32_t j = 0; - for (j = 0; j < mediaCtx->pSurfaceHeap->uiAllocatedHeapElements; j++, mediaSurfaceHeapElmt++) + for (j = 0; j < mediaCtx->pSurfaceHeap->uiAllocatedHeapElements && mediaSurfaceHeapElmt != nullptr; j++, mediaSurfaceHeapElmt++) { - if (mediaSurfaceHeapElmt != nullptr && - mediaSurfaceHeapElmt->pSurface != nullptr && - bo == mediaSurfaceHeapElmt->pSurface->bo) + if (mediaSurfaceHeapElmt->pSurface != nullptr && bo == mediaSurfaceHeapElmt->pSurface->bo) { mediaSurfaceHeapElmt->pSurface->curStatusReport.decode.status = (uint32_t)tempNewReport.codecStatus; mediaSurfaceHeapElmt->pSurface->curStatusReport.decode.errMbNum = (uint32_t)tempNewReport.numMbsAffected;