From f0a76b66f960d942aab38ad471b026842cc1fe17 Mon Sep 17 00:00:00 2001 From: baosiyuan Date: Fri, 20 Jun 2025 15:03:07 +0800 Subject: [PATCH] Change the branch to a macro definition Signed-off-by: baosiyuan Change-Id: Ibab0466f3f0588015c52f152088c8f02608cff27 --- .../accessor/src/fragment_metadata.cpp | 5 +- .../innerkitsimpl/codec/src/image_source.cpp | 57 +++++------- .../common/src/memory_manager.cpp | 10 +-- .../common/src/pixel_yuv_ext.cpp | 88 ++++++------------- .../src/heif_format_agent.cpp | 14 ++- .../image/libgifplugin/src/gif_encoder.cpp | 5 +- .../image/libjpegplugin/src/exif_info.cpp | 5 +- plugins/manager/src/framework/impl_class.cpp | 12 +-- .../manager/src/framework/impl_class_mgr.cpp | 4 +- plugins/manager/src/plugin_server.cpp | 10 +-- 10 files changed, 68 insertions(+), 142 deletions(-) diff --git a/frameworks/innerkitsimpl/accessor/src/fragment_metadata.cpp b/frameworks/innerkitsimpl/accessor/src/fragment_metadata.cpp index 908ecf80f..238015591 100644 --- a/frameworks/innerkitsimpl/accessor/src/fragment_metadata.cpp +++ b/frameworks/innerkitsimpl/accessor/src/fragment_metadata.cpp @@ -51,10 +51,7 @@ int FragmentMetadata::GetValue(const std::string &key, std::string &value) const IMAGE_LOGE("%{public}s properties is nullptr.", __func__); return ERR_IMAGE_INVALID_PARAMETER; } - if (!IsValidKey(key)) { - IMAGE_LOGE("Key is not supported."); - return ERR_IMAGE_INVALID_PARAMETER; - } + CHECK_ERROR_RETURN_RET_LOG(!IsValidKey(key), ERR_IMAGE_INVALID_PARAMETER, "Key is not supported."); auto it = properties_->find(key); if (it != properties_->end()) { value = it->second; diff --git a/frameworks/innerkitsimpl/codec/src/image_source.cpp b/frameworks/innerkitsimpl/codec/src/image_source.cpp index ee0d0b619..3b4c760b7 100644 --- a/frameworks/innerkitsimpl/codec/src/image_source.cpp +++ b/frameworks/innerkitsimpl/codec/src/image_source.cpp @@ -1056,9 +1056,7 @@ unique_ptr ImageSource::CreatePixelMapExtended(uint32_t index, const D if (NeedConvertToYuv(opts.desiredPixelFormat, pixelMap->GetPixelFormat())) { uint32_t convertRes = ImageFormatConvert::RGBConvertImageFormatOptionUnique( pixelMap, plInfo.pixelFormat, opts_.desiredPixelFormat); - if (convertRes != SUCCESS) { - IMAGE_LOGE("convert rgb to yuv failed, return origin rgb!"); - } + CHECK_ERROR_PRINT_LOG(convertRes != SUCCESS, "convert rgb to yuv failed, return origin rgb!"); } return pixelMap; } @@ -1555,11 +1553,10 @@ uint32_t ImageSource::PromoteDecoding(uint32_t index, const DecodeOptions &opts, // IMAGE_ERROR or IMAGE_DECODED. state = incrementalRecordIter->second.IncrementalState; decodeProgress = incrementalRecordIter->second.decodingProgress; - if (incrementalRecordIter->second.IncrementalState == ImageDecodingState::IMAGE_ERROR) { - IMAGE_LOGE("[ImageSource]invalid imageState %{public}d on incremental decoding.", - incrementalRecordIter->second.IncrementalState); - return ERR_IMAGE_DECODE_ABNORMAL; - } + cond = incrementalRecordIter->second.IncrementalState == ImageDecodingState::IMAGE_ERROR; + CHECK_ERROR_RETURN_RET_LOG(cond, ERR_IMAGE_DECODE_ABNORMAL, + "[ImageSource]invalid imageState %{public}d on incremental decoding.", + incrementalRecordIter->second.IncrementalState); return SUCCESS; } @@ -1935,9 +1932,7 @@ uint32_t ImageSource::GetImagePropertyString(uint32_t index, const std::string & uint32_t ImageSource::GetImagePropertyStringBySync(uint32_t index, const std::string &key, std::string &value) { - if (key.empty()) { - return Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT; - } + CHECK_ERROR_RETURN_RET(key.empty(), Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT); uint32_t ret = SUCCESS; if (IMAGE_GIFLOOPCOUNT_TYPE.compare(key) == ZERO) { @@ -1948,20 +1943,16 @@ uint32_t ImageSource::GetImagePropertyStringBySync(uint32_t index, const std::st return ret; } else { ret = mainDecoder_->GetImagePropertyString(index, key, value); - if (ret != SUCCESS) { - IMAGE_LOGE("[ImageSource]GetLoopCount get loop count issue. errorCode=%{public}u", ret); - return ret; - } + CHECK_ERROR_RETURN_RET_LOG(ret != SUCCESS, ret, + "[ImageSource]GetLoopCount get loop count issue. errorCode=%{public}u", ret); } return ret; } std::unique_lock guard(decodingMutex_); std::unique_lock guardFile(fileMutex_); - - if (isExifReadFailed_ && exifMetadata_ == nullptr) { - return exifReadStatus_; - } + bool cond = isExifReadFailed_ && exifMetadata_ == nullptr; + CHECK_ERROR_RETURN_RET(cond, exifReadStatus_); ret = CreatExifMetadataByImageSource(); if (ret != SUCCESS) { if (key.substr(0, KEY_SIZE) == "Hw") { @@ -1975,9 +1966,8 @@ uint32_t ImageSource::GetImagePropertyStringBySync(uint32_t index, const std::st return ret; } - if (exifMetadata_->GetValue(key, value) != SUCCESS) { - return ERR_IMAGE_PROPERTY_NOT_EXIST; - } + cond = exifMetadata_->GetValue(key, value) != SUCCESS; + CHECK_ERROR_RETURN_RET(cond, ERR_IMAGE_PROPERTY_NOT_EXIST); return SUCCESS; } @@ -2608,11 +2598,10 @@ uint32_t ImageSource::SetDecodeOptions(std::unique_ptr &decoder bool isVpeSupport10BitOutputFormat = (opts.photoDesiredPixelFormat == PixelFormat::YCBCR_P010 || opts.photoDesiredPixelFormat == PixelFormat::RGBA_1010102); if (opts.photoDesiredPixelFormat != PixelFormat::UNKNOWN) { - if ((isDecodeHdrImage && !isVpeSupport10BitOutputFormat) || - (!isDecodeHdrImage && isVpeSupport10BitOutputFormat)) { - IMAGE_LOGE("Photos provided a error parameter"); - return COMMON_ERR_INVALID_PARAMETER; - } + bool cond = (isDecodeHdrImage && !isVpeSupport10BitOutputFormat) || + (!isDecodeHdrImage && isVpeSupport10BitOutputFormat); + CHECK_ERROR_RETURN_RET_LOG(cond, COMMON_ERR_INVALID_PARAMETER, + "Photos provided a error parameter"); plOptions.desiredPixelFormat = opts.photoDesiredPixelFormat; if (opts.photoDesiredPixelFormat == PixelFormat::YCBCR_P010) { // if need 10bit yuv, set plOptions to nv21 @@ -3782,10 +3771,7 @@ void ImageSource::DumpInputData(const std::string &fileSuffix) return; } - if (sourceStreamPtr_ == nullptr) { - IMAGE_LOGI("ImageSource::DumpInputData failed, streamPtr is null"); - return; - } + CHECK_ERROR_RETURN_LOG(sourceStreamPtr_ == nullptr, "ImageSource::DumpInputData failed, streamPtr is null"); uint8_t *data = sourceStreamPtr_->GetDataPtr(); size_t size = sourceStreamPtr_->GetStreamSize(); @@ -4430,14 +4416,13 @@ static bool CopyRGBAToSurfaceBuffer(const DecodeContext& context, sptr& buffer, PlImageInfo plInfo) { - if (context.info.pixelFormat != PixelFormat::NV12 && - context.info.pixelFormat != PixelFormat::NV21) { - return false; - } + bool cond = context.info.pixelFormat != PixelFormat::NV12 && + context.info.pixelFormat != PixelFormat::NV21; + CHECK_ERROR_RETURN_RET(cond, false); uint8_t* srcRow = static_cast(context.pixelsBuffer.buffer); uint8_t* dstRow = static_cast(buffer->GetVirAddr()); size_t dstSize = buffer->GetSize(); - bool cond = (buffer->GetStride() < 0); + cond = (buffer->GetStride() < 0); CHECK_ERROR_RETURN_RET(cond, false); YUVDataInfo yuvDataInfo = context.yuvInfo; IMAGE_LOGD("[ImageSource] CopyYUVToSurfaceBuffer yHeight = %{public}d, uvHeight = %{public}d," diff --git a/frameworks/innerkitsimpl/common/src/memory_manager.cpp b/frameworks/innerkitsimpl/common/src/memory_manager.cpp index ee9f4cc03..4f5321d45 100644 --- a/frameworks/innerkitsimpl/common/src/memory_manager.cpp +++ b/frameworks/innerkitsimpl/common/src/memory_manager.cpp @@ -45,10 +45,7 @@ constexpr int32_t PIXEL_MAP_MAX_RAM_SIZE = 600 * 1024 * 1024; uint32_t HeapMemory::Create() { IMAGE_LOGD("HeapMemory::Create IN"); - if (data.data != nullptr) { - IMAGE_LOGD("HeapMemory::Create has created"); - return SUCCESS; - } + CHECK_DEBUG_RETURN_RET_LOG(data.data != nullptr, SUCCESS, "HeapMemory::Create has created"); if (data.size == 0 || data.size > PIXEL_MAP_MAX_RAM_SIZE) { IMAGE_LOGE("HeapMemory::Create Invalid value of bufferSize"); return ERR_IMAGE_DATA_ABNORMAL; @@ -68,10 +65,7 @@ uint32_t HeapMemory::Release() { #if !defined(IOS_PLATFORM) &&!defined(ANDROID_PLATFORM) IMAGE_LOGD("HeapMemory::Release IN"); - if (data.data == nullptr) { - IMAGE_LOGI("HeapMemory::Release nullptr data"); - return ERR_IMAGE_DATA_ABNORMAL; - } + CHECK_INFO_RETURN_RET_LOG(data.data != nullptr, ERR_IMAGE_DATA_ABNORMAL, "HeapMemory::Release nullptr data"); free(data.data); data.data = nullptr; #endif diff --git a/frameworks/innerkitsimpl/common/src/pixel_yuv_ext.cpp b/frameworks/innerkitsimpl/common/src/pixel_yuv_ext.cpp index 3cf76273f..7954fa6bc 100644 --- a/frameworks/innerkitsimpl/common/src/pixel_yuv_ext.cpp +++ b/frameworks/innerkitsimpl/common/src/pixel_yuv_ext.cpp @@ -151,21 +151,14 @@ void PixelYuvExt::scale(float xAxis, float yAxis, const AntiAliasingOption &opti int32_t dstH = (imageInfo.size.height * yAxis + ROUND_FLOAT_NUMBER); YUVStrideInfo dstStrides; auto m = CreateMemory(imageInfo.pixelFormat, "Trans ImageData", dstW, dstH, dstStrides); - if (m == nullptr) { - IMAGE_LOGE("scale CreateMemory failed"); - return; - } + CHECK_ERROR_RETURN_LOG(m == nullptr, "scale CreateMemory failed"); int64_t dstBufferSizeOverflow = static_cast(dstW) * static_cast(dstH); - if (ImageUtils::GetPixelBytes(imageInfo.pixelFormat) == 0) { - IMAGE_LOGE("invalid pixelFormat:[%{public}d]", imageInfo.pixelFormat); - return; - } + bool cond = ImageUtils::GetPixelBytes(imageInfo.pixelFormat) == 0; + CHECK_ERROR_RETURN_LOG(cond, "invalid pixelFormat:[%{public}d]", imageInfo.pixelFormat); int64_t maxDstBufferSize = static_cast(INT32_MAX) / ImageUtils::GetPixelBytes(imageInfo.pixelFormat); - if (abs(dstBufferSizeOverflow) > maxDstBufferSize) { - IMAGE_LOGE("scale target size too large, srcWidth(%{public}d) * xAxis(%{public}.2f), " + cond = abs(dstBufferSizeOverflow) > maxDstBufferSize; + CHECK_ERROR_RETURN_LOG(cond, "scale target size too large, srcWidth(%{public}d) * xAxis(%{public}.2f), " "srcHeight(%{public}d) * yAxis(%{public}.2f)", imageInfo.size.width, xAxis, imageInfo.size.height, yAxis); - return; - } uint8_t *dst = reinterpret_cast(m->data.data); YUVDataInfo yuvDataInfo; @@ -203,10 +196,7 @@ void PixelYuvExt::scale(int32_t dstW, int32_t dstH, const AntiAliasingOption &op YUVStrideInfo dstStrides; auto m = CreateMemory(imageInfo.pixelFormat, "Trans ImageData", dstW, dstH, dstStrides); - if (m == nullptr) { - IMAGE_LOGE("scale CreateMemory failed"); - return; - } + CHECK_ERROR_RETURN_LOG(m == nullptr, "scale CreateMemory failed"); uint8_t *dst = reinterpret_cast(m->data.data); YUVDataInfo yuvDataInfo; GetImageYUVInfo(yuvDataInfo); @@ -235,9 +225,8 @@ void PixelYuvExt::scale(int32_t dstW, int32_t dstH, const AntiAliasingOption &op void PixelYuvExt::rotate(float degrees) { - if (!IsYuvFormat() || degrees == 0) { - return; - } + bool cond = !IsYuvFormat() || degrees == 0; + CHECK_ERROR_RETURN(cond); YUVDataInfo yuvDataInfo; GetImageYUVInfo(yuvDataInfo); @@ -248,18 +237,13 @@ void PixelYuvExt::rotate(float degrees) OpenSourceLibyuv::RotationMode rotateNum = OpenSourceLibyuv::RotationMode::kRotate0; int32_t dstWidth = imageInfo_.size.width; int32_t dstHeight = imageInfo_.size.height; - if (!YuvRotateConvert(imageInfo_.size, degrees, dstWidth, dstHeight, rotateNum)) { - IMAGE_LOGI("Rotate degress is invalid, don't need rotate"); - return ; - } + cond = !YuvRotateConvert(imageInfo_.size, degrees, dstWidth, dstHeight, rotateNum); + CHECK_INFO_RETURN_LOG(cond, "Rotate degress is invalid, don't need rotate"); IMAGE_LOGD("PixelYuvExt::rotate dstWidth=%{public}d dstHeight=%{public}d", dstWidth, dstHeight); YUVStrideInfo dstStrides; auto m = CreateMemory(imageInfo_.pixelFormat, "rotate ImageData", dstWidth, dstHeight, dstStrides); - if (m == nullptr) { - IMAGE_LOGE("rotate CreateMemory failed"); - return; - } + CHECK_ERROR_RETURN_LOG(m == nullptr, "rotate CreateMemory failed"); uint8_t *dst = reinterpret_cast(m->data.data); yuvDataInfo.imageSize = imageInfo_.size; @@ -279,9 +263,8 @@ void PixelYuvExt::rotate(float degrees) void PixelYuvExt::flip(bool xAxis, bool yAxis) { - if (!IsYuvFormat() || (xAxis == false && yAxis == false)) { - return; - } + bool cond = !IsYuvFormat() || (xAxis == false && yAxis == false); + CHECK_ERROR_RETURN(cond); ImageInfo imageInfo; GetImageInfo(imageInfo); @@ -302,10 +285,7 @@ void PixelYuvExt::flip(bool xAxis, bool yAxis) int32_t height = imageInfo.size.height; YUVStrideInfo dstStrides; auto m = CreateMemory(imageInfo.pixelFormat, "flip ImageData", width, height, dstStrides); - if (m == nullptr) { - IMAGE_LOGE("flip CreateMemory failed"); - return; - } + CHECK_ERROR_RETURN_LOG(m == nullptr, "flip CreateMemory failed"); uint8_t *dst = reinterpret_cast(m->data.data); bool bRet = false; if (xAxis && yAxis) { @@ -363,10 +343,8 @@ int32_t PixelYuvExt::ColorSpaceBGRAToYuv( GetImageYUVInfo(yuvDataInfo); uint32_t pictureSize = GetImageSize(dstWidth, dstHeight, format); std::unique_ptr yuvData = std::make_unique(pictureSize); - if (!PixelYuvExtUtils::BGRAToYuv420(bgraData, data_, dstWidth, dstHeight, format, yuvDataInfo)) { - IMAGE_LOGE("BGRAToYuv420 failed"); - return ERR_IMAGE_COLOR_CONVERT; - } + bool cond = !PixelYuvExtUtils::BGRAToYuv420(bgraData, data_, dstWidth, dstHeight, format, yuvDataInfo); + CHECK_ERROR_RETURN_RET_LOG(cond, ERR_IMAGE_COLOR_CONVERT, "BGRAToYuv420 failed"); auto grName = grColorSpace.GetColorSpaceName(); grColorSpace_ = std::make_shared( dst.info.refColorSpace(), grName); @@ -376,12 +354,10 @@ int32_t PixelYuvExt::ColorSpaceBGRAToYuv( uint32_t PixelYuvExt::ApplyColorSpace(const OHOS::ColorManager::ColorSpace &grColorSpace) { - if (!IsYuvFormat()) { - return ERR_IMAGE_COLOR_CONVERT; - } - if (CheckColorSpace(grColorSpace)) { - return SUCCESS; - } + bool cond = !IsYuvFormat(); + CHECK_ERROR_RETURN_RET(cond, ERR_IMAGE_INVALID_PARAMETER); + cond = CheckColorSpace(grColorSpace); + CHECK_ERROR_RETURN_RET(cond, SUCCESS); /*convert yuV420 to·BRGA */ PixelFormat format = imageInfo_.pixelFormat; YUVDataInfo yuvDataInfo; @@ -389,10 +365,9 @@ uint32_t PixelYuvExt::ApplyColorSpace(const OHOS::ColorManager::ColorSpace &grCo int32_t width = imageInfo_.size.width; int32_t height = imageInfo_.size.height; - if (!PixelYuvUtils::CheckWidthAndHeightMult(width, height, RGBA_BIT_DEPTH)) { - IMAGE_LOGE("ApplyColorSpace size overflow width(%{public}d), height(%{public}d)", width, height); - return ERR_IMAGE_COLOR_CONVERT; - } + cond = !PixelYuvUtils::CheckWidthAndHeightMult(width, height, RGBA_BIT_DEPTH); + CHECK_ERROR_RETURN_RET_LOG(cond, ERR_IMAGE_COLOR_CONVERT, + "ApplyColorSpace size overflow width(%{public}d), height(%{public}d)", width, height); uint8_t *srcData = data_; std::unique_ptr RGBAdata = std::make_unique(width * height * NUM_4); @@ -410,10 +385,7 @@ uint32_t PixelYuvExt::ApplyColorSpace(const OHOS::ColorManager::ColorSpace &grCo IMAGE_LOGI("applyColorSpace rowStride:%{public}ld sucess", rowStride); auto bret = src.bitmap.installPixels(src.info, RGBAdata.get(), rowStride); - if (bret == false) { - IMAGE_LOGE("src.bitmap.installPixels failed"); - return -1; - } + CHECK_ERROR_RETURN_RET_LOG(bret == false, -1, "src.bitmap.installPixels failed"); // Build sk target infomation SkTransYuvInfo dst; @@ -421,15 +393,11 @@ uint32_t PixelYuvExt::ApplyColorSpace(const OHOS::ColorManager::ColorSpace &grCo std::unique_ptr RGBAdataC = std::make_unique(width * height * NUM_4); // Transfor pixels*by readPixels - if (!src.bitmap.readPixels(dst.info, RGBAdataC.get(), rowStride, 0, 0)) { - IMAGE_LOGE("ReadPixels failed"); - return ERR_IMAGE_COLOR_CONVERT; - } + cond = !src.bitmap.readPixels(dst.info, RGBAdataC.get(), rowStride, 0, 0); + CHECK_ERROR_RETURN_RET_LOG(cond, ERR_IMAGE_COLOR_CONVERT, "ReadPixels failed"); // convert bgra back to·yuv - if (ColorSpaceBGRAToYuv(RGBAdataC.get(), dst, imageInfo_, format, grColorSpace) != SUCCESS) { - IMAGE_LOGE("ColorSpaceBGRAToYuv failed"); - return ERR_IMAGE_COLOR_CONVERT; - } + cond = ColorSpaceBGRAToYuv(RGBAdataC.get(), dst, imageInfo_, format, grColorSpace) != SUCCESS; + CHECK_ERROR_RETURN_RET_LOG(cond, ERR_IMAGE_COLOR_CONVERT, "ColorSpaceBGRAToYuv failed"); return SUCCESS; } #endif diff --git a/plugins/common/libs/image/formatagentplugin/src/heif_format_agent.cpp b/plugins/common/libs/image/formatagentplugin/src/heif_format_agent.cpp index 0878c6fdc..dcf45ef66 100644 --- a/plugins/common/libs/image/formatagentplugin/src/heif_format_agent.cpp +++ b/plugins/common/libs/image/formatagentplugin/src/heif_format_agent.cpp @@ -92,10 +92,8 @@ bool HeifFormatAgent::CheckFormat(const void *headerData, uint32_t dataSize) int64_t chunkDataSize = static_cast(chunkSize) - offset; // It should at least have major brand (4-byte) and minor version (4-bytes). // The rest of the chunk (if any) is a list of (4-byte) compatible brands. - if (chunkDataSize < HEADER_LEAST_SIZE) { - IMAGE_LOGE("chunk data size [%{public}lld] less than eight.", static_cast(chunkDataSize)); - return false; - } + CHECK_ERROR_RETURN_RET_LOG(chunkDataSize < HEADER_LEAST_SIZE, false, + "chunk data size [%{public}lld] less than eight.", static_cast(chunkDataSize)); uint32_t numCompatibleBrands = (chunkDataSize - OFFSET_SIZE) / sizeof(uint32_t); if (numCompatibleBrands != 0 && numCompatibleBrands + TIMES_TWO < HEADER_SIZE) { for (size_t i = 0; i < numCompatibleBrands + 2; ++i) { // need next 2 item @@ -103,11 +101,9 @@ bool HeifFormatAgent::CheckFormat(const void *headerData, uint32_t dataSize) // Skip this index, it refers to the minorVersion, not a brand. continue; } - if (i == MAX_LOOP_SIZE) { - // When numCompatibleBrands is 4, i equals 5, and there is no heif brand, it will be read out of bounds. - IMAGE_LOGI("check heif format failed, the number of cycles exceeded expectations"); - return false; - } + // When numCompatibleBrands is 4, i equals 5, and there is no heif brand, it will be read out of bounds. + CHECK_ERROR_RETURN_RET_LOG(i == MAX_LOOP_SIZE, false, + "check heif format failed, the number of cycles exceeded expectations"); auto *brandPtr = static_cast(tmpBuff) + (numCompatibleBrands + i); uint32_t brand = EndianSwap32(*brandPtr); cond = brand == Fourcc('m', 'i', 'f', '1') || brand == Fourcc('h', 'e', 'i', 'c') || diff --git a/plugins/common/libs/image/libgifplugin/src/gif_encoder.cpp b/plugins/common/libs/image/libgifplugin/src/gif_encoder.cpp index b570086f8..22d20adfb 100644 --- a/plugins/common/libs/image/libgifplugin/src/gif_encoder.cpp +++ b/plugins/common/libs/image/libgifplugin/src/gif_encoder.cpp @@ -691,10 +691,7 @@ uint32_t GifEncoder::LZWEncode(uint8_t *buffer, int length) } curChar = Pixel; if (runningCode_ >= LZ_MAX_CODE) { - if (LZWWriteOut(clearCode_)) { - IMAGE_LOGE("Failed to write."); - return ERR_IMAGE_ENCODE_FAILED; - } + CHECK_ERROR_RETURN_RET_LOG(LZWWriteOut(clearCode_), ERR_IMAGE_ENCODE_FAILED, "Failed to write."); runningCode_ = eofCode_ + 1; runningBits_ = BITS_IN_BYTE + 1; maxCode_ = 1 << runningBits_; diff --git a/plugins/common/libs/image/libjpegplugin/src/exif_info.cpp b/plugins/common/libs/image/libjpegplugin/src/exif_info.cpp index d37d3e48c..2bd39a598 100644 --- a/plugins/common/libs/image/libjpegplugin/src/exif_info.cpp +++ b/plugins/common/libs/image/libjpegplugin/src/exif_info.cpp @@ -1095,9 +1095,8 @@ static bool ConvertToDouble(const std::string& str, double& value) errno = 0; char* endPtr = nullptr; value = strtod(str.c_str(), &endPtr); - if (errno == ERANGE && *endPtr != '\0') { - return false; - } + bool cond = errno == ERANGE && *endPtr != '\0'; + CHECK_ERROR_RETURN_RET(cond, false); return true; } diff --git a/plugins/manager/src/framework/impl_class.cpp b/plugins/manager/src/framework/impl_class.cpp index 69eada89a..aff288d11 100644 --- a/plugins/manager/src/framework/impl_class.cpp +++ b/plugins/manager/src/framework/impl_class.cpp @@ -65,10 +65,8 @@ uint32_t ImplClass::Register(const weak_ptr &plugin, const json &classIn uint32_t result = JsonHelper::GetUint16Value(classInfo, "priority", priority_); if (result != SUCCESS) { - if (result != ERR_NO_TARGET) { - IMAGE_LOGE("read priority failed, result: %{public}u.", result); - return ERR_INVALID_PARAMETER; - } + CHECK_ERROR_RETURN_RET_LOG(result != ERR_NO_TARGET, ERR_INVALID_PARAMETER, + "read priority failed, result: %{public}u.", result); // priority is optional, and default zero. priority_ = 0; } @@ -276,10 +274,8 @@ bool ImplClass::AnalysisServices(const json &classInfo) #ifndef PLUGIN_FLAG_RTTI_ENABLE // check only one business interface class is allowed to inherit. - if (lastInterfaceID != UINT32_MAX_VALUE && lastInterfaceID != interfaceID) { - IMAGE_LOGE("more than one business interface base class."); - return false; - } + bool cond = lastInterfaceID != UINT32_MAX_VALUE && lastInterfaceID != interfaceID; + CHECK_ERROR_RETURN_RET_LOG(cond, false, "more than one business interface base class."); lastInterfaceID = interfaceID; #endif uint32_t result = JsonHelper::GetUint16Value(serviceInfo, "serviceType", serviceType); diff --git a/plugins/manager/src/framework/impl_class_mgr.cpp b/plugins/manager/src/framework/impl_class_mgr.cpp index f08e48087..baed51727 100644 --- a/plugins/manager/src/framework/impl_class_mgr.cpp +++ b/plugins/manager/src/framework/impl_class_mgr.cpp @@ -107,9 +107,7 @@ PluginClassBase *ImplClassMgr::CreateObject(uint16_t interfaceID, const string & } for (; iter != endIter; ++iter) { - if (iter->second->IsSupport(interfaceID)) { - return iter->second->CreateObject(errorCode); - } + CHECK_ERROR_RETURN_RET(iter->second->IsSupport(interfaceID), iter->second->CreateObject(errorCode)); } // no this class diff --git a/plugins/manager/src/plugin_server.cpp b/plugins/manager/src/plugin_server.cpp index a483f5dde..958d07929 100644 --- a/plugins/manager/src/plugin_server.cpp +++ b/plugins/manager/src/plugin_server.cpp @@ -79,10 +79,8 @@ uint32_t PluginServer::Register(vector &&pluginPaths) if (!gstCanonicalPaths.empty()) { uint32_t result = gstPluginFw_.Register(gstCanonicalPaths); - if (result != SUCCESS) { - IMAGE_LOGE("failed to register gst plugin path, ERRNO: %{public}u.", result); - return result; - } + CHECK_ERROR_RETURN_RET_LOG(result != SUCCESS, result, + "failed to register gst plugin path, ERRNO: %{public}u.", result); } if (!canonicalPaths.empty()) { @@ -128,9 +126,7 @@ PluginClassBase *PluginServer::CreateObject(uint16_t interfaceID, uint16_t servi if (GetInterfaceIDType(interfaceID) == IID_TYPE_PIPELINE) { IMAGE_LOGD("it is a pipeline interface type."); obj = gstPluginFw_.CreateObject(interfaceID, serviceType, capabilities, priorityScheme, errorCode); - if (obj != nullptr) { - return obj; - } + CHECK_ERROR_RETURN_RET(obj != nullptr, obj); } obj = pluginFw_.CreateObject(interfaceID, serviceType, capabilities, priorityScheme, errorCode); -- Gitee