diff --git a/device/plugins/memory_plugin/src/memory_data_plugin.cpp b/device/plugins/memory_plugin/src/memory_data_plugin.cpp index 6878f651a..04abf285a 100644 --- a/device/plugins/memory_plugin/src/memory_data_plugin.cpp +++ b/device/plugins/memory_plugin/src/memory_data_plugin.cpp @@ -67,8 +67,6 @@ MemoryDataPlugin::~MemoryDataPlugin() { PROFILER_LOG_INFO(LOG_CORE, "%s:~MemoryDataPlugin!", __func__); - buffer_ = nullptr; - if (meminfoFd_ > 0) { close(meminfoFd_); meminfoFd_ = -1; diff --git a/device/plugins/native_daemon/src/debug_logger.cpp b/device/plugins/native_daemon/src/debug_logger.cpp index 543707f1d..886875b51 100644 --- a/device/plugins/native_daemon/src/debug_logger.cpp +++ b/device/plugins/native_daemon/src/debug_logger.cpp @@ -85,7 +85,7 @@ int DebugLogger::Log(DebugLevel level, const std::string &logTag, const char *fm const auto startSprintf = steady_clock::now(); #endif const auto startTime = steady_clock::now(); - if (!ShouldLog(level, logTag) or logDisabled_ or fmt == nullptr) { + if (!ShouldLog(level, logTag) || logDisabled_ || fmt == nullptr) { #ifdef HIPERF_DEBUG_TIME logTimes_ += duration_cast(steady_clock::now() - startSprintf); #endif @@ -101,7 +101,7 @@ int DebugLogger::Log(DebugLevel level, const std::string &logTag, const char *fm #ifdef HIPERF_DEBUG_TIME logSprintfTimes_ += duration_cast(steady_clock::now() - startSprintf); #endif - if ((mixLogOutput_ and level < LEVEL_FATAL) or level == LEVEL_FATAL) { + if ((mixLogOutput_ && level < LEVEL_FATAL) || level == LEVEL_FATAL) { ret = fprintf(stdout, "%s", buffer.data()); // to the stdout } diff --git a/device/plugins/native_daemon/src/hook_manager.cpp b/device/plugins/native_daemon/src/hook_manager.cpp index f7871b9c0..d68811a3d 100644 --- a/device/plugins/native_daemon/src/hook_manager.cpp +++ b/device/plugins/native_daemon/src/hook_manager.cpp @@ -31,8 +31,6 @@ #include "share_memory_allocator.h" #include "utilities.h" #include "virtual_runtime.h" -#include "hook_common.h" -#include "common.h" #include "native_memory_profiler_sa_service.h" namespace OHOS::Developtools::NativeDaemon { diff --git a/device/plugins/native_daemon/src/virtual_runtime.cpp b/device/plugins/native_daemon/src/virtual_runtime.cpp index 6a52ba651..2a6856783 100644 --- a/device/plugins/native_daemon/src/virtual_runtime.cpp +++ b/device/plugins/native_daemon/src/virtual_runtime.cpp @@ -469,7 +469,7 @@ const DfxSymbol VirtualRuntime::GetSymbol(CallFrame& callFrame, pid_t pid, pid_t } else if (GetSymbolCache(callFrame.ip_, symbol, GetThread(pid, tid))) { return symbol; } - if (context == PERF_CONTEXT_USER or (context == PERF_CONTEXT_MAX and !symbol.IsValid())) { + if (context == PERF_CONTEXT_USER || (context == PERF_CONTEXT_MAX && !symbol.IsValid())) { // check userspace memmap symbol = GetUserSymbol(callFrame.ip_, GetThread(pid, tid)); if (symbol.IsValid()) { diff --git a/device/plugins/native_hook/src/runtime_stack_range.cpp b/device/plugins/native_hook/src/runtime_stack_range.cpp index dc3508b37..44fcd68ea 100644 --- a/device/plugins/native_hook/src/runtime_stack_range.cpp +++ b/device/plugins/native_hook/src/runtime_stack_range.cpp @@ -134,9 +134,9 @@ static void GetAnUnlimitedLine(FILE* fp, std::string& buf) static bool IsLegalSoName(const std::string &fileName) { - if (fileName.front() == '[' or fileName.back() == ']' or - std::strncmp(fileName.c_str(), "/dev/", sizeof("/dev/")) == 0 or - std::strncmp(fileName.c_str(), "/memfd:", sizeof("/memfd:")) == 0 or + if (fileName.front() == '[' || fileName.back() == ']' || + std::strncmp(fileName.c_str(), "/dev/", sizeof("/dev/")) == 0 || + std::strncmp(fileName.c_str(), "/memfd:", sizeof("/memfd:")) == 0 || std::strncmp(fileName.c_str(), "//anon", sizeof("//anon")) == 0) { return false; } diff --git a/device/services/profiler_service/src/trace_file_helper.cpp b/device/services/profiler_service/src/trace_file_helper.cpp index bb7eb66d8..273db3ce8 100644 --- a/device/services/profiler_service/src/trace_file_helper.cpp +++ b/device/services/profiler_service/src/trace_file_helper.cpp @@ -64,5 +64,4 @@ bool TraceFileHelper::Validate(const TraceFileHeader& header) { CHECK_TRUE(Finish(), false, "Finish FAILED!"); return memcmp(&header_, &header, sizeof(header_)) == 0; - return true; } diff --git a/hiebpf/src/bpf_event_receiver.cpp b/hiebpf/src/bpf_event_receiver.cpp index 72e4116b3..6876c7e07 100644 --- a/hiebpf/src/bpf_event_receiver.cpp +++ b/hiebpf/src/bpf_event_receiver.cpp @@ -403,7 +403,7 @@ int BPFEventReceiver::EncodeSTRTraceEvent( item->srcTracer_ = cmplt_event->start_event.stracer; item->srcType_ = cmplt_event->start_event.type; item->strLen_ = cmplt_event->len; - if (item->strLen_ and item->strLen_ <= MAX_FILENAME_LEN) { + if (item->strLen_ && item->strLen_ <= MAX_FILENAME_LEN) { char *filename = reinterpret_cast(tlvItem); filename += sizeof(struct FixedSTRTraceTLVItem); CHECK_TRUE(strncpy_s(filename, MAX_FILENAME_LEN, cmplt_event->filename, item->strLen_) == EOK, -1, diff --git a/hiebpf/src/elf_file.cpp b/hiebpf/src/elf_file.cpp index 2168a8fc8..3dfd26187 100644 --- a/hiebpf/src/elf_file.cpp +++ b/hiebpf/src/elf_file.cpp @@ -261,10 +261,10 @@ bool ElfHeader::Init(unsigned char * const ehdrBuf, const std::size_t bufSize) CHECK_TRUE(magicStr.compare(elfMagic) == 0, false, "elf magic not found"); std::copy(ehdrBuf, ehdrBuf + EI_NIDENT, ehdrIdent_); - if (ehdrBuf[EI_CLASS] == ELFCLASS32 and ParseElf32Header(ehdrBuf, bufSize)) { + if (ehdrBuf[EI_CLASS] == ELFCLASS32 && ParseElf32Header(ehdrBuf, bufSize)) { return true; } - if (ehdrBuf[EI_CLASS] == ELFCLASS64 and ParseElf64Header(ehdrBuf, bufSize)) { + if (ehdrBuf[EI_CLASS] == ELFCLASS64 && ParseElf64Header(ehdrBuf, bufSize)) { return true; } HHLOGE(true, "init elf header failed, elf header buffer dumped"); diff --git a/hiebpf/src/kernel_symbol_info.cpp b/hiebpf/src/kernel_symbol_info.cpp index 8f7dd09eb..5283a0c37 100644 --- a/hiebpf/src/kernel_symbol_info.cpp +++ b/hiebpf/src/kernel_symbol_info.cpp @@ -103,7 +103,6 @@ uint32_t KernelSymbolInfo::GetSymbolData(std::vector &buf) } prevSymbol = currSymbol; } - file.close(); if (prevSymbol.type_ == 'T') { symbolItems.emplace_back(prevSymbol); strTabLen += prevSymbol.name_.size() + 1; diff --git a/hiebpf/src/utilities.cpp b/hiebpf/src/utilities.cpp index b7ec79306..8efc5d34a 100644 --- a/hiebpf/src/utilities.cpp +++ b/hiebpf/src/utilities.cpp @@ -24,7 +24,7 @@ namespace Hiebpf { std::string ReadFileToString(const std::string &fileName) { std::ifstream inputString(fileName, std::ios::in); - if (!inputString or !inputString.is_open()) { + if (!inputString || !inputString.is_open()) { return EMPTY_STRING; } std::istreambuf_iterator firstIt = {inputString};