From 89c619399923538d06788fb22d563f2a401be29f Mon Sep 17 00:00:00 2001 From: liupengfei Date: Mon, 28 Mar 2022 15:33:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liupengfei Change-Id: I1a7715ee05e3251dd4f9d9f42b2aee4f62170cc3 --- .../accesstoken/src/hap_policy_parcel.cpp | 2 +- .../src/hap_token_info_for_sync_parcel.cpp | 2 +- frameworks/common/src/random_mbedtls.cpp | 2 +- .../accesstoken/src/accesstoken_kit.cpp | 12 +++---- .../innerkits/nativetoken/src/nativetoken.c | 4 +-- .../token_setproc/src/token_setproc.c | 13 ++++---- .../accesstoken/napi/src/napi_atmanager.cpp | 32 +++++++++---------- .../main/cpp/src/database/data_translator.cpp | 4 +-- .../src/permission/permission_policy_set.cpp | 6 ++-- .../src/command/base_remote_command.cpp | 26 +++++++-------- .../src/remote/remote_command_executor.cpp | 4 +-- .../src/remote/soft_bus_manager.cpp | 12 +++---- 12 files changed, 60 insertions(+), 59 deletions(-) diff --git a/frameworks/accesstoken/src/hap_policy_parcel.cpp b/frameworks/accesstoken/src/hap_policy_parcel.cpp index bbd333fc0..8ede17163 100644 --- a/frameworks/accesstoken/src/hap_policy_parcel.cpp +++ b/frameworks/accesstoken/src/hap_policy_parcel.cpp @@ -36,7 +36,7 @@ bool HapPolicyParcel::Marshalling(Parcel& out) const RETURN_IF_FALSE(out.WriteString(this->hapPolicyParameter.domain)); const std::vector& permList = this->hapPolicyParameter.permList; - int32_t permListSize = (int32_t)permList.size(); + int32_t permListSize = static_cast(permList.size()); RETURN_IF_FALSE(out.WriteInt32(permListSize)); for (int i = 0; i < permListSize; i++) { diff --git a/frameworks/accesstoken/src/hap_token_info_for_sync_parcel.cpp b/frameworks/accesstoken/src/hap_token_info_for_sync_parcel.cpp index 282939ccb..dfaf2f0a0 100644 --- a/frameworks/accesstoken/src/hap_token_info_for_sync_parcel.cpp +++ b/frameworks/accesstoken/src/hap_token_info_for_sync_parcel.cpp @@ -39,7 +39,7 @@ bool HapTokenInfoForSyncParcel::Marshalling(Parcel& out) const out.WriteParcelable(&baseInfoParcel); const std::vector& permStateList = this->hapTokenInfoForSyncParams.permStateList; - int32_t permStateListSize = (int32_t)permStateList.size(); + int32_t permStateListSize = static_cast (permStateList.size()); RETURN_IF_FALSE(out.WriteInt32(permStateListSize)); for (int i = 0; i < permStateListSize; i++) { diff --git a/frameworks/common/src/random_mbedtls.cpp b/frameworks/common/src/random_mbedtls.cpp index 082298f5d..1a6ad4013 100644 --- a/frameworks/common/src/random_mbedtls.cpp +++ b/frameworks/common/src/random_mbedtls.cpp @@ -40,7 +40,7 @@ int RandomMbedtls::GenerateRandomArray(unsigned char *randStr, unsigned int len) int ret; Utils::UniqueWriteGuard infoGuard(this->randomLock_); - if (initFlag_ == false) { + if (!initFlag_) { mbedtls_ctr_drbg_init(&ctrDrbg_); mbedtls_entropy_init(&entropy_); ret = mbedtls_ctr_drbg_seed(&ctrDrbg_, mbedtls_entropy_func, &entropy_, NULL, 0); diff --git a/interfaces/innerkits/accesstoken/src/accesstoken_kit.cpp b/interfaces/innerkits/accesstoken/src/accesstoken_kit.cpp index c9d8f2449..89eff880d 100644 --- a/interfaces/innerkits/accesstoken/src/accesstoken_kit.cpp +++ b/interfaces/innerkits/accesstoken/src/accesstoken_kit.cpp @@ -33,9 +33,9 @@ AccessTokenIDEx AccessTokenKit::AllocHapToken(const HapInfoParams& info, const H { AccessTokenIDEx res = {0}; ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__); - if ((!DataValidator::IsUserIdValid(info.userID)) || !DataValidator::IsAppIDDescValid(info.appIDDesc) - || !DataValidator::IsBundleNameValid(info.bundleName) || !DataValidator::IsAplNumValid(policy.apl) - || !DataValidator::IsDomainValid(policy.domain)) { + if ((!DataValidator::IsUserIdValid(info.userID)) || !DataValidator::IsAppIDDescValid(info.appIDDesc) || + !DataValidator::IsBundleNameValid(info.bundleName) || !DataValidator::IsAplNumValid(policy.apl) || + !DataValidator::IsDomainValid(policy.domain)) { ACCESSTOKEN_LOG_ERROR(LABEL, "input param failed"); return res; } @@ -60,8 +60,8 @@ AccessTokenID AccessTokenKit::AllocLocalTokenID(const std::string& remoteDeviceI int AccessTokenKit::UpdateHapToken(AccessTokenID tokenID, const std::string& appIDDesc, const HapPolicyParams& policy) { ACCESSTOKEN_LOG_INFO(LABEL, "%{public}s called", __func__); - if ((tokenID == 0) || (!DataValidator::IsAppIDDescValid(appIDDesc)) - || (!DataValidator::IsAplNumValid(policy.apl))) { + if ((tokenID == 0) || (!DataValidator::IsAppIDDescValid(appIDDesc)) || + (!DataValidator::IsAplNumValid(policy.apl))) { ACCESSTOKEN_LOG_ERROR(LABEL, "input param failed"); return RET_FAILED; } @@ -95,7 +95,7 @@ ATokenTypeEnum AccessTokenKit::GetTokenTypeFlag(AccessTokenID tokenID) if (tokenID == 0) { return TOKEN_INVALID; } - AccessTokenIDInner *idInner = (AccessTokenIDInner *)&tokenID; + AccessTokenIDInner *idInner = reinterpret_cast(&tokenID); return (ATokenTypeEnum)(idInner->type); } diff --git a/interfaces/innerkits/nativetoken/src/nativetoken.c b/interfaces/innerkits/nativetoken/src/nativetoken.c index 7ce4c8b82..1e386fe37 100644 --- a/interfaces/innerkits/nativetoken/src/nativetoken.c +++ b/interfaces/innerkits/nativetoken/src/nativetoken.c @@ -512,8 +512,8 @@ static void SaveTokenIdToCfg(const NativeTokenList *curr) static uint32_t CheckProcessInfo(const char *processname, const char **dcaps, int32_t dcapNum, const char *aplStr, int32_t *aplRet) { - if ((processname == NULL) || strlen(processname) > MAX_PROCESS_NAME_LEN - || strlen(processname) == 0) { + if ((processname == NULL) || strlen(processname) > MAX_PROCESS_NAME_LEN || + strlen(processname) == 0) { ACCESSTOKEN_LOG_ERROR("[ATLIB-%s]:processname is invalid.", __func__); return ATRET_FAILED; } diff --git a/interfaces/innerkits/token_setproc/src/token_setproc.c b/interfaces/innerkits/token_setproc/src/token_setproc.c index 14363d595..da5dd2a1a 100644 --- a/interfaces/innerkits/token_setproc/src/token_setproc.c +++ b/interfaces/innerkits/token_setproc/src/token_setproc.c @@ -20,6 +20,7 @@ #include #include #include +#include #define ACCESS_TOKEN_ID_IOCTL_BASE 'A' @@ -32,13 +33,13 @@ enum { }; #define ACCESS_TOKENID_GET_TOKENID \ - _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_TOKEN_ID, unsigned long long) + _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_TOKEN_ID, uint64_t) #define ACCESS_TOKENID_SET_TOKENID \ - _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_TOKEN_ID, unsigned long long) + _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_TOKEN_ID, uint64_t) #define ACCESS_TOKENID_GET_FTOKENID \ - _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_FTOKEN_ID, unsigned long long) + _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_FTOKEN_ID, uint64_t) #define ACCESS_TOKENID_SET_FTOKENID \ - _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_FTOKEN_ID, unsigned long long) + _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_FTOKEN_ID, uint64_t) #define ACCESS_TOKEN_OK 0 #define ACCESS_TOKEN_ERROR (-1) @@ -48,7 +49,7 @@ enum { #define TOKENID_DEVNODE "/dev/access_token_id" -uint64_t GetSelfTokenID() +uint64_t GetSelfTokenID(void) { uint64_t token = INVAL_TOKEN_ID; int fd = open(TOKENID_DEVNODE, O_RDWR); @@ -81,7 +82,7 @@ int SetSelfTokenID(uint64_t tokenID) return ACCESS_TOKEN_OK; } -uint64_t GetFirstCallerTokenID() +uint64_t GetFirstCallerTokenID(void) { uint64_t token = INVAL_TOKEN_ID; int fd = open(TOKENID_DEVNODE, O_RDWR); diff --git a/interfaces/kits/accesstoken/napi/src/napi_atmanager.cpp b/interfaces/kits/accesstoken/napi/src/napi_atmanager.cpp index 672003a66..8c39ddd24 100644 --- a/interfaces/kits/accesstoken/napi/src/napi_atmanager.cpp +++ b/interfaces/kits/accesstoken/napi/src/napi_atmanager.cpp @@ -146,7 +146,7 @@ void NapiAtManager::ParseInputVerifyPermissionOrGetFlag(const napi_env env, cons void NapiAtManager::VerifyAccessTokenExecute(napi_env env, void *data) { - AtManagerAsyncContext* asyncContext = (AtManagerAsyncContext *)data; + AtManagerAsyncContext* asyncContext = reinterpret_cast(data); // use innerkit class method to verify permission asyncContext->result = AccessTokenKit::VerifyAccessToken(asyncContext->tokenId, @@ -162,7 +162,7 @@ void NapiAtManager::VerifyAccessTokenExecute(napi_env env, void *data) void NapiAtManager::VerifyAccessTokenComplete(napi_env env, napi_status status, void *data) { - AtManagerAsyncContext* asyncContext = (AtManagerAsyncContext*)data; + AtManagerAsyncContext* asyncContext = reinterpret_cast(data); napi_value result; ACCESSTOKEN_LOG_DEBUG(LABEL, "tokenId = %{public}d, permissionName = %{public}s, verify result = %{public}d.", @@ -208,7 +208,7 @@ napi_value NapiAtManager::VerifyAccessToken(napi_env env, napi_callback_info inf napi_create_async_work( // define work env, nullptr, resource, VerifyAccessTokenExecute, VerifyAccessTokenComplete, - (void *)asyncContext, &(asyncContext->work)); + reinterpret_cast(asyncContext), &(asyncContext->work)); napi_queue_async_work(env, asyncContext->work); // add async work handle to the napi queue and wait for result ACCESSTOKEN_LOG_DEBUG(LABEL, "VerifyAccessToken end."); @@ -257,7 +257,7 @@ void NapiAtManager::ParseInputGrantOrRevokePermission(const napi_env env, const void NapiAtManager::GrantUserGrantedPermissionExcute(napi_env env, void *data) { - AtManagerAsyncContext* asyncContext = (AtManagerAsyncContext *)data; + AtManagerAsyncContext* asyncContext = reinterpret_cast(data); PermissionDef permissionDef; // struct init, can not use = { 0 } or memset otherwise program crashdump @@ -289,8 +289,8 @@ void NapiAtManager::GrantUserGrantedPermissionExcute(napi_env env, void *data) asyncContext->tokenId, asyncContext->permissionName, asyncContext->flag, asyncContext->result); // set status according to the innerkit class method return - if ((asyncContext->result == ACCESSTOKEN_PERMISSION_GRANT_SUCC) - || (asyncContext->result == ACCESSTOKEN_PERMISSION_GRANT_FAIL)) { + if ((asyncContext->result == ACCESSTOKEN_PERMISSION_GRANT_SUCC) || + (asyncContext->result == ACCESSTOKEN_PERMISSION_GRANT_FAIL)) { asyncContext->status = ASYN_THREAD_EXEC_SUCC; // success or failure regard as function exec success } else { asyncContext->status = ASYN_THREAD_EXEC_FAIL; // other regard as function exec failure @@ -300,7 +300,7 @@ void NapiAtManager::GrantUserGrantedPermissionExcute(napi_env env, void *data) void NapiAtManager::GrantUserGrantedPermissionComplete(napi_env env, napi_status status, void *data) { - AtManagerAsyncContext* asyncContext = (AtManagerAsyncContext*)data; + AtManagerAsyncContext* asyncContext = reinterpret_cast(data); napi_value result = nullptr; if (asyncContext->status == ASYN_THREAD_EXEC_SUCC) { @@ -370,7 +370,7 @@ napi_value NapiAtManager::GrantUserGrantedPermission(napi_env env, napi_callback napi_create_async_work( // define work env, nullptr, resource, GrantUserGrantedPermissionExcute, GrantUserGrantedPermissionComplete, - (void *)asyncContext, &(asyncContext->work)); + reinterpret_cast(asyncContext), &(asyncContext->work)); napi_queue_async_work(env, asyncContext->work); // add async work handle to the napi queue and wait for result @@ -381,7 +381,7 @@ napi_value NapiAtManager::GrantUserGrantedPermission(napi_env env, napi_callback void NapiAtManager::RevokeUserGrantedPermissionExcute(napi_env env, void *data) { - AtManagerAsyncContext* asyncContext = (AtManagerAsyncContext *)data; + AtManagerAsyncContext* asyncContext = reinterpret_cast(data); PermissionDef permissionDef; // struct init, can not use = { 0 } or memset otherwise program crashdump @@ -412,8 +412,8 @@ void NapiAtManager::RevokeUserGrantedPermissionExcute(napi_env env, void *data) asyncContext->tokenId, asyncContext->permissionName, asyncContext->flag, asyncContext->result); // set status according to the innerkit class method return - if ((asyncContext->result == ACCESSTOKEN_PERMISSION_REVOKE_SUCC) - || (asyncContext->result == ACCESSTOKEN_PERMISSION_REVOKE_FAIL)) { + if ((asyncContext->result == ACCESSTOKEN_PERMISSION_REVOKE_SUCC) || + (asyncContext->result == ACCESSTOKEN_PERMISSION_REVOKE_FAIL)) { asyncContext->status = ASYN_THREAD_EXEC_SUCC; // success or failure regard as function exec success } else { asyncContext->status = ASYN_THREAD_EXEC_FAIL; // other regard as function exec failure @@ -423,7 +423,7 @@ void NapiAtManager::RevokeUserGrantedPermissionExcute(napi_env env, void *data) void NapiAtManager::RevokeUserGrantedPermissionComplete(napi_env env, napi_status status, void *data) { - AtManagerAsyncContext* asyncContext = (AtManagerAsyncContext*)data; + AtManagerAsyncContext* asyncContext = reinterpret_cast(data); napi_value result = nullptr; if (asyncContext->status == ASYN_THREAD_EXEC_SUCC) { @@ -493,7 +493,7 @@ napi_value NapiAtManager::RevokeUserGrantedPermission(napi_env env, napi_callbac napi_create_async_work( // define work env, nullptr, resource, RevokeUserGrantedPermissionExcute, RevokeUserGrantedPermissionComplete, - (void *)asyncContext, &(asyncContext->work)); + reinterpret_cast(asyncContext), &(asyncContext->work)); napi_queue_async_work(env, asyncContext->work); // add async work handle to the napi queue and wait for result @@ -504,7 +504,7 @@ napi_value NapiAtManager::RevokeUserGrantedPermission(napi_env env, napi_callbac void NapiAtManager::GetPermissionFlagsExcute(napi_env env, void *data) { - AtManagerAsyncContext* asyncContext = (AtManagerAsyncContext *)data; + AtManagerAsyncContext* asyncContext = reinterpret_cast(data); // use innerkit class method to get permission flag asyncContext->flag = AccessTokenKit::GetPermissionFlag(asyncContext->tokenId, @@ -514,7 +514,7 @@ void NapiAtManager::GetPermissionFlagsExcute(napi_env env, void *data) void NapiAtManager::GetPermissionFlagsComplete(napi_env env, napi_status status, void *data) { - AtManagerAsyncContext* asyncContext = (AtManagerAsyncContext*)data; + AtManagerAsyncContext* asyncContext = reinterpret_cast(data); napi_value result; ACCESSTOKEN_LOG_DEBUG(LABEL, "permissionName = %{public}s, tokenId = %{public}d, flag = %{public}d.", @@ -560,7 +560,7 @@ napi_value NapiAtManager::GetPermissionFlags(napi_env env, napi_callback_info in napi_create_async_work( // define work env, nullptr, resource, GetPermissionFlagsExcute, GetPermissionFlagsComplete, - (void *)asyncContext, &(asyncContext->work)); + reinterpret_cast(asyncContext), &(asyncContext->work)); napi_queue_async_work(env, asyncContext->work); // add async work handle to the napi queue and wait for result ACCESSTOKEN_LOG_DEBUG(LABEL, "GetPermissionFlags end."); diff --git a/services/accesstokenmanager/main/cpp/src/database/data_translator.cpp b/services/accesstokenmanager/main/cpp/src/database/data_translator.cpp index b341c78ca..fc22be8f3 100644 --- a/services/accesstokenmanager/main/cpp/src/database/data_translator.cpp +++ b/services/accesstokenmanager/main/cpp/src/database/data_translator.cpp @@ -67,8 +67,8 @@ int DataTranslator::TranslationIntoPermissionDef(const GenericValues& inGenericV int DataTranslator::TranslationIntoGenericValues(const PermissionStateFull& inPermissionState, const unsigned int grantIndex, GenericValues& outGenericValues) { - if (grantIndex >= inPermissionState.resDeviceID.size() || grantIndex >= inPermissionState.grantStatus.size() - || grantIndex >= inPermissionState.grantFlags.size()) { + if (grantIndex >= inPermissionState.resDeviceID.size() || grantIndex >= inPermissionState.grantStatus.size() || + grantIndex >= inPermissionState.grantFlags.size()) { ACCESSTOKEN_LOG_WARN(LABEL, "perm status grant size is wrong"); return RET_FAILED; } diff --git a/services/accesstokenmanager/main/cpp/src/permission/permission_policy_set.cpp b/services/accesstokenmanager/main/cpp/src/permission/permission_policy_set.cpp index f70246e47..312686a4a 100644 --- a/services/accesstokenmanager/main/cpp/src/permission/permission_policy_set.cpp +++ b/services/accesstokenmanager/main/cpp/src/permission/permission_policy_set.cpp @@ -185,7 +185,7 @@ int PermissionPolicySet::VerifyPermissStatus(const std::string& permissionName) Utils::UniqueReadGuard infoGuard(this->permPolicySetLock_); for (auto perm : permStateList_) { if (perm.permissionName == permissionName) { - if (perm.isGeneral == true) { + if (perm.isGeneral) { return perm.grantStatus[0]; } else { return PERMISSION_DENIED; @@ -212,7 +212,7 @@ int PermissionPolicySet::QueryPermissionFlag(const std::string& permissionName) Utils::UniqueReadGuard infoGuard(this->permPolicySetLock_); for (auto perm : permStateList_) { if (perm.permissionName == permissionName) { - if (perm.isGeneral == true) { + if (perm.isGeneral) { return perm.grantFlags[0]; } else { return DEFAULT_PERMISSION_FLAGS; @@ -227,7 +227,7 @@ void PermissionPolicySet::UpdatePermissionStatus(const std::string& permissionNa Utils::UniqueWriteGuard infoGuard(this->permPolicySetLock_); for (auto& perm : permStateList_) { if (perm.permissionName == permissionName) { - if (perm.isGeneral == true) { + if (perm.isGeneral) { perm.grantStatus[0] = isGranted ? PERMISSION_GRANTED : PERMISSION_DENIED; perm.grantFlags[0] = flag; } else { diff --git a/services/tokensyncmanager/src/command/base_remote_command.cpp b/services/tokensyncmanager/src/command/base_remote_command.cpp index 8b66297cd..1e405b5cc 100644 --- a/services/tokensyncmanager/src/command/base_remote_command.cpp +++ b/services/tokensyncmanager/src/command/base_remote_command.cpp @@ -182,25 +182,25 @@ void BaseRemoteCommand::FromPermStateListJson(const nlohmann::json& hapTokenJson nlohmann::json permissionsJson = hapTokenJson.at("permState").get(); for (auto permissionJson : permissionsJson) { PermissionStateFull permission; - if (permissionJson.find("permissionName") == permissionJson.end() - || !permissionJson.at("permissionName").is_string() - || permissionJson.find("isGeneral") == permissionJson.end() - || !permissionJson.at("isGeneral").is_boolean() - || permissionJson.find("grantConfig") == permissionJson.end() - || !permissionJson.at("grantConfig").is_array() - || permissionJson.at("grantConfig").size() == 0) { + if (permissionJson.find("permissionName") == permissionJson.end() || + !permissionJson.at("permissionName").is_string() || + permissionJson.find("isGeneral") == permissionJson.end() || + !permissionJson.at("isGeneral").is_boolean() || + permissionJson.find("grantConfig") == permissionJson.end() || + !permissionJson.at("grantConfig").is_array() || + permissionJson.at("grantConfig").size() == 0) { continue; } permissionJson.at("permissionName").get_to(permission.permissionName); permissionJson.at("isGeneral").get_to(permission.isGeneral); nlohmann::json grantConfigsJson = permissionJson.at("grantConfig").get(); for (auto grantConfigJson :grantConfigsJson) { - if (grantConfigJson.find("resDeviceID") == grantConfigJson.end() - || !grantConfigJson.at("resDeviceID").is_string() - || grantConfigJson.find("grantStatus") == grantConfigJson.end() - || !grantConfigJson.at("grantStatus").is_number() - || grantConfigJson.find("grantFlags") == grantConfigJson.end() - || !grantConfigJson.at("grantFlags").is_number()) { + if (grantConfigJson.find("resDeviceID") == grantConfigJson.end() || + !grantConfigJson.at("resDeviceID").is_string() || + grantConfigJson.find("grantStatus") == grantConfigJson.end() || + !grantConfigJson.at("grantStatus").is_number() || + grantConfigJson.find("grantFlags") == grantConfigJson.end() || + !grantConfigJson.at("grantFlags").is_number()) { continue; } std::string deviceID; diff --git a/services/tokensyncmanager/src/remote/remote_command_executor.cpp b/services/tokensyncmanager/src/remote/remote_command_executor.cpp index 4219bfe44..ceac49d9d 100644 --- a/services/tokensyncmanager/src/remote/remote_command_executor.cpp +++ b/services/tokensyncmanager/src/remote/remote_command_executor.cpp @@ -152,7 +152,7 @@ int RemoteCommandExecutor::ProcessBufferedCommands(bool standalone) running_ = true; while (true) { // interrupt - if (running_ == false) { + if (!running_) { ACCESSTOKEN_LOG_INFO( LABEL, "end with running flag == false, targetNodeId: %{public}s", targetNodeId_.c_str()); return Constant::FAILURE; @@ -222,7 +222,7 @@ void RemoteCommandExecutor::ProcessBufferedCommandsWithThread() return; } bool result = handler->ProxyPostTask(runner, TASK_NAME); - if (result == false) { + if (!result) { ACCESSTOKEN_LOG_ERROR(LABEL, "post task failed, targetNodeId: %{public}s", targetNodeId_.c_str()); } ACCESSTOKEN_LOG_INFO(LABEL, diff --git a/services/tokensyncmanager/src/remote/soft_bus_manager.cpp b/services/tokensyncmanager/src/remote/soft_bus_manager.cpp index 279c6c1d4..74f466f7b 100644 --- a/services/tokensyncmanager/src/remote/soft_bus_manager.cpp +++ b/services/tokensyncmanager/src/remote/soft_bus_manager.cpp @@ -120,13 +120,13 @@ void SoftBusManager::Destroy() ACCESSTOKEN_LOG_DEBUG(LABEL, "destroy, init: %{public}d, isSoftBusServiceBindSuccess: %{public}d", inited_.load(), isSoftBusServiceBindSuccess_); - if (inited_.load() == false) { + if (!inited_.load()) { ACCESSTOKEN_LOG_DEBUG(LABEL, "not inited, skip"); return; } std::unique_lock lock(mutex_); - if (inited_.load() == false) { + if (!inited_.load()) { ACCESSTOKEN_LOG_DEBUG(LABEL, "not inited, skip"); return; } @@ -160,7 +160,7 @@ int32_t SoftBusManager::OpenSession(const std::string &deviceId) DeviceInfo info; bool result = DeviceInfoManager::GetInstance().GetDeviceInfo(deviceId, DeviceIdType::UNKNOWN, info); - if (result == false) { + if (!result) { ACCESSTOKEN_LOG_WARN(LABEL, "device info notfound for deviceId %{public}s", deviceId.c_str()); return Constant::FAILURE; } @@ -231,7 +231,7 @@ std::string SoftBusManager::GetUniversallyUniqueIdByNodeId(const std::string &no DeviceInfo info; bool result = DeviceInfoManager::GetInstance().GetDeviceInfo(uuid, DeviceIdType::UNIVERSALLY_UNIQUE_ID, info); - if (result == false) { + if (!result) { ACCESSTOKEN_LOG_DEBUG(LABEL, "local device info not found for uuid %{public}s", uuid.c_str()); } else { std::string dimUuid = info.deviceId.universallyUniqueId; @@ -283,7 +283,7 @@ std::string SoftBusManager::GetUuidByNodeId(const std::string &nodeId) const ACCESSTOKEN_LOG_WARN(LABEL, "GetNodeKeyInfo error, return code: %{public}d", ret); return ""; } - std::string uuid((char *) info); + std::string uuid(reinterpret_cast(info)); delete[] info; ACCESSTOKEN_LOG_DEBUG(LABEL, "call softbus finished. nodeId(in): %{public}s, uuid: %{public}s", nodeId.c_str(), uuid.c_str()); @@ -305,7 +305,7 @@ std::string SoftBusManager::GetUdidByNodeId(const std::string &nodeId) const ACCESSTOKEN_LOG_WARN(LABEL, "GetNodeKeyInfo error, code: %{public}d", ret); return ""; } - std::string udid((char *) info); + std::string udid(reinterpret_cast(info)); delete[] info; ACCESSTOKEN_LOG_DEBUG(LABEL, "call softbus finished: nodeId(in): %{public}s, udid: %{public}s", nodeId.c_str(), udid.c_str()); -- Gitee