!834 profiler告警清理

Merge pull request !834 from zhangcui/master
This commit is contained in:
openharmony_ci 2023-03-23 09:44:05 +00:00 committed by Gitee
commit 3fccad604b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
8 changed files with 10 additions and 14 deletions

View File

@ -324,7 +324,7 @@ bool CheckApplicationPermission(int pid, const std::string& processName)
HILOG_ERROR(LOG_CORE, "Get process name by pid failed!");
return false;
}
bundleName = bundleName.substr(0, strlen(bundleName.c_str()));
bundleName.resize(strlen(bundleName.c_str()));
} else {
bundleName = processName;
}

View File

@ -58,7 +58,7 @@ inline uint64_t GetTimestampIncrements(uint64_t ext)
return ext << TS_EXT_SHIFT;
}
bool ReadInc(uint8_t* start[], uint8_t end[], void* outData, size_t outSize)
bool ReadInc(uint8_t* start[], const uint8_t end[], void* outData, size_t outSize)
{
if ((end - *start) < static_cast<ptrdiff_t>(outSize)) {
return false;

View File

@ -29,7 +29,6 @@
namespace {
constexpr int RD = 0;
constexpr int WR = 1;
constexpr int INVALID_FD = -1;
} // namespace
struct PipedSigHandler {
@ -136,21 +135,18 @@ static bool ExecuteProcess(const std::string& bin,
int errFd = nullFd;
CHECK_TRUE(inFd >= 0, false, "open /dev/null failed, %d", errno);
CHECK_TRUE(dup2(inFd, STDIN_FILENO) != -1, false, "dup nullFD to stdin failed, %d", errno);
inFd = INVALID_FD; // for static check warning
// redirect outFd to stdout
if (out2pipe) {
outFd = pipeFd;
}
CHECK_TRUE(dup2(outFd, STDOUT_FILENO) != -1, false, "dup fd %d to stdout failed, %d", outFd, errno);
outFd = INVALID_FD; // for static check warning
// redirect errFd to stderr
if (err2pipe) {
errFd = pipeFd;
}
CHECK_TRUE(dup2(errFd, STDERR_FILENO) != -1, false, "dup fd %d to stderr failed, %d", errFd, errno);
errFd = INVALID_FD; // for static check warning
CHECK_TRUE(close(nullFd) != -1, false, "close nullFd failed, %d", errno);
CHECK_TRUE(close(pipeFd) != -1, false, "close pipeFd failed, %d", errno);

View File

@ -295,7 +295,7 @@ bool ElfFile::ParseSymNamesStr()
const auto &shdr = shdrs_[secName];
uint64_t secOffset = shdr->fileOffset_;
uint64_t secSize = shdr->secSize_;
int64_t ret = lseek(fd_, secOffset, SEEK_SET);
(void)lseek(fd_, secOffset, SEEK_SET);
char *secBuf = new (std::nothrow) char[secSize];
if (secBuf == nullptr) {
HLOGE("Error in ElfFile::ParsesymNamesStr(): new failed");
@ -304,7 +304,7 @@ bool ElfFile::ParseSymNamesStr()
if (memset_s(secBuf, secSize, '\0', secSize) != EOK) {
HLOGE("memset failed");
}
ret = ReadFile(secBuf, secSize);
int64_t ret = ReadFile(secBuf, secSize);
HLOG_ASSERT(ret == static_cast<int64_t>(secSize));
symNamesStr_ = std::string(secBuf, secSize);
if (symNamesStr_ == "") {

View File

@ -238,7 +238,7 @@ void* ThreadFuncC(void* param)
// 打开文件到内存中
int OpenFile(const char* fileName)
{
int fd = open(fileName, O_RDWR | O_CREAT, (mode_t)0777);
int fd = open(fileName, O_RDWR | O_CREAT, (mode_t)0644); // 0644 rw-r--r--
if (fd == -1) {
printf("can not open the file\n");
return -1;

View File

@ -256,7 +256,7 @@ static void* ThreadFuncC(void* param)
// 打开文件到内存中
static int OpenFile(const char* fileName)
{
int fd = open(fileName, O_RDWR | O_CREAT, (mode_t)0777);
int fd = open(fileName, O_RDWR | O_CREAT, (mode_t)0644); // 0644 rw-r--r--
if (fd == -1) {
printf("can not open the file\n");
return -1;

View File

@ -582,7 +582,7 @@ bool ProcessDataPlugin::WritePssData(int pid, PssInfo* protoc)
getline(input, line);
line += '\n';
std::string::size_type pos = 0u;
if ((pos = line.find("Pss:", pos)) != std::string::npos) {
if (line.find("Pss:", pos) != std::string::npos) {
char* pTmp = const_cast<char*>(line.c_str());
uint64_t num;
CHECK_TRUE(GetValidValue(pTmp, num), false, "%s: FindFirstNum failed", __func__);

View File

@ -794,7 +794,7 @@ int BPFController::DumpFSTraceEvent(BPFController *bpfctlr, void *data, size_t d
<< "\nips: " << cmplt_event.nips
<< "\nips:"
<< std::setw(16) << std::hex;
for (int i = 0; i < cmplt_event.nips; ++i) {
for (uint32_t i = 0; i < cmplt_event.nips; ++i) {
std::cout << "\n " << cmplt_event.ips[i];
}
std::cout << std::dec << std::endl;
@ -837,7 +837,7 @@ int BPFController::DumpPFTraceEvent(BPFController *bpfctlr, void *data, size_t d
<< "\ncomm: " << cmplt_event.comm
<< "\nips: " << cmplt_event.nips
<< std::setw(16) << std::hex;
for (int i = 0; i < cmplt_event.nips; ++i) {
for (uint32_t i = 0; i < cmplt_event.nips; ++i) {
std::cout << "\n " << cmplt_event.ips[i];
}
std::cout << std::dec << std::endl;
@ -881,7 +881,7 @@ int BPFController::DumpBIOTraceEvent(BPFController *bpfctlr, void *data, size_t
<< "\nblkcnt: " << cmplt_event.blkcnt
<< "\nips: " << cmplt_event.nips
<< std::setw(16) << std::hex;
for (int i = 0; i < cmplt_event.nips; ++i) {
for (uint32_t i = 0; i < cmplt_event.nips; ++i) {
std::cout << "\n " << cmplt_event.ips[i];
}
std::cout << std::dec << std::endl;