From a40bdda19ad7ea36a21bd158c40957c800588674 Mon Sep 17 00:00:00 2001 From: chen0088 Date: Tue, 27 Aug 2024 09:42:45 +0800 Subject: [PATCH] modify Signed-off-by: chen0088 --- common/src/utils/dcamera_hisysevent_adapter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/src/utils/dcamera_hisysevent_adapter.cpp b/common/src/utils/dcamera_hisysevent_adapter.cpp index 27de6310..8229a89d 100644 --- a/common/src/utils/dcamera_hisysevent_adapter.cpp +++ b/common/src/utils/dcamera_hisysevent_adapter.cpp @@ -26,6 +26,8 @@ namespace OHOS { namespace DistributedHardware { namespace { constexpr int32_t MSG_MAX_LEN = 2048; +constexpr int32_t ENUM_STREAMTYPE_LEN = 2; +constexpr int32_t ENUM_ENCODETYPE_LEN = 4; using HiSysEventNameSpace = OHOS::HiviewDFX::HiSysEvent; const std::string ENUM_STREAMTYPE_STRINGS[] = { "CONTINUOUS_FRAME", "SNAPSHOT_FRAME" @@ -118,10 +120,8 @@ void ReportCameraOperaterEvent(const std::string& eventName, const std::string& void ReportStartCaptureEvent(const std::string& eventName, EventCaptureInfo& capture, const std::string& errMsg) { - if (capture.encodeType_ < 0 || - capture.encodeType_ >= sizeof(ENUM_ENCODETYPE_STRINGS) / sizeof(ENUM_ENCODETYPE_STRINGS[0]) || - capture.type_ < 0 || - capture.type_ >= sizeof(ENUM_STREAMTYPE_STRINGS) / sizeof(ENUM_STREAMTYPE_STRINGS[0])) { + if (capture.encodeType_ < 0 || capture.encodeType_ >= ENUM_ENCODETYPE_LEN || + capture.type_ < 0 || capture.type_ >= ENUM_STREAMTYPE_LEN) { DHLOGE("Invalid capture parameters."); return; } -- Gitee