From 78e2f2f94c56c7225564425e8d6fffdb3b0f141b Mon Sep 17 00:00:00 2001 From: lwx1285820 Date: Fri, 12 Apr 2024 08:34:00 +0000 Subject: [PATCH] add Signed-off-by: lwx1285820 Change-Id: I08438e76e9d7f8a7a857054b4ae1861402f0cbb8 --- .../src/js_event_cooperate_target.cpp | 11 +++-- .../coordination/src/js_event_target.cpp | 14 ++----- .../services/device_manager/src/device.cpp | 2 +- libs/src/devicestatus_data_parse.cpp | 2 +- .../interaction/drag/src/drag_drawing.cpp | 42 +++++++++---------- tools/vdev/src/virtual_device_builder.cpp | 2 +- 6 files changed, 33 insertions(+), 40 deletions(-) diff --git a/frameworks/js/napi/interaction/cooperate/src/js_event_cooperate_target.cpp b/frameworks/js/napi/interaction/cooperate/src/js_event_cooperate_target.cpp index ab4150ddf..662e91430 100644 --- a/frameworks/js/napi/interaction/cooperate/src/js_event_cooperate_target.cpp +++ b/frameworks/js/napi/interaction/cooperate/src/js_event_cooperate_target.cpp @@ -576,7 +576,6 @@ void JsEventCooperateTarget::CallGetStateAsyncWork(uv_work_t *work, int32_t stat void JsEventCooperateTarget::EmitCoordinationMessageEvent(uv_work_t *work, int32_t status) { CALL_INFO_TRACE; - std::lock_guard guard(mutex_); CHKPV(work); if (work->data == nullptr) { JsUtilCooperate::DeletePtr(work); @@ -585,6 +584,7 @@ void JsEventCooperateTarget::EmitCoordinationMessageEvent(uv_work_t *work, int32 } sptr temp(static_cast(work->data)); JsUtilCooperate::DeletePtr(work); + std::lock_guard guard(mutex_); temp->DecStrongRef(nullptr); auto msgEvent = coordinationListeners_.find(COORDINATION); if (msgEvent == coordinationListeners_.end()) { @@ -592,13 +592,12 @@ void JsEventCooperateTarget::EmitCoordinationMessageEvent(uv_work_t *work, int32 return; } for (const auto &item : msgEvent->second) { - napi_handle_scope scope = nullptr; - napi_open_handle_scope(item->env, &scope); - if (item->env == nullptr || item->ref != temp->ref) { - FI_HILOGW("item->env is nullptr, skip then continue") - napi_close_handle_scope(item->env, scope); + CHKPC(item->env); + if (item->ref != temp->ref) { continue; } + napi_handle_scope scope = nullptr; + napi_open_handle_scope(item->env, &scope); napi_value deviceDescriptor = nullptr; CHKRV_SCOPE(item->env, napi_create_string_utf8(item->env, item->data.deviceDescriptor.c_str(), NAPI_AUTO_LENGTH, &deviceDescriptor), CREATE_STRING_UTF8, scope); diff --git a/frameworks/js/napi/interaction/coordination/src/js_event_target.cpp b/frameworks/js/napi/interaction/coordination/src/js_event_target.cpp index 00b03d47d..43c3bdb83 100644 --- a/frameworks/js/napi/interaction/coordination/src/js_event_target.cpp +++ b/frameworks/js/napi/interaction/coordination/src/js_event_target.cpp @@ -613,18 +613,12 @@ void JsEventTarget::EmitCoordinationMessageEvent(uv_work_t *work, int32_t status } for (const auto &item : messageEvent->second) { + CHKPC(item->env); + if (item->ref != temp->ref) { + continue; + } napi_handle_scope scope = nullptr; napi_open_handle_scope(item->env, &scope); - if (item->env == nullptr) { - FI_HILOGW("item->env is nullptr, skip then continue"); - napi_close_handle_scope(item->env, scope); - continue; - } - if (item->ref != temp->ref) { - napi_close_handle_scope(item->env, scope); - continue; - } - napi_value deviceDescriptor = nullptr; CHKRV_SCOPE(item->env, napi_create_string_utf8(item->env, item->data.deviceDescriptor.c_str(), NAPI_AUTO_LENGTH, &deviceDescriptor), CREATE_STRING_UTF8, scope); diff --git a/intention/services/device_manager/src/device.cpp b/intention/services/device_manager/src/device.cpp index 93f5b7ce0..d6a158112 100644 --- a/intention/services/device_manager/src/device.cpp +++ b/intention/services/device_manager/src/device.cpp @@ -388,7 +388,7 @@ int32_t Device::ReadConfigFile(const std::string &filePath) } pos = tmp.find('='); if (tmp.size() == 0) { - FI_HILOGE("tmp.size() - 1 will overflow"); + FI_HILOGE("Invalid size, pos will overflow"); return RET_ERR; } else if ((pos == (tmp.size() - 1)) || (pos == tmp.npos)) { FI_HILOGE("Find config item error"); diff --git a/libs/src/devicestatus_data_parse.cpp b/libs/src/devicestatus_data_parse.cpp index 09c478446..825391edf 100644 --- a/libs/src/devicestatus_data_parse.cpp +++ b/libs/src/devicestatus_data_parse.cpp @@ -123,7 +123,7 @@ bool DeviceStatusDataParse::DisableCount(const Type type) { CALL_DEBUG_ENTER; if (tempcount_.size() <= static_cast(type)) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, size is %{public}zu", tempcount_.size()); return false; } tempcount_[static_cast(type)] = static_cast(TypeValue::INVALID); diff --git a/services/interaction/drag/src/drag_drawing.cpp b/services/interaction/drag/src/drag_drawing.cpp index 58f1f87bd..c5282fcc2 100644 --- a/services/interaction/drag/src/drag_drawing.cpp +++ b/services/interaction/drag/src/drag_drawing.cpp @@ -164,7 +164,7 @@ bool CheckNodesValid() { FI_HILOGD("enter"); if (g_drawingInfo.nodes.size() <= DRAG_STYLE_INDEX) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, node size is %{public}zu", g_drawingInfo.nodes.size()); return false; } else if (g_drawingInfo.nodes.empty() || g_drawingInfo.nodes[DRAG_STYLE_INDEX] == nullptr) { FI_HILOGE("Nodes invalid"); @@ -231,7 +231,7 @@ int32_t DragDrawing::Init(const DragData &dragData) return INIT_FAIL; } if (g_drawingInfo.nodes.size() <= DRAG_STYLE_INDEX || g_drawingInfo.nodes.size() <= PIXEL_MAP_INDEX) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, node size is %{public}zu", g_drawingInfo.nodes.size()); return INIT_FAIL; } std::shared_ptr shadowNode = g_drawingInfo.nodes[PIXEL_MAP_INDEX]; @@ -351,7 +351,7 @@ int32_t DragDrawing::UpdateShadowPic(const ShadowInfo &shadowInfo) return RET_ERR; } if (g_drawingInfo.nodes.size() <= PIXEL_MAP_INDEX) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, node size is %{public}zu", g_drawingInfo.nodes.size()); return RET_ERR; } std::shared_ptr shadowNode = g_drawingInfo.nodes[PIXEL_MAP_INDEX]; @@ -383,7 +383,7 @@ void DragDrawing::OnDragSuccess() return; } if (g_drawingInfo.nodes.size() <= PIXEL_MAP_INDEX || g_drawingInfo.nodes.size() <= DRAG_STYLE_INDEX) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, node size is %{public}zu", g_drawingInfo.nodes.size()); return; } std::shared_ptr shadowNode = g_drawingInfo.nodes[PIXEL_MAP_INDEX]; @@ -413,7 +413,7 @@ void DragDrawing::EraseMouseIcon() return; } if (g_drawingInfo.nodes.size() <= MOUSE_ICON_INDEX) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, node size is %{public}zu", g_drawingInfo.nodes.size()); return; } std::shared_ptr mouseIconNode = g_drawingInfo.nodes[MOUSE_ICON_INDEX]; @@ -576,7 +576,7 @@ void DragDrawing::StartStyleAnimation(float startScale, float endScale, int32_t return; } if (g_drawingInfo.nodes.size() <= DRAG_STYLE_INDEX) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, node size is %{public}zu", g_drawingInfo.nodes.size()); return; } std::shared_ptr dragStyleNode = g_drawingInfo.nodes[DRAG_STYLE_INDEX]; @@ -634,7 +634,7 @@ void DragDrawing::OnDragStyleAnimation() return; } if (g_drawingInfo.nodes.size() <= DRAG_STYLE_INDEX) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, node size is %{public}zu", g_drawingInfo.nodes.size()); return; } std::shared_ptr dragStyleNode = g_drawingInfo.nodes[DRAG_STYLE_INDEX]; @@ -694,7 +694,7 @@ void DragDrawing::OnStopAnimationSuccess() return; } if (g_drawingInfo.nodes.size() <= DRAG_STYLE_INDEX) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, node size is %{public}zu", g_drawingInfo.nodes.size()); return; } std::shared_ptr dragStyleNode = g_drawingInfo.nodes[DRAG_STYLE_INDEX]; @@ -767,7 +767,7 @@ void DragDrawing::OnStopAnimationFail() return; } if (g_drawingInfo.nodes.size() <= DRAG_STYLE_INDEX) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, node size is %{public}zu", g_drawingInfo.nodes.size()); return; } std::shared_ptr dragStyleNode = g_drawingInfo.nodes[DRAG_STYLE_INDEX]; @@ -868,7 +868,7 @@ int32_t DragDrawing::DrawMouseIcon() return RET_ERR; } if (g_drawingInfo.nodes.size() <= MOUSE_ICON_INDEX) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, node size is %{public}zu", g_drawingInfo.nodes.size()); return RET_ERR; } std::shared_ptr mouseIconNode = g_drawingInfo.nodes[MOUSE_ICON_INDEX]; @@ -1181,7 +1181,7 @@ void DragDrawing::RemoveModifier() } if (g_drawingInfo.nodes.size() <= PIXEL_MAP_INDEX || g_drawingInfo.nodes.size() <= DRAG_STYLE_INDEX) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, node size is %{public}zu", g_drawingInfo.nodes.size()); return; } std::shared_ptr pixelMapNode = g_drawingInfo.nodes[PIXEL_MAP_INDEX]; @@ -1554,7 +1554,7 @@ void DragDrawing::ProcessFilter() { FI_HILOGD("enter"); if (g_drawingInfo.nodes.size() <= BACKGROUND_FILTER_INDEX) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, node size is %{public}zu", g_drawingInfo.nodes.size()); return; } std::shared_ptr filterNode = g_drawingInfo.nodes[BACKGROUND_FILTER_INDEX]; @@ -1647,7 +1647,7 @@ int32_t DragDrawing::UpdatePreviewStyle(const PreviewStyle &previewStyle) { FI_HILOGD("enter"); if (g_drawingInfo.nodes.size() <= PIXEL_MAP_INDEX) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, node size is %{public}zu", g_drawingInfo.nodes.size()); return RET_ERR; } else if (ModifyPreviewStyle(g_drawingInfo.nodes[PIXEL_MAP_INDEX], previewStyle) != RET_OK) { FI_HILOGE("ModifyPreviewStyle failed"); @@ -1723,7 +1723,7 @@ void DragDrawing::DoDrawMouse() return; } if (g_drawingInfo.nodes.size() <= MOUSE_ICON_INDEX) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, node size is %{public}zu", g_drawingInfo.nodes.size()); return; } std::shared_ptr mouseIconNode = g_drawingInfo.nodes[MOUSE_ICON_INDEX]; @@ -1749,7 +1749,7 @@ int32_t DragDrawing::UpdateDefaultDragStyle(DragCursorStyle style) return RET_ERR; } if (g_drawingInfo.nodes.size() <= DRAG_STYLE_INDEX) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, node size is %{public}zu", g_drawingInfo.nodes.size()); return RET_ERR; } if (!g_drawingInfo.isCurrentDefaultStyle) { @@ -1776,7 +1776,7 @@ int32_t DragDrawing::UpdateValidDragStyle(DragCursorStyle style) return RET_ERR; } if (g_drawingInfo.nodes.size() <= DRAG_STYLE_INDEX) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, node size is %{public}zu", g_drawingInfo.nodes.size()); return RET_ERR; } std::shared_ptr dragStyleNode = g_drawingInfo.nodes[DRAG_STYLE_INDEX]; @@ -2076,7 +2076,7 @@ int32_t DragDrawing::DoRotateDragWindow(float rotation) return RET_ERR; } if (g_drawingInfo.nodes.size() <= MOUSE_ICON_INDEX) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, node size is %{public}zu", g_drawingInfo.nodes.size()); return RET_ERR; } std::shared_ptr mouseIconNode = g_drawingInfo.nodes[MOUSE_ICON_INDEX]; @@ -2231,7 +2231,7 @@ void DrawMouseIconModifier::OnDraw(std::shared_ptr pixelMap, in g_drawingInfo.mouseWidth = pixelMap->GetWidth(); g_drawingInfo.mouseHeight = pixelMap->GetHeight(); if (g_drawingInfo.nodes.size() <= MOUSE_ICON_INDEX) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, node size is %{public}zu", g_drawingInfo.nodes.size()); return; } std::shared_ptr mouseIconNode = g_drawingInfo.nodes[MOUSE_ICON_INDEX]; @@ -2292,7 +2292,7 @@ void DrawStyleChangeModifier::Draw(Rosen::RSDrawingContext &context) const return; } if (g_drawingInfo.nodes.size() <= DRAG_STYLE_INDEX) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, node size is %{public}zu", g_drawingInfo.nodes.size()); return; } std::shared_ptr dragStyleNode = g_drawingInfo.nodes[DRAG_STYLE_INDEX]; @@ -2348,7 +2348,7 @@ void DrawStyleScaleModifier::Draw(Rosen::RSDrawingContext &context) const return; } if (g_drawingInfo.nodes.size() <= DRAG_STYLE_INDEX) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, node size is %{public}zu", g_drawingInfo.nodes.size()); return; } std::shared_ptr dragStyleNode = g_drawingInfo.nodes[DRAG_STYLE_INDEX]; @@ -2383,7 +2383,7 @@ void DrawDragStopModifier::Draw(Rosen::RSDrawingContext &context) const g_drawingInfo.parentNode->SetAlpha(alpha_->Get()); g_drawingInfo.parentNode->SetScale(scale_->Get(), scale_->Get()); if (g_drawingInfo.nodes.size() <= DRAG_STYLE_INDEX) { - FI_HILOGE("The index is out of bounds"); + FI_HILOGE("The index is out of bounds, node size is %{public}zu", g_drawingInfo.nodes.size()); return; } std::shared_ptr dragStyleNode = g_drawingInfo.nodes[DRAG_STYLE_INDEX]; diff --git a/tools/vdev/src/virtual_device_builder.cpp b/tools/vdev/src/virtual_device_builder.cpp index cbbbde060..ed7850226 100644 --- a/tools/vdev/src/virtual_device_builder.cpp +++ b/tools/vdev/src/virtual_device_builder.cpp @@ -153,7 +153,7 @@ bool VirtualDeviceBuilder::ExecuteUnmount(const char *id, const char *name, cons spath << "/cmdline"; char realPath[PATH_MAX] = { 0 }; if (realpath(spath.str().c_str(), realPath) == nullptr) { - std::cout << "Invalid path" << spath.str().c_str() <