From d01783e6399728980bf0d57d2fb022ecaf6b2220 Mon Sep 17 00:00:00 2001 From: Liumengkai <13322780+lmkgit@user.noreply.gitee.com> Date: Thu, 11 Jan 2024 10:15:05 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E9=99=A4=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Liumengkai <13322780+lmkgit@user.noreply.gitee.com> --- frameworks/js/napi/base/src/napi_common_utils.cpp | 2 +- services/core/ability/utils/src/sha256_utils.cpp | 2 +- services/engine/src/update_service_impl_firmware.cpp | 2 +- services/firmware/common/src/firmware_update_helper.cpp | 8 -------- .../src/firmware_download_data_processor.cpp | 2 +- .../upgrade/executor/src/firmware_download_executor.cpp | 4 ++-- 6 files changed, 6 insertions(+), 14 deletions(-) diff --git a/frameworks/js/napi/base/src/napi_common_utils.cpp b/frameworks/js/napi/base/src/napi_common_utils.cpp index 210fbcc9..fde1684c 100644 --- a/frameworks/js/napi/base/src/napi_common_utils.cpp +++ b/frameworks/js/napi/base/src/napi_common_utils.cpp @@ -70,7 +70,7 @@ int32_t NapiCommonUtils::GetString(napi_env env, napi_value arg, std::string &st std::vector buff(STRING_MAX_LENGTH); size_t copied; - status = napi_get_value_string_utf8(env, arg, (char*)buff.data(), STRING_MAX_LENGTH, &copied); + status = napi_get_value_string_utf8(env, arg, static_cast(buff.data()), STRING_MAX_LENGTH, &copied); PARAM_CHECK(status == napi_ok, return CAST_INT(ClientStatus::CLIENT_INVALID_TYPE), "Error get string"); strValue.assign(buff.data(), copied); return CAST_INT(ClientStatus::CLIENT_SUCCESS); diff --git a/services/core/ability/utils/src/sha256_utils.cpp b/services/core/ability/utils/src/sha256_utils.cpp index 5931ced3..c5373013 100644 --- a/services/core/ability/utils/src/sha256_utils.cpp +++ b/services/core/ability/utils/src/sha256_utils.cpp @@ -33,7 +33,7 @@ constexpr unsigned int SHA256_TO_STRING_STEP = 2; std::string Sha256Utils::CalculateHashCode(std::string inputStr) { char result[SHA256_STRING_LEN] = {0}; - if (!Sha256Calculate((unsigned char *)(inputStr.c_str()), inputStr.length(), result, SHA256_STRING_LEN)) { + if (!Sha256Calculate(reinterpret_cast(inputStr.c_str()), inputStr.length(), result, SHA256_STRING_LEN)) { ENGINE_LOGE("CalculateHashCode fail, src = %s", inputStr.c_str()); return ""; } diff --git a/services/engine/src/update_service_impl_firmware.cpp b/services/engine/src/update_service_impl_firmware.cpp index 0d293585..524eb5b6 100644 --- a/services/engine/src/update_service_impl_firmware.cpp +++ b/services/engine/src/update_service_impl_firmware.cpp @@ -40,7 +40,7 @@ int32_t UpdateServiceImplFirmware::CheckNewVersion(const UpgradeInfo &info, Busi { wptr weakPtr(this); FirmwareManager::GetInstance()->DoCheck( - [&, weakPtr](BusinessError &error, CheckResult &result) { + [&, weakPtr](const BusinessError &error, const CheckResult &result) { sptr firmwareSptr = weakPtr.promote(); if (firmwareSptr == nullptr) { FIRMWARE_LOGE("UpdateServiceImplFirmware has been destructed, CheckNewVersion is TimeOut"); diff --git a/services/firmware/common/src/firmware_update_helper.cpp b/services/firmware/common/src/firmware_update_helper.cpp index eeffd489..ad62df68 100644 --- a/services/firmware/common/src/firmware_update_helper.cpp +++ b/services/firmware/common/src/firmware_update_helper.cpp @@ -35,7 +35,6 @@ std::string FirmwareUpdateHelper::BuildTaskId(const std::vector preferencesUtil = DelayedSingleton::GetInstance(); FirmwareTask task; FirmwareTaskOperator firmwareTaskOperator; @@ -101,16 +100,9 @@ void FirmwareUpdateHelper::BuildNewVersionInfo(const std::vector components; FirmwareComponentOperator().QueryAll(components); - for (FirmwareComponent &component : components) { + for (const FirmwareComponent &component : components) { requireTotalSize += (Firmware::ONE_HUNDRED - component.progress) * component.size / Firmware::ONE_HUNDRED; } bool isDownloadSpaceEnough = FirmwareFileUtils::IsSpaceEnough(requireTotalSize); diff --git a/services/firmware/upgrade/executor/src/firmware_download_executor.cpp b/services/firmware/upgrade/executor/src/firmware_download_executor.cpp index 9ac08cd3..0f316c7e 100644 --- a/services/firmware/upgrade/executor/src/firmware_download_executor.cpp +++ b/services/firmware/upgrade/executor/src/firmware_download_executor.cpp @@ -103,7 +103,7 @@ void FirmwareDownloadExecutor::PerformDownload() }); int32_t ret = downloadThread_->StartDownload(downloadFileName, downloadInfo.url); if (ret != 0) { - Progress progress0; + progress0 = {}; progress0.status = UpgradeStatus::DOWNLOAD_FAIL; progress0.endReason = std::to_string(CAST_INT(DownloadEndReason::FAIL)); firmwareProgressCallback_.progressCallback(progress0); @@ -162,7 +162,7 @@ void FirmwareDownloadExecutor::DownloadCallback(std::string serverUrl, std::stri bool FirmwareDownloadExecutor::VerifyDownloadPkg(const std::string &pkgName, Progress &progress) { std::string verifyInfo = ""; - for (auto &component : components_) { + for (const auto &component : components_) { if (component.spath == pkgName) { verifyInfo = component.verifyInfo; break; -- Gitee