diff --git a/device/plugins/gpu_plugin/src/test_main.cpp b/device/plugins/gpu_plugin/src/test_main.cpp index f059ab007..9db49e5b7 100644 --- a/device/plugins/gpu_plugin/src/test_main.cpp +++ b/device/plugins/gpu_plugin/src/test_main.cpp @@ -33,7 +33,7 @@ int main(int agrc, char* agrv[]) return 0; } std::cout << "test:handle = " << handle << std::endl; - gpuPlugin = static_cast(dlsym(handle, "g_pluginModule")); + gpuPlugin = reinterpret_cast(dlsym(handle, "g_pluginModule")); std::cout << "test:name = " << gpuPlugin->name << std::endl; std::cout << "test:buffer size = " << gpuPlugin->resultBufferSizeHint << std::endl; diff --git a/device/plugins/memory_plugin/include/memory_data_plugin.h b/device/plugins/memory_plugin/include/memory_data_plugin.h index b76217c5f..298b74982 100644 --- a/device/plugins/memory_plugin/include/memory_data_plugin.h +++ b/device/plugins/memory_plugin/include/memory_data_plugin.h @@ -318,8 +318,8 @@ enum WinMgrSvcType { }; struct GraphicsMemory { - uint64_t gl; - uint64_t graph; + uint64_t gl = 0; + uint64_t graph = 0; }; const std::vector> MEMORY_TRACKER_TYPES = { @@ -362,14 +362,14 @@ private: std::unique_ptr buffer_; - int meminfoFd_; - int vmstatFd_; - std::map meminfoCounters_; - std::map vmstatCounters_; + int meminfoFd_ = -1; + int vmstatFd_ = -1; + std::map meminfoCounters_ = {}; + std::map vmstatCounters_ = {}; void InitProto2StrVector(); - std::vector meminfoStrList_; - std::vector vmstatStrList_; + std::vector meminfoStrList_ = {}; + std::vector vmstatStrList_ = {}; // SmapsStats * template void WriteVmstat(T& memoryData); @@ -378,10 +378,10 @@ private: template void WriteZramData(T& memoryData); - std::unordered_map> pidFds_; - std::vector seenPids_; - char* testpath_; - int32_t err_; + std::unordered_map> pidFds_ = {}; + std::vector seenPids_ = {}; + char* testpath_ = nullptr; + int32_t err_ = -1; int32_t ReadFile(int fd); std::string ReadFile(const std::string& path); std::vector OpenProcPidFiles(int32_t pid); diff --git a/device/plugins/native_daemon/include/hook_standalone.h b/device/plugins/native_daemon/include/hook_standalone.h index 900ad7f58..9cfb73285 100644 --- a/device/plugins/native_daemon/include/hook_standalone.h +++ b/device/plugins/native_daemon/include/hook_standalone.h @@ -21,7 +21,7 @@ #include struct HookData { - std::set pids; + std::set pids = {}; uint32_t smbSize {0}; uint64_t duration {0}; uint32_t filterSize {0}; diff --git a/device/plugins/native_daemon/native_daemon_client.cpp b/device/plugins/native_daemon/native_daemon_client.cpp index cc9eb049f..73f91c6cd 100644 --- a/device/plugins/native_daemon/native_daemon_client.cpp +++ b/device/plugins/native_daemon/native_daemon_client.cpp @@ -26,8 +26,8 @@ using namespace OHOS::Developtools::NativeDaemon; static uint32_t TestDumpFile() { - uint32_t fd = open("/data/local/tmp/test_dump_file.htrace", - O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + uint32_t fd = static_cast(open("/data/local/tmp/test_dump_file.htrace", + O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)); return fd; } @@ -102,7 +102,7 @@ int32_t main(int32_t argc, char* argv[]) } else if ((arg == "--munmapStackData") || (arg == "-musd")) { config->munmapStackData_ = true; } else if ((arg == "--mallocFreeMatchingInterval") || (arg == "-mfmi")) { - config->mallocFreeMatchingInterval_ = std::stoi(argv[++i]); + config->mallocFreeMatchingInterval_ = static_cast(std::stoi(argv[++i])); } else if ((arg == "--mallocFreeMatchingCnt") || (arg == "-mfmc")) { config->mallocFreeMatchingCnt_ = std::stoi(argv[++i]); } else if ((arg == "--disable_stringCompressed") || (arg == "-sc")) { diff --git a/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_service.cpp b/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_service.cpp index 825b0da96..1ee76b565 100644 --- a/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_service.cpp +++ b/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_service.cpp @@ -54,7 +54,10 @@ bool NativeMemoryProfilerSaService::StartServiceAbility() CHECK_NOTNULL(serviceManager, false, "serviceManager is nullptr"); auto native = new NativeMemoryProfilerSaService(); - CHECK_NOTNULL(native, false, "native is nullptr"); + if (native == nullptr) { + HILOG_ERROR(LOG_CORE, "native is nullptr"); + return false; + } int32_t result = serviceManager->AddSystemAbility(NATIVE_DAEMON_SYSTEM_ABILITY_ID, native); if (result != 0) { HILOG_ERROR(LOG_CORE, "Service native memory failed to start"); diff --git a/device/plugins/native_daemon/src/hook_manager.cpp b/device/plugins/native_daemon/src/hook_manager.cpp index 67e688081..a53b698a3 100644 --- a/device/plugins/native_daemon/src/hook_manager.cpp +++ b/device/plugins/native_daemon/src/hook_manager.cpp @@ -221,7 +221,7 @@ bool HookManager::HandleHookContext(const std::shared_ptr& ctx) return false; } // create smb and eventNotifier - uint32_t bufferSize = hookConfig_.smb_pages() * PAGE_BYTES; /* bufferConfig.pages() */ + uint32_t bufferSize = static_cast(hookConfig_.smb_pages()) * PAGE_BYTES; /* bufferConfig.pages() */ ctx->shareMemoryBlock = ShareMemoryAllocator::GetInstance().CreateMemoryBlockLocal(ctx->smbName, bufferSize); CHECK_TRUE(ctx->shareMemoryBlock != nullptr, false, "CreateMemoryBlockLocal FAIL %s", ctx->smbName.c_str()); diff --git a/device/plugins/native_daemon/src/hook_standalone.cpp b/device/plugins/native_daemon/src/hook_standalone.cpp index 9b606f5d5..777772d61 100644 --- a/device/plugins/native_daemon/src/hook_standalone.cpp +++ b/device/plugins/native_daemon/src/hook_standalone.cpp @@ -34,7 +34,6 @@ std::shared_ptr g_hookManager; NativeHookConfig g_nativeConfig; static void SignalHandl(int signo) { - HILOG_INFO(LOG_CORE, "SignalHandl recv %d", signo); std::vector pluginIds; g_hookManager->StopPluginSession(pluginIds); g_hookManager->DestroyPluginSession(pluginIds); diff --git a/device/plugins/native_daemon/src/stack_preprocess.cpp b/device/plugins/native_daemon/src/stack_preprocess.cpp index 41aae09b2..5133f402b 100644 --- a/device/plugins/native_daemon/src/stack_preprocess.cpp +++ b/device/plugins/native_daemon/src/stack_preprocess.cpp @@ -427,11 +427,6 @@ void StackPreprocess::SetEventFrame(const RawStackPtr& rawStack, if (hookConfig_.callframe_compress() && stackMapId != 0) { event->set_stack_id(stackMapId); - } else if (hookConfig_.string_compressed()) { - for (; idx < callFrames.size(); ++idx) { - Frame* frame = event->add_frame_info(); - SetFrameInfo(*frame, callFrames[idx]); - } } else { for (; idx < callFrames.size(); ++idx) { Frame* frame = event->add_frame_info(); diff --git a/device/plugins/native_daemon/src/virtual_thread.cpp b/device/plugins/native_daemon/src/virtual_thread.cpp index eb44451b0..f800a4c35 100644 --- a/device/plugins/native_daemon/src/virtual_thread.cpp +++ b/device/plugins/native_daemon/src/virtual_thread.cpp @@ -225,8 +225,10 @@ bool VirtualThread::ParseMap(std::vector>& memMaps, bool std::shared_ptr dfxMaps = OHOS::HiviewDFX::DfxMaps::Create(pid_, mapPath); if (dfxMaps == nullptr) { HLOGE("VirtualThread Failed to Parse Map."); + } else { + memMaps = dfxMaps->GetMaps(); } - memMaps = dfxMaps->GetMaps(); + bool mapsAdded = !update; std::vector> tempMap; std::string tempMapName; @@ -296,7 +298,7 @@ void VirtualThread::SortMaps() } if (targetPos < static_cast(currPos - 1)) { auto target = (*maps_)[currPos]; - for (size_t k = currPos - 1; k > targetPos; --k) { + for (size_t k = currPos - 1; k > static_cast(targetPos); --k) { (*maps_)[k + 1] = (*maps_)[k]; } (*maps_)[targetPos + 1] = target; diff --git a/proto_encoder/src/base_message.cpp b/proto_encoder/src/base_message.cpp index 8ba9149d0..770349b1a 100755 --- a/proto_encoder/src/base_message.cpp +++ b/proto_encoder/src/base_message.cpp @@ -85,7 +85,6 @@ void BaseMessage::AddBytes(uint32_t fieldId, const void* data, uint32_t dataSize uint8_t* fieldMemory = nullptr; uint32_t fieldOffset = 0; - // max field size = varint(fieldId + type) + varint(dataSize) + dataSize if (!writeCtx_->getMemory(writeCtx_, VARINT_ENCODE_MAX_SIZE + SIZE_RESERVED_LEN + dataSize, &fieldMemory, &fieldOffset)) { Drop();