From 894dd06bd11570e04be030adf3fb87cd5be35026 Mon Sep 17 00:00:00 2001 From: youshugen Date: Sun, 20 Jul 2025 10:20:53 +0800 Subject: [PATCH] fix: code improve Signed-off-by: youshugen --- frameworks/native/power_mgr_client.cpp | 6 +++--- frameworks/native/running_lock_info.cpp | 3 ++- services/native/src/power_mgr_service_ipc_adapter.cpp | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/frameworks/native/power_mgr_client.cpp b/frameworks/native/power_mgr_client.cpp index 43a5e65e..4538fb40 100644 --- a/frameworks/native/power_mgr_client.cpp +++ b/frameworks/native/power_mgr_client.cpp @@ -46,7 +46,7 @@ std::vector> PowerMgrClient::runningLocks_; std::mutex PowerMgrClient::runningLocksMutex_; std::mutex g_instanceMutex; constexpr int32_t MAX_VERSION_STRING_SIZE = 4; -constexpr int32_t PARAM_MAX_NUM = 10; +constexpr uint32_t PARAM_MAX_NUM = 10; PowerMgrClient::PowerMgrClient() { @@ -573,9 +573,9 @@ std::string PowerMgrClient::Dump(const std::vector& args) sptr proxy = GetPowerMgrProxy(); RETURN_IF_WITH_RET(proxy == nullptr, error); std::string returnDump = "remote error"; - int32_t argc = args.size(); + uint32_t argc = args.size(); if (argc >= PARAM_MAX_NUM) { - POWER_HILOGW(COMP_FWK, "params exceed limit, argc=%{public}d", argc); + POWER_HILOGW(COMP_FWK, "params exceed limit, argc=%{public}u", argc); return returnDump; } proxy->ShellDumpIpc(args, argc, returnDump); diff --git a/frameworks/native/running_lock_info.cpp b/frameworks/native/running_lock_info.cpp index 38f62c0b..b55dbd04 100644 --- a/frameworks/native/running_lock_info.cpp +++ b/frameworks/native/running_lock_info.cpp @@ -22,7 +22,6 @@ namespace OHOS { namespace PowerMgr { -constexpr uint32_t MAX_PROXY_RUNNINGLOCK_NUM = 2000; bool RunningLockInfo::ReadFromParcel(Parcel& parcel) { uint32_t readType; @@ -68,6 +67,7 @@ bool RunningLockInfo::Marshalling(Parcel& parcel) const bool VectorPair::Marshalling(Parcel& parcel) const { + constexpr uint32_t MAX_PROXY_RUNNINGLOCK_NUM = 2000; size_t size = processInfos_.size(); RETURN_IF_WRITE_PARCEL_FAILED_WITH_RET(parcel, Int32, size, false); if (size > MAX_PROXY_RUNNINGLOCK_NUM) { @@ -83,6 +83,7 @@ bool VectorPair::Marshalling(Parcel& parcel) const VectorPair* VectorPair::Unmarshalling(Parcel& parcel) { + constexpr int32_t MAX_PROXY_RUNNINGLOCK_NUM = 2000; auto vectorPairPtr = std::make_unique(); int32_t size {0}; diff --git a/services/native/src/power_mgr_service_ipc_adapter.cpp b/services/native/src/power_mgr_service_ipc_adapter.cpp index 530154c1..6e18c17d 100644 --- a/services/native/src/power_mgr_service_ipc_adapter.cpp +++ b/services/native/src/power_mgr_service_ipc_adapter.cpp @@ -199,7 +199,7 @@ int32_t PowerMgrServiceAdapter::QueryRunningLockListsIpc(std::map(runningLockLists.size()); RETURN_IF_WITH_RET(num > MAX_PARAM_NUM, INIT_VALUE); return ERR_OK; } -- Gitee