diff --git a/common/log/src/app_log_wrapper.cpp b/common/log/src/app_log_wrapper.cpp index d9706b946..75de555d6 100644 --- a/common/log/src/app_log_wrapper.cpp +++ b/common/log/src/app_log_wrapper.cpp @@ -32,7 +32,7 @@ std::string AppLogWrapper::GetBriefFileName(const char *str) return std::string(); } std::string fullPath(str); - size_t pos = fullPath.find_last_of("/"); + size_t pos = fullPath.find_last_of('/'); if (pos == std::string::npos) { return std::string(); } diff --git a/common/utils/src/bundle_file_util.cpp b/common/utils/src/bundle_file_util.cpp index 11ad31e67..c0326e889 100644 --- a/common/utils/src/bundle_file_util.cpp +++ b/common/utils/src/bundle_file_util.cpp @@ -89,7 +89,7 @@ bool BundleFileUtil::CheckFilePath(const std::vector &bundlePaths, if (bundlePaths.size() == 1) { APP_LOGD("bundlePaths only has one element"); - std::string bundlePath = bundlePaths.front(); + const std::string& bundlePath = bundlePaths.front(); std::string realPath = ""; // it is a file if (CheckFilePath(bundlePaths.front(), realPath)) { diff --git a/interfaces/inner_api/appexecfwk_base/include/bundle_common_event.h b/interfaces/inner_api/appexecfwk_base/include/bundle_common_event.h index 9f2c3d1e0..61c7690bb 100644 --- a/interfaces/inner_api/appexecfwk_base/include/bundle_common_event.h +++ b/interfaces/inner_api/appexecfwk_base/include/bundle_common_event.h @@ -16,8 +16,6 @@ #ifndef FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_COMMON_EVENT_H #define FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_COMMON_EVENT_H -#include - namespace OHOS { namespace AppExecFwk { constexpr const char* COMMON_EVENT_SANDBOX_PACKAGE_ADDED = "usual.event.SANDBOX_PACKAGE_ADDED"; diff --git a/interfaces/inner_api/appexecfwk_base/include/launcher_ability_info.h b/interfaces/inner_api/appexecfwk_base/include/launcher_ability_info.h index e42c0058e..bc994ab9d 100644 --- a/interfaces/inner_api/appexecfwk_base/include/launcher_ability_info.h +++ b/interfaces/inner_api/appexecfwk_base/include/launcher_ability_info.h @@ -24,7 +24,6 @@ namespace OHOS { namespace AppExecFwk { struct LauncherAbilityInfo { -public: ApplicationInfo applicationInfo; ElementName elementName; // bundle name , ability name, deviceid uint32_t labelId = 0; diff --git a/interfaces/inner_api/appexecfwk_base/include/overlay/overlay_bundle_info.h b/interfaces/inner_api/appexecfwk_base/include/overlay/overlay_bundle_info.h index 4121e34a6..f594bd8e5 100644 --- a/interfaces/inner_api/appexecfwk_base/include/overlay/overlay_bundle_info.h +++ b/interfaces/inner_api/appexecfwk_base/include/overlay/overlay_bundle_info.h @@ -32,8 +32,8 @@ enum OverlayType : int8_t { struct OverlayBundleInfo : public Parcelable { std::string bundleName; std::string bundleDir; - int32_t state; // 0 is for disable and 1 is for enable - int32_t priority; + int32_t state = 0; // 0 is for disable and 1 is for enable + int32_t priority = 0; bool ReadFromParcel(Parcel &parcel); virtual bool Marshalling(Parcel &parcel) const override; diff --git a/interfaces/inner_api/appexecfwk_base/src/ability_info.cpp b/interfaces/inner_api/appexecfwk_base/src/ability_info.cpp index 0fe6019d6..da5eebaa7 100644 --- a/interfaces/inner_api/appexecfwk_base/src/ability_info.cpp +++ b/interfaces/inner_api/appexecfwk_base/src/ability_info.cpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include "bundle_constants.h" @@ -505,7 +505,7 @@ bool AbilityInfo::Marshalling(Parcel &parcel) const void AbilityInfo::Dump(std::string prefix, int fd) { - APP_LOGI("called dump Abilityinfo"); + APP_LOGI("call Dump"); if (fd < 0) { APP_LOGE("dump Abilityinfo fd error"); return; diff --git a/interfaces/inner_api/appexecfwk_base/src/application_info.cpp b/interfaces/inner_api/appexecfwk_base/src/application_info.cpp index cfa79b1e1..25066a8fe 100644 --- a/interfaces/inner_api/appexecfwk_base/src/application_info.cpp +++ b/interfaces/inner_api/appexecfwk_base/src/application_info.cpp @@ -15,6 +15,7 @@ #include "application_info.h" +#include #include #include #include @@ -290,7 +291,7 @@ bool ApplicationInfo::ReadMetaDataFromParcel(Parcel &parcel) std::vector customizeDatas; metaData[moduleName] = customizeDatas; CONTAINER_SECURITY_VERIFY(parcel, customizeDataSize, &customizeDatas); - for (int j = 0; j < customizeDataSize; j++) { + for (int32_t j = 0; j < customizeDataSize; j++) { std::unique_ptr customizeData(parcel.ReadParcelable()); if (!customizeData) { APP_LOGE("ReadParcelable failed"); @@ -793,7 +794,6 @@ void ApplicationInfo::Dump(std::string prefix, int fd) APP_LOGE("dump write error : %{public}d", errno); } } - return; } bool ApplicationInfo::CheckNeedPreload(const std::string &moduleName) const diff --git a/interfaces/inner_api/appexecfwk_base/src/form_info.cpp b/interfaces/inner_api/appexecfwk_base/src/form_info.cpp index 18c50d3a2..6b064d4fd 100644 --- a/interfaces/inner_api/appexecfwk_base/src/form_info.cpp +++ b/interfaces/inner_api/appexecfwk_base/src/form_info.cpp @@ -89,12 +89,12 @@ FormInfo::FormInfo(const ExtensionAbilityInfo &abilityInfo, const ExtensionFormI src = formInfo.src; window.designWidth = formInfo.window.designWidth; window.autoDesignWidth = formInfo.window.autoDesignWidth; - std::size_t pos = formInfo.displayName.find(":"); + std::size_t pos = formInfo.displayName.find(':'); if (pos != std::string::npos) { displayNameId = static_cast( atoi(formInfo.displayName.substr(pos + 1, formInfo.displayName.length() - pos - 1).c_str())); } - pos = formInfo.description.find(":"); + pos = formInfo.description.find(':'); if (pos != std::string::npos) { descriptionId = static_cast( atoi(formInfo.description.substr(pos + 1, formInfo.description.length() - pos - 1).c_str())); diff --git a/interfaces/inner_api/appexecfwk_base/src/preinstalled_application_info.cpp b/interfaces/inner_api/appexecfwk_base/src/preinstalled_application_info.cpp index 6c9b0cf88..156f52f27 100644 --- a/interfaces/inner_api/appexecfwk_base/src/preinstalled_application_info.cpp +++ b/interfaces/inner_api/appexecfwk_base/src/preinstalled_application_info.cpp @@ -43,7 +43,7 @@ PreinstalledApplicationInfo *PreinstalledApplicationInfo::Unmarshalling(Parcel & APP_LOGE("Info is null"); return nullptr; } - if (info && !info->ReadFromParcel(parcel)) { + if (!info->ReadFromParcel(parcel)) { APP_LOGW("Read from parcel failed"); delete info; info = nullptr; diff --git a/interfaces/inner_api/appexecfwk_base/src/skill.cpp b/interfaces/inner_api/appexecfwk_base/src/skill.cpp index b327a84a0..e4bd8ac39 100644 --- a/interfaces/inner_api/appexecfwk_base/src/skill.cpp +++ b/interfaces/inner_api/appexecfwk_base/src/skill.cpp @@ -71,7 +71,7 @@ bool Skill::Match(const OHOS::AAFwk::Want &want) const } std::vector vecTypes = want.GetStringArrayParam(OHOS::AAFwk::Want::PARAM_ABILITY_URITYPES); std::string uriString = want.GetUriString(); - if (vecTypes.size() > 0) { + if (!vecTypes.empty()) { for (std::string strType : vecTypes) { if (MatchUriAndType(uriString, strType)) { APP_LOGD("type %{public}s, Is Matched", strType.c_str()); diff --git a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_stream_installer_host.h b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_stream_installer_host.h index 2e81eebad..388619ed2 100644 --- a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_stream_installer_host.h +++ b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_stream_installer_host.h @@ -35,7 +35,7 @@ public: private: DISALLOW_COPY_AND_MOVE(BundleStreamInstallerHost); - void init(); + void Init(); ErrCode HandleCreateStream(MessageParcel &data, MessageParcel &reply); ErrCode HandleCreateSignatureFileStream(MessageParcel &data, MessageParcel &reply); ErrCode HandleCreateSharedBundleStream(MessageParcel &data, MessageParcel &reply); diff --git a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/launcher_service.h b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/launcher_service.h index 7e43bd709..292dab949 100644 --- a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/launcher_service.h +++ b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/launcher_service.h @@ -107,7 +107,7 @@ private: const int32_t userId); private: - void init(); + void Init(); void OnDeath(); static OHOS::sptr GetBundleMgr(); diff --git a/interfaces/inner_api/appexecfwk_core/src/bundle_resource/bundle_resource_proxy.cpp b/interfaces/inner_api/appexecfwk_core/src/bundle_resource/bundle_resource_proxy.cpp index 063c360a4..0e67e6768 100644 --- a/interfaces/inner_api/appexecfwk_core/src/bundle_resource/bundle_resource_proxy.cpp +++ b/interfaces/inner_api/appexecfwk_core/src/bundle_resource/bundle_resource_proxy.cpp @@ -30,7 +30,7 @@ namespace AppExecFwk { namespace { constexpr size_t MAX_PARCEL_CAPACITY = 1024 * 1024 * 1024; // allow max 1GB resource size constexpr size_t MAX_IPC_ALLOWED_CAPACITY = 100 * 1024 * 1024; // max ipc size 100MB -bool GetData(void *&buffer, size_t size, const void *data) +bool GetData(size_t size, const void *data, void *&buffer) { if (data == nullptr) { APP_LOGE("failed due to null data"); @@ -277,7 +277,7 @@ ErrCode BundleResourceProxy::GetParcelInfo(BundleResourceInterfaceCode code, Mes return ERR_APPEXECFWK_PARCEL_ERROR; } } else { - if (!GetData(buffer, dataSize, reply.ReadRawData(dataSize))) { + if (!GetData(dataSize, reply.ReadRawData(dataSize), buffer)) { APP_LOGE("GetData failed dataSize: %{public}zu", dataSize); return ERR_APPEXECFWK_PARCEL_ERROR; } @@ -328,7 +328,7 @@ ErrCode BundleResourceProxy::GetVectorParcelInfo( return ERR_APPEXECFWK_PARCEL_ERROR; } } else { - if (!GetData(buffer, dataSize, reply.ReadRawData(dataSize))) { + if (!GetData(dataSize, reply.ReadRawData(dataSize), buffer)) { APP_LOGE("GetData failed dataSize: %{public}zu", dataSize); return ERR_APPEXECFWK_PARCEL_ERROR; } diff --git a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_client_impl.cpp b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_client_impl.cpp index cf36539f3..3a4039791 100644 --- a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_client_impl.cpp +++ b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_client_impl.cpp @@ -136,8 +136,7 @@ bool BundleMgrClientImpl::GetResConfigFile(const HapModuleInfo &hapModuleInfo, c APP_LOGE("no valid file can be obtained"); return false; } - int32_t InfoSize = static_cast(profileInfos.size()); - APP_LOGD("The size of the profile info is : %{public}d", InfoSize); + APP_LOGD("The size of the profile info is : %{public}zu", profileInfos.size()); return true; } @@ -154,8 +153,7 @@ bool BundleMgrClientImpl::GetResConfigFile(const ExtensionAbilityInfo &extension APP_LOGE("no valid file can be obtained"); return false; } - int32_t InfoSize = static_cast(profileInfos.size()); - APP_LOGD("The size of the profile info is : %{public}d", InfoSize); + APP_LOGD("The size of the profile info is : %{public}zu", profileInfos.size()); return true; } diff --git a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_stream_installer_host.cpp b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_stream_installer_host.cpp index f508b1fc0..d312ea8c8 100644 --- a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_stream_installer_host.cpp +++ b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_stream_installer_host.cpp @@ -27,7 +27,7 @@ namespace AppExecFwk { BundleStreamInstallerHost::BundleStreamInstallerHost() { LOG_D(BMS_TAG_INSTALLER, "create bundle stream installer host instance"); - init(); + Init(); } int BundleStreamInstallerHost::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, @@ -108,7 +108,7 @@ ErrCode BundleStreamInstallerHost::HandleInstall(MessageParcel &data, MessagePar return ERR_OK; } -void BundleStreamInstallerHost::init() +void BundleStreamInstallerHost::Init() { funcMap_.emplace(static_cast(BundleStreamInstallerInterfaceCode::CREATE_STREAM), [this](MessageParcel &data, MessageParcel &reply)->ErrCode { diff --git a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/launcher_service.cpp b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/launcher_service.cpp index 400e23290..3e02e1424 100644 --- a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/launcher_service.cpp +++ b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/launcher_service.cpp @@ -40,10 +40,10 @@ void LauncherService::LauncherServiceDeathRecipient::OnRemoteDied([[maybe_unused LauncherService::LauncherService() { - init(); + Init(); } -void LauncherService::init() +void LauncherService::Init() { EventFwk::MatchingSkills matchingSkills; matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_ADDED); @@ -266,7 +266,7 @@ ErrCode LauncherService::GetShortcutInfos( APP_LOGE("GetShortcutInfos is empty"); return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST; } - if (infos.size() == 0) { + if (infos.empty()) { APP_LOGE("infos size is empty"); return ERR_BUNDLE_MANAGER_PROFILE_NOT_EXIST; } diff --git a/interfaces/inner_api/appexecfwk_core/src/default_app/default_app_host.cpp b/interfaces/inner_api/appexecfwk_core/src/default_app/default_app_host.cpp index 6b3c69f1e..efd393527 100644 --- a/interfaces/inner_api/appexecfwk_core/src/default_app/default_app_host.cpp +++ b/interfaces/inner_api/appexecfwk_core/src/default_app/default_app_host.cpp @@ -57,7 +57,7 @@ int DefaultAppHost::OnRemoteRequest( case static_cast(DefaultAppInterfaceCode::RESET_DEFAULT_APPLICATION): return HandleResetDefaultApplication(data, reply); default: - LOG_W(BMS_TAG_DEFAULT, "DefaultAppHost receive unknown code, code = %{public}d", code); + LOG_W(BMS_TAG_DEFAULT, "DefaultAppHost receive unknown code, code = %{public}zu", code); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); } } diff --git a/interfaces/kits/js/app_control/js_app_control.cpp b/interfaces/kits/js/app_control/js_app_control.cpp index 18ffe729f..cb2167d2c 100644 --- a/interfaces/kits/js/app_control/js_app_control.cpp +++ b/interfaces/kits/js/app_control/js_app_control.cpp @@ -152,7 +152,7 @@ napi_value SetDisposedStatus(napi_env env, napi_callback_info info) BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING); return nullptr; } - asyncCallbackInfo->err = asyncCallbackInfo->appId.size() == 0 ? ERROR_INVALID_APPID : NO_ERROR; + asyncCallbackInfo->err = asyncCallbackInfo->appId.empty() ? ERROR_INVALID_APPID : NO_ERROR; } else if (i == ARGS_POS_ONE) { if (!CommonFunc::ParseWantWithoutVerification(env, args[i], asyncCallbackInfo->want)) { APP_LOGE("disposed want invalid"); @@ -195,7 +195,7 @@ napi_value SetDisposedStatusSync(napi_env env, napi_callback_info info) BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING); return nRet; } - if (appId.size() == 0) { + if (appId.empty()) { napi_value businessError = BusinessError::CreateCommonError( env, ERROR_INVALID_APPID, SET_DISPOSED_STATUS_SYNC); napi_throw(env, businessError); @@ -282,7 +282,7 @@ napi_value DeleteDisposedStatus(napi_env env, napi_callback_info info) BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING); return nullptr; } - if (asyncCallbackInfo->appId.size() == 0) { + if (asyncCallbackInfo->appId.empty()) { asyncCallbackInfo->err = ERROR_INVALID_APPID; } } else if (i == ARGS_POS_ONE) { @@ -308,7 +308,7 @@ static napi_value InnerDeleteDisposedStatusSync(napi_env env, std::string &appId { napi_value nRet; napi_get_undefined(env, &nRet); - if (appId.size() == 0) { + if (appId.empty()) { napi_value businessError = BusinessError::CreateCommonError( env, ERROR_INVALID_APPID, DELETE_DISPOSED_STATUS_SYNC); napi_throw(env, businessError); @@ -429,7 +429,7 @@ napi_value GetDisposedStatus(napi_env env, napi_callback_info info) BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING); return nullptr; } - if (asyncCallbackInfo->appId.size() == 0) { + if (asyncCallbackInfo->appId.empty()) { asyncCallbackInfo->err = ERROR_INVALID_APPID; } } else if (i == ARGS_POS_ONE) { @@ -466,7 +466,7 @@ napi_value GetDisposedStatusSync(napi_env env, napi_callback_info info) BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING); return nullptr; } - if (appId.size() == 0) { + if (appId.empty()) { napi_value businessError = BusinessError::CreateCommonError( env, ERROR_INVALID_APPID, GET_DISPOSED_STATUS_SYNC); napi_throw(env, businessError); @@ -613,7 +613,7 @@ bool ParseDiposedRule(napi_env env, napi_value nRule, DisposedRule &rule) static napi_value InnerGetDisposedRule(napi_env env, std::string &appId, int32_t appIndex) { - if (appId.size() == 0) { + if (appId.empty()) { napi_value businessError = BusinessError::CreateCommonError( env, ERROR_INVALID_APPID, GET_DISPOSED_STATUS_SYNC); napi_throw(env, businessError); @@ -723,7 +723,7 @@ napi_value SetDisposedRule(napi_env env, napi_callback_info info) BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING); return nRet; } - if (appId.size() == 0) { + if (appId.empty()) { napi_value businessError = BusinessError::CreateCommonError( env, ERROR_INVALID_APPID, SET_DISPOSED_STATUS_SYNC); napi_throw(env, businessError);