diff --git a/src/perf_events.cpp b/src/perf_events.cpp index dca64b69b86896775f11784e32b82acb28fb80db..26eb70df619fbb875e4589bbc76cf17c5179ec9a 100644 --- a/src/perf_events.cpp +++ b/src/perf_events.cpp @@ -1880,11 +1880,13 @@ void PerfEvents::StatLoop() durationInSec = usedTimeMsTick.count(); auto lefTimeMsTick = duration_cast(endTime - thisTime); if (reportPtr_ == nullptr) { - printf("\nReport at %" PRId64 " ms (%" PRId64 " ms left):\n", - (uint64_t)usedTimeMsTick.count(), (uint64_t)lefTimeMsTick.count()); + printf("\nReport at %" PRIu64 " ms (%" PRIu64 " ms left):\n", + static_cast(usedTimeMsTick.count()), + static_cast(lefTimeMsTick.count())); } else { - fprintf(reportPtr_, "\nReport at %" PRId64 " ms (%" PRId64 " ms left):\n", - (uint64_t)usedTimeMsTick.count(), (uint64_t)lefTimeMsTick.count()); + fprintf(reportPtr_, "\nReport at %" PRIu64 " ms (%" PRIu64 " ms left):\n", + static_cast(usedTimeMsTick.count()), + static_cast(lefTimeMsTick.count())); } // end of comments nextReportTime += timeReport_; @@ -1900,9 +1902,10 @@ void PerfEvents::StatLoop() usedTimeMsTick = duration_cast(thisTime - startTime); durationInSec = usedTimeMsTick.count(); if (reportPtr_ == nullptr) { - printf("Timeout exit (total %" PRId64 " ms)\n", (uint64_t)usedTimeMsTick.count()); + printf("Timeout exit (total %" PRIu64 " ms)\n", static_cast(usedTimeMsTick.count())); } else { - fprintf(reportPtr_, "Timeout exit (total %" PRId64 " ms)\n", (uint64_t)usedTimeMsTick.count()); + fprintf(reportPtr_, "Timeout exit (total %" PRIu64 " ms)\n", + static_cast(usedTimeMsTick.count())); } if (trackedCommand_) { trackedCommand_->Stop(); @@ -1925,7 +1928,7 @@ void PerfEvents::StatLoop() if (!g_trackRunning) { // for user interrupt situation, print time statistic usedTimeMsTick = duration_cast(steady_clock::now() - startTime); - printf("User interrupt exit (total %" PRId64 " ms)\n", (uint64_t)usedTimeMsTick.count()); + printf("User interrupt exit (total %" PRIu64 " ms)\n", static_cast(usedTimeMsTick.count())); } if (timeReport_ == milliseconds::zero()) { diff --git a/src/perf_pipe.cpp b/src/perf_pipe.cpp index 3825c5656e88557df880abd858b8be9a4b6c4143..0b2d70bb92e044dd258055d384fd9ab41ea2cb40 100644 --- a/src/perf_pipe.cpp +++ b/src/perf_pipe.cpp @@ -110,8 +110,8 @@ bool PerfPipe::SendFifoAndWaitReply(const std::string &cmd, const std::chrono::m close(fdRead); return false; } - size_t size = write(fdWrite, cmd.c_str(), cmd.size()); - if (size != cmd.size()) { + ssize_t size = write(fdWrite, cmd.c_str(), cmd.size()); + if (size != static_cast(cmd.size())) { HLOGE("failed to write fifo file(%s) command(%s)", fifoFileC2S_.c_str(), cmd.c_str()); HIPERF_HILOGE(MODULE_DEFAULT, "failed to write fifo file(%{public}s) command(%{public}s).", fifoFileC2S_.c_str(), cmd.c_str()); diff --git a/src/subcommand_record.cpp b/src/subcommand_record.cpp index 7cf8e6395941f730bd6d3082692c921708b50165..d1b9979ca9b0e54d4f6f37bdf1763a593f800607 100644 --- a/src/subcommand_record.cpp +++ b/src/subcommand_record.cpp @@ -788,7 +788,7 @@ pid_t SubCommandRecord::GetPidFromAppPackage(const pid_t oldPid, const uint64_t } std::string fileName {basePath + subDir + cmdline}; if (IsSameCommand(ReadFileToString(fileName), appPackage_)) { - res = std::stoul(subDir, nullptr); + res = static_cast(std::stoul(subDir, nullptr)); HLOGD("[GetAppPackagePid]: get appid for %s is %d", appPackage_.c_str(), res); return res; } @@ -1203,8 +1203,8 @@ bool SubCommandRecord::ClientCommandResponse(const std::string& str) return false; } } - size_t size = write(clientPipeOutput_, str.c_str(), str.size()); - if (size != str.size()) { + ssize_t size = write(clientPipeOutput_, str.c_str(), str.size()); + if (size != static_cast(str.size())) { char errInfo[ERRINFOLEN] = { 0 }; strerror_r(errno, errInfo, ERRINFOLEN); HLOGD("Server:%s -> %d : %zd %d:%s", str.c_str(), clientPipeOutput_, size, errno, errInfo); @@ -1223,8 +1223,8 @@ bool SubCommandRecord::ChildResponseToMain(bool response) bool SubCommandRecord::ChildResponseToMain(const std::string& str) { int tempFd = isHiperfClient_ ? clientPipeOutput_ : writeFd_; - size_t size = write(tempFd, str.c_str(), str.size()); - if (size != str.size()) { + ssize_t size = write(tempFd, str.c_str(), str.size()); + if (size != static_cast(str.size())) { char errInfo[ERRINFOLEN] = { 0 }; strerror_r(errno, errInfo, ERRINFOLEN); HLOGE("write pipe failed. str:%s, size:%zd, errno:%d:%s", str.c_str(), size, errno, errInfo); diff --git a/src/subcommand_stat.cpp b/src/subcommand_stat.cpp index b91531ec2e898a49b164c5b6f44e9f8e88db14a5..ce00f4a0a41adbe66ca8373ba9317e59525e5434 100644 --- a/src/subcommand_stat.cpp +++ b/src/subcommand_stat.cpp @@ -781,8 +781,8 @@ bool SubCommandStat::ClientCommandResponse(bool response) bool SubCommandStat::ClientCommandResponse(const std::string& str) { - size_t size = write(clientPipeOutput_, str.c_str(), str.size()); - if (size != str.size()) { + ssize_t size = write(clientPipeOutput_, str.c_str(), str.size()); + if (size != static_cast(str.size())) { char errInfo[ERRINFOLEN] = { 0 }; strerror_r(errno, errInfo, ERRINFOLEN); HLOGD("Server:%s -> %d : %zd %d:%s", str.c_str(), clientPipeOutput_, size, errno, errInfo);