From 1e941b7050f32452692a26f32d8046f0ced21b94 Mon Sep 17 00:00:00 2001 From: xsz233 Date: Tue, 25 Oct 2022 21:30:24 +0800 Subject: [PATCH 1/2] fix alerts Signed-off-by: xsz233 --- .../src/bundle_manager_service.cpp | 6 ++-- .../src/gt_bundle_manager_service.cpp | 30 +++++++++---------- services/bundlemgr_lite/src/zip_file.cpp | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/services/bundlemgr_lite/src/bundle_manager_service.cpp b/services/bundlemgr_lite/src/bundle_manager_service.cpp index 8fab372..bb81de6 100644 --- a/services/bundlemgr_lite/src/bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/bundle_manager_service.cpp @@ -123,7 +123,7 @@ bool ManagerService::GetAmsInterface(AmsInnerInterface **amsInterface) return false; } - int result = iUnknown->QueryInterface(iUnknown, 0, (void **) amsInterface); + int result = iUnknown->QueryInterface(iUnknown, 0, reinterpret_cast(amsInterface)); if (result != 0) { HILOG_ERROR(HILOG_MODULE_APP, "BundleMS Query ams Interface failed: %{public}d\n", result); return false; @@ -647,8 +647,8 @@ uint32_t ManagerService::GetBundleSize(const char *bundleName) std::string ManagerService::GetCodeDirPath() const { - std::string codeDirPath; if (installer_ == nullptr) { + std::string codeDirPath; return codeDirPath; } return installer_->GetCodeDirPath(); @@ -656,8 +656,8 @@ std::string ManagerService::GetCodeDirPath() const std::string ManagerService::GetDataDirPath() const { - std::string dataDirPath; if (installer_ == nullptr) { + std::string dataDirPath; return dataDirPath; } return installer_->GetDataDirPath(); diff --git a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp index 4b00319..f83af62 100755 --- a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp @@ -320,17 +320,17 @@ void GtManagerService::InstallAllSystemBundle(InstallerCallback installerCallbac if (currentNode == nullptr) { return; } - if ((strcmp(((AppInfoList *)currentNode)->filePath, ".") == 0) || - (strcmp(((AppInfoList *)currentNode)->filePath, "..") == 0)) { + if ((strcmp((reinterpret_cast(currentNode))->filePath, ".") == 0) || + (strcmp((reinterpret_cast(currentNode))->filePath, "..") == 0)) { continue; } - if (!BundleUtil::IsFile(((AppInfoList *)currentNode)->filePath) || - !BundleUtil::EndWith(((AppInfoList *)currentNode)->filePath, INSTALL_FILE_SUFFIX)) { + if (!BundleUtil::IsFile((reinterpret_cast(currentNode))->filePath) || + !BundleUtil::EndWith((reinterpret_cast(currentNode))->filePath, INSTALL_FILE_SUFFIX)) { GtManagerService::APP_FreeAllAppInfo(list); return; } - (void) Install(((AppInfoList *)currentNode)->filePath, nullptr, installerCallback); + (void) Install((reinterpret_cast(currentNode))->filePath, nullptr, installerCallback); } GtManagerService::APP_FreeAllAppInfo(list); } @@ -441,21 +441,21 @@ void GtManagerService::ScanSystemApp(const cJSON *uninstallRecord, ListfilePath, ".") == 0) || - (strcmp(((AppInfoList *)currentNode)->filePath, "..") == 0)) { + if ((strcmp((reinterpret_cast(currentNode))->filePath, ".") == 0) || + (strcmp((reinterpret_cast(currentNode))->filePath, "..") == 0)) { continue; } - if (BundleUtil::StartWith(((AppInfoList *)currentNode)->filePath, SYSTEM_BUNDLE_PATH)) { + if (BundleUtil::StartWith((reinterpret_cast(currentNode))->filePath, SYSTEM_BUNDLE_PATH)) { scanFlag = SYSTEM_APP_FLAG; - } else if (BundleUtil::StartWith(((AppInfoList *)currentNode)->filePath, THIRD_SYSTEM_BUNDLE_PATH)) { + } else if (BundleUtil::StartWith((reinterpret_cast(currentNode))->filePath, THIRD_SYSTEM_BUNDLE_PATH)) { scanFlag = THIRD_SYSTEM_APP_FLAG; } else { continue; // skip third app } // scan system app - bool res = CheckSystemBundleIsValid(((AppInfoList *)currentNode)->filePath, &bundleName, versionCode); + bool res = CheckSystemBundleIsValid((reinterpret_cast(currentNode))->filePath, &bundleName, versionCode); if (!res) { APP_ERRCODE_EXTRA(EXCE_ACE_APP_SCAN, EXCE_ACE_APP_SCAN_INVALID_SYSTEM_APP); AdapterFree(bundleName); @@ -469,7 +469,7 @@ void GtManagerService::ScanSystemApp(const cJSON *uninstallRecord, ListfilePath, bundleName, + ReloadEntireBundleInfo((reinterpret_cast(currentNode))->filePath, bundleName, systemPathList, versionCode, scanFlag); AdapterFree(bundleName); } @@ -979,7 +979,7 @@ int32_t GtManagerService::ReportUninstallCallback(uint8_t errCode, uint8_t insta AppInfoList *GtManagerService::APP_InitAllAppInfo() { - AppInfoList *list = (AppInfoList *)AdapterMalloc(sizeof(AppInfoList)); + AppInfoList *list = reinterpret_cast(AdapterMalloc(sizeof(AppInfoList))); if (list == nullptr) { return nullptr; } @@ -1054,7 +1054,7 @@ void GtManagerService::APP_InsertAppInfo(char *filePath, AppInfoList *list) return; } - AppInfoList *app = (AppInfoList *)AdapterMalloc(sizeof(AppInfoList)); + AppInfoList *app = reinterpret_cast(AdapterMalloc(sizeof(AppInfoList))); if (app == nullptr) { return; } @@ -1110,7 +1110,7 @@ void SetCurrentBundle(const char *name) } int len = strlen(name); - g_currentBundle = (char *)AdapterMalloc(len + 1); + g_currentBundle = static_cast(AdapterMalloc(len + 1)); if (g_currentBundle == nullptr || strncpy_s(g_currentBundle, len + 1, name, len) < 0) { AdapterFree(g_currentBundle); } @@ -1126,7 +1126,7 @@ const char *GetCurrentBundle() } int len = strlen(g_currentBundle); - char *bundleName = (char *)AdapterMalloc(len + 1); + char *bundleName = static_cast(AdapterMalloc(len + 1)); if (bundleName == nullptr || strncpy_s(bundleName, len + 1, g_currentBundle, len) < 0) { AdapterFree(bundleName); MutexRelease(&g_currentBundleMutex); diff --git a/services/bundlemgr_lite/src/zip_file.cpp b/services/bundlemgr_lite/src/zip_file.cpp index 0970ae9..c680ba5 100755 --- a/services/bundlemgr_lite/src/zip_file.cpp +++ b/services/bundlemgr_lite/src/zip_file.cpp @@ -509,7 +509,7 @@ bool ZipFile::UnzipWithInflated(const ZipEntry &zipEntry, const uint16_t extraSi size_t inflateLen = UNZIP_BUF_OUT_LEN - zstream.avail_out; if (inflateLen > 0) { - dest.write((const char*)bufOut, inflateLen); + dest.write(reinterpret_cast(bufOut), inflateLen); zstream.next_out = bufOut; zstream.avail_out = UNZIP_BUF_OUT_LEN; errorTimes = 0; -- Gitee From 83ae50a5cb0b3d948ea39b926ee99bcc48fc238b Mon Sep 17 00:00:00 2001 From: xsz233 Date: Thu, 27 Oct 2022 10:50:25 +0800 Subject: [PATCH 2/2] fix alerts Signed-off-by: xsz233 --- .../src/bundle_manager_service.cpp | 6 ++-- .../src/gt_bundle_manager_service.cpp | 30 +++++++++---------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/services/bundlemgr_lite/src/bundle_manager_service.cpp b/services/bundlemgr_lite/src/bundle_manager_service.cpp index bb81de6..f72805e 100644 --- a/services/bundlemgr_lite/src/bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/bundle_manager_service.cpp @@ -648,8 +648,7 @@ uint32_t ManagerService::GetBundleSize(const char *bundleName) std::string ManagerService::GetCodeDirPath() const { if (installer_ == nullptr) { - std::string codeDirPath; - return codeDirPath; + return ""; } return installer_->GetCodeDirPath(); } @@ -657,8 +656,7 @@ std::string ManagerService::GetCodeDirPath() const std::string ManagerService::GetDataDirPath() const { if (installer_ == nullptr) { - std::string dataDirPath; - return dataDirPath; + return ""; } return installer_->GetDataDirPath(); } diff --git a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp index f83af62..4b00319 100755 --- a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp @@ -320,17 +320,17 @@ void GtManagerService::InstallAllSystemBundle(InstallerCallback installerCallbac if (currentNode == nullptr) { return; } - if ((strcmp((reinterpret_cast(currentNode))->filePath, ".") == 0) || - (strcmp((reinterpret_cast(currentNode))->filePath, "..") == 0)) { + if ((strcmp(((AppInfoList *)currentNode)->filePath, ".") == 0) || + (strcmp(((AppInfoList *)currentNode)->filePath, "..") == 0)) { continue; } - if (!BundleUtil::IsFile((reinterpret_cast(currentNode))->filePath) || - !BundleUtil::EndWith((reinterpret_cast(currentNode))->filePath, INSTALL_FILE_SUFFIX)) { + if (!BundleUtil::IsFile(((AppInfoList *)currentNode)->filePath) || + !BundleUtil::EndWith(((AppInfoList *)currentNode)->filePath, INSTALL_FILE_SUFFIX)) { GtManagerService::APP_FreeAllAppInfo(list); return; } - (void) Install((reinterpret_cast(currentNode))->filePath, nullptr, installerCallback); + (void) Install(((AppInfoList *)currentNode)->filePath, nullptr, installerCallback); } GtManagerService::APP_FreeAllAppInfo(list); } @@ -441,21 +441,21 @@ void GtManagerService::ScanSystemApp(const cJSON *uninstallRecord, List(currentNode))->filePath, ".") == 0) || - (strcmp((reinterpret_cast(currentNode))->filePath, "..") == 0)) { + if ((strcmp(((AppInfoList *)currentNode)->filePath, ".") == 0) || + (strcmp(((AppInfoList *)currentNode)->filePath, "..") == 0)) { continue; } - if (BundleUtil::StartWith((reinterpret_cast(currentNode))->filePath, SYSTEM_BUNDLE_PATH)) { + if (BundleUtil::StartWith(((AppInfoList *)currentNode)->filePath, SYSTEM_BUNDLE_PATH)) { scanFlag = SYSTEM_APP_FLAG; - } else if (BundleUtil::StartWith((reinterpret_cast(currentNode))->filePath, THIRD_SYSTEM_BUNDLE_PATH)) { + } else if (BundleUtil::StartWith(((AppInfoList *)currentNode)->filePath, THIRD_SYSTEM_BUNDLE_PATH)) { scanFlag = THIRD_SYSTEM_APP_FLAG; } else { continue; // skip third app } // scan system app - bool res = CheckSystemBundleIsValid((reinterpret_cast(currentNode))->filePath, &bundleName, versionCode); + bool res = CheckSystemBundleIsValid(((AppInfoList *)currentNode)->filePath, &bundleName, versionCode); if (!res) { APP_ERRCODE_EXTRA(EXCE_ACE_APP_SCAN, EXCE_ACE_APP_SCAN_INVALID_SYSTEM_APP); AdapterFree(bundleName); @@ -469,7 +469,7 @@ void GtManagerService::ScanSystemApp(const cJSON *uninstallRecord, List(currentNode))->filePath, bundleName, + ReloadEntireBundleInfo(((AppInfoList *)currentNode)->filePath, bundleName, systemPathList, versionCode, scanFlag); AdapterFree(bundleName); } @@ -979,7 +979,7 @@ int32_t GtManagerService::ReportUninstallCallback(uint8_t errCode, uint8_t insta AppInfoList *GtManagerService::APP_InitAllAppInfo() { - AppInfoList *list = reinterpret_cast(AdapterMalloc(sizeof(AppInfoList))); + AppInfoList *list = (AppInfoList *)AdapterMalloc(sizeof(AppInfoList)); if (list == nullptr) { return nullptr; } @@ -1054,7 +1054,7 @@ void GtManagerService::APP_InsertAppInfo(char *filePath, AppInfoList *list) return; } - AppInfoList *app = reinterpret_cast(AdapterMalloc(sizeof(AppInfoList))); + AppInfoList *app = (AppInfoList *)AdapterMalloc(sizeof(AppInfoList)); if (app == nullptr) { return; } @@ -1110,7 +1110,7 @@ void SetCurrentBundle(const char *name) } int len = strlen(name); - g_currentBundle = static_cast(AdapterMalloc(len + 1)); + g_currentBundle = (char *)AdapterMalloc(len + 1); if (g_currentBundle == nullptr || strncpy_s(g_currentBundle, len + 1, name, len) < 0) { AdapterFree(g_currentBundle); } @@ -1126,7 +1126,7 @@ const char *GetCurrentBundle() } int len = strlen(g_currentBundle); - char *bundleName = static_cast(AdapterMalloc(len + 1)); + char *bundleName = (char *)AdapterMalloc(len + 1); if (bundleName == nullptr || strncpy_s(bundleName, len + 1, g_currentBundle, len) < 0) { AdapterFree(bundleName); MutexRelease(&g_currentBundleMutex); -- Gitee