diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index e861dbca4096e80e8ca65c67990d5db68ee9423a..91fd9fbe72f6d7f164f98f8bf201c7197085ede4 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -273,17 +273,20 @@ int32_t DeviceManagerImpl::UnAuthenticateDevice(const std::string &pkgName, cons } DmDeviceInfo deviceInfo; - strcpy_s(deviceInfo.deviceId, DM_MAX_DEVICE_ID_LEN, deviceId.c_str()); + int32_t ret = strcpy_s(deviceInfo.deviceId, DM_MAX_DEVICE_ID_LEN, deviceId.c_str()); + if (ret != DM_OK) { + LOGE("UnAuthenticateDevice error: copy deviceId failed"); + return DM_INVALID_VALUE; + } std::shared_ptr req = std::make_shared(); std::shared_ptr rsp = std::make_shared(); req->SetPkgName(pkgName); req->SetDeviceInfo(deviceInfo); - int32_t ret = ipcClientProxy_->SendRequest(UNAUTHENTICATE_DEVICE, req, rsp); + ret = ipcClientProxy_->SendRequest(UNAUTHENTICATE_DEVICE, req, rsp); if (ret != DM_OK) { LOGE("UnAuthenticateDevice error: Send Request failed ret: %d", ret); return DM_IPC_SEND_REQUEST_FAILED; } - ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGE("UnAuthenticateDevice error: Failed with ret %d", ret); diff --git a/interfaces/kits/js/src/native_devicemanager_js.cpp b/interfaces/kits/js/src/native_devicemanager_js.cpp index b6cec47926033fe83b9c1d24f32db0adfb7a4201..215a2cd209341d7ec3123c8893174ba980e45f1e 100644 --- a/interfaces/kits/js/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js/src/native_devicemanager_js.cpp @@ -1078,11 +1078,10 @@ void DeviceManagerNapi::CallGetTrustedDeviceListStatus(napi_env env, napi_status bool isArray = false; napi_create_array(env, &array[1]); napi_is_array(env, array[1], &isArray); - if (isArray == false) { + if (!isArray) { LOGE("napi_create_array fail"); } - - for (int32_t i = 0; i != deviceInfoListAsyncCallbackInfo->devList.size(); ++i) { + for (size_t i = 0; i != deviceInfoListAsyncCallbackInfo->devList.size(); ++i) { DeviceInfoToJsArray(env, deviceInfoListAsyncCallbackInfo->devList, i, array[1]); } LOGE("devList is OK"); diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index 359721a012625694e3d529ffe5d02a4862b7e301..eeb032229256a6dc902f8d56f0b52b9a758abeaa 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -414,7 +414,7 @@ void DmAuthManager::RespNegotiate(const int32_t &sessionId) char localDeviceId[DEVICE_UUID_LENGTH] = {0}; GetDevUdid(localDeviceId, DEVICE_UUID_LENGTH); bool ret = hiChainConnector_->IsDevicesInGroup(authResponseContext_->localDeviceId, localDeviceId); - if (ret != true) { + if (!ret) { LOGE("DmAuthManager::EstablishAuthChannel device is in group"); authResponseContext_->reply = DM_AUTH_PEER_REJECT; } else { diff --git a/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp b/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp index 897800efe5a5465b61b69f03c87eb34d600e8cbc..9ef388b1c3176f9c95ff23e7be8673a752beb4bd 100644 --- a/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp +++ b/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp @@ -73,7 +73,6 @@ DmTimerStatus DmTimer::Start(uint32_t timeOut, TimeoutHandle handle, void *data) mStatus_ = DmTimerStatus::DM_STATUS_RUNNING; mThread_ = std::thread(&DmTimer::WaitForTimeout, this); mThread_.detach(); - return mStatus_; } @@ -87,12 +86,9 @@ void DmTimer::Stop(int32_t code) if (mTimeFd_[1]) { char event = 'S'; if (write(mTimeFd_[1], &event, 1) < 0) { - LOGE("DmTimer %s Stop timer failed, errno %d", mTimerName_.c_str(), errno); return; } - LOGI("DmTimer %s Stop success", mTimerName_.c_str()); } - return; } void DmTimer::WaitForTimeout() @@ -122,7 +118,6 @@ void DmTimer::WaitForTimeout() Release(); LOGE("DmTimer %s end timer at (%d)s", mTimerName_.c_str(), mTimeOutSec_); } - return; } int32_t DmTimer::CreateTimeFd() diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp index fc4807ccbb3683cbe9b9f5823304ff4bb3b0a025..42654f175cfe3560a2a5f6756767181bbebeecb5 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp @@ -394,7 +394,7 @@ ON_IPC_CMD(SERVER_GET_DMFA_INFO, MessageParcel &data, MessageParcel &reply) int32_t ret = DM_OK; ret = DeviceManagerService::GetInstance().GetFaParam(packName, authParam); int32_t appIconLen = authParam.imageinfo.GetAppIconLen(); - uint32_t appThumbnailLen = authParam.imageinfo.GetAppThumbnailLen(); + int32_t appThumbnailLen = authParam.imageinfo.GetAppThumbnailLen(); if (!reply.WriteInt32(authParam.direction) || !reply.WriteInt32(authParam.authType) || !reply.WriteString(authParam.authToken) || !reply.WriteString(authParam.packageName) || diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp index 71b0bbabfd883ba6e1ff370f9bdbdd67e233c43d..30f37fc6bf28db25333fcd537c218bbb4c3e1a9d 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp @@ -133,12 +133,17 @@ int32_t IpcServerStub::RegisterDeviceManagerListener(std::string &pkgName, sptr< LOGI("RegisterDeviceManagerListener: listener already exists"); return DM_OK; } - sptr appRecipient = sptr(new AppDeathRecipient()); - if (!listener->AddDeathRecipient(appRecipient)) { - LOGE("RegisterDeviceManagerListener: AddDeathRecipient Failed"); + try { + sptr appRecipient = sptr(new AppDeathRecipient()); + if (!listener->AddDeathRecipient(appRecipient)) { + LOGE("RegisterDeviceManagerListener: AddDeathRecipient Failed"); + } + dmListener_[pkgName] = listener; + appRecipient_[pkgName] = appRecipient; + } catch (const std::bad_alloc &e) { + LOGE("new AppDeathRecipient failed"); + return DM_MALLOC_ERROR; } - dmListener_[pkgName] = listener; - appRecipient_[pkgName] = appRecipient; return DM_OK; } diff --git a/utils/src/dm_anonymous.cpp b/utils/src/dm_anonymous.cpp index 907c9f20880f77eabe86f5524587e762e7bbb7f7..8fbe5b580d178b9d4a7de9cd33a5b5a29086f30c 100644 --- a/utils/src/dm_anonymous.cpp +++ b/utils/src/dm_anonymous.cpp @@ -24,7 +24,7 @@ std::string GetAnonyString(const std::string &value) const int32_t INT32_MIN_ID_LENGTH = 3; std::string tmpStr("******"); - int32_t strLen = value.length(); + size_t strLen = value.length(); if (strLen < INT32_MIN_ID_LENGTH) { return tmpStr; } @@ -46,7 +46,7 @@ std::string GetAnonyString(const std::string &value) std::string GetAnonyInt32(const int32_t value) { std::string tempString = std::to_string(value); - int32_t length = tempString.length(); + size_t length = tempString.length(); if (length == 0x01) { tempString[0] = '*'; return tempString;