diff --git a/common/include/utils/macro_utils.h b/common/include/utils/macro_utils.h index 58109d610db4ce92c9625d38588f340901cb787d..f49faf44d2b0a4d5070ecae0acdd2504908ea3a2 100644 --- a/common/include/utils/macro_utils.h +++ b/common/include/utils/macro_utils.h @@ -69,10 +69,6 @@ namespace DistributedDeviceProfile { #define SEND_REQUEST(remote, code, data, reply) \ do { \ MessageOption option; \ - if ((remote) == nullptr) { \ - HILOGE("remote is nullptr"); \ - return DP_IPC_REMOTE_OBJECT_NULLPTR; \ - } \ int32_t errCode = (remote)->SendRequest((code), (data), (reply), option); \ if (errCode != DP_SUCCESS) { \ HILOGE("transact failed, errCode = %{public}d", errCode); \ diff --git a/common/src/interfaces/sync_completed_callback_proxy.cpp b/common/src/interfaces/sync_completed_callback_proxy.cpp index c6c9088085e0a26217dc25c38b45963d70e11a57..25e3f9aa1e007944bd9e5cd20b2f1d5a563499ce 100644 --- a/common/src/interfaces/sync_completed_callback_proxy.cpp +++ b/common/src/interfaces/sync_completed_callback_proxy.cpp @@ -51,10 +51,6 @@ void SyncCompletedCallbackProxy::OnSyncCompleted(const SyncResult &syncResults) } } MessageOption option{MessageOption::TF_ASYNC}; - if (Remote() == nullptr) { - HILOGE("Remote is nullptr"); - return; - } int32_t errCode = Remote()->SendRequest(static_cast(DPInterfaceCode::ON_SYNC_COMPLETED), data, reply, option); if (errCode != ERR_OK) { diff --git a/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.cpp b/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.cpp index 789a5a3351bbcde22ffc9b92c39b41d039da0222..e4c0e275efd98a66c80b6e0a54dcd3f144d84cf5 100644 --- a/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.cpp +++ b/common/test/profilechangelistenerstubunittest/profile_change_listener_stub_test.cpp @@ -125,7 +125,6 @@ HWTEST_F(ProfileChangeListenerStubTest, OnRemoteRequest_001, TestSize.Level0) MessageParcel data; MessageParcel reply; MessageOption option; - ASSERT_NE(listenerStub_, nullptr); int32_t ret = listenerStub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(DP_INTERFACE_CHECK_FAILED, ret); } @@ -134,7 +133,6 @@ HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileAddInner_001, TestSi { MessageParcel data; MessageParcel reply; - ASSERT_NE(listenerStub_, nullptr); int32_t ret = listenerStub_->OnTrustDeviceProfileAddInner(data, reply); EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); } @@ -143,7 +141,6 @@ HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileDeleteInner_001, Tes { MessageParcel data; MessageParcel reply; - ASSERT_NE(listenerStub_, nullptr); int32_t ret = listenerStub_->OnTrustDeviceProfileDeleteInner(data, reply); EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); } @@ -152,7 +149,6 @@ HWTEST_F(ProfileChangeListenerStubTest, OnTrustDeviceProfileUpdateInner_001, Tes { MessageParcel data; MessageParcel reply; - ASSERT_NE(listenerStub_, nullptr); int32_t ret = listenerStub_->OnTrustDeviceProfileUpdateInner(data, reply); EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); } @@ -161,7 +157,6 @@ HWTEST_F(ProfileChangeListenerStubTest, OnDeviceProfileAddInner_001, TestSize.Le { MessageParcel data; MessageParcel reply; - ASSERT_NE(listenerStub_, nullptr); int32_t ret = listenerStub_->OnDeviceProfileAddInner(data, reply); EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); } @@ -170,7 +165,6 @@ HWTEST_F(ProfileChangeListenerStubTest, OnDeviceProfileDeleteInner_001, TestSize { MessageParcel data; MessageParcel reply; - ASSERT_NE(listenerStub_, nullptr); int32_t ret = listenerStub_->OnDeviceProfileDeleteInner(data, reply); EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); } @@ -179,7 +173,6 @@ HWTEST_F(ProfileChangeListenerStubTest, OnDeviceProfileUpdateInner_001, TestSize { MessageParcel data; MessageParcel reply; - ASSERT_NE(listenerStub_, nullptr); int32_t ret = listenerStub_->OnDeviceProfileUpdateInner(data, reply); EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); } @@ -188,7 +181,6 @@ HWTEST_F(ProfileChangeListenerStubTest, OnServiceProfileAddInner_001, TestSize.L { MessageParcel data; MessageParcel reply; - ASSERT_NE(listenerStub_, nullptr); int32_t ret = listenerStub_->OnServiceProfileAddInner(data, reply); EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); } @@ -197,7 +189,6 @@ HWTEST_F(ProfileChangeListenerStubTest, OnServiceProfileDeleteInner_001, TestSiz { MessageParcel data; MessageParcel reply; - ASSERT_NE(listenerStub_, nullptr); int32_t ret = listenerStub_->OnServiceProfileDeleteInner(data, reply); EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); } @@ -206,7 +197,6 @@ HWTEST_F(ProfileChangeListenerStubTest, OnServiceProfileUpdateInner_001, TestSiz { MessageParcel data; MessageParcel reply; - ASSERT_NE(listenerStub_, nullptr); int32_t ret = listenerStub_->OnServiceProfileUpdateInner(data, reply); EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); } @@ -215,7 +205,6 @@ HWTEST_F(ProfileChangeListenerStubTest, OnCharacteristicProfileAddInner_001, Tes { MessageParcel data; MessageParcel reply; - ASSERT_NE(listenerStub_, nullptr); int32_t ret = listenerStub_->OnCharacteristicProfileAddInner(data, reply); EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); } @@ -224,7 +213,6 @@ HWTEST_F(ProfileChangeListenerStubTest, OnCharacteristicProfileDeleteInner_001, { MessageParcel data; MessageParcel reply; - ASSERT_NE(listenerStub_, nullptr); int32_t ret = listenerStub_->OnCharacteristicProfileDeleteInner(data, reply); EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); } @@ -233,7 +221,6 @@ HWTEST_F(ProfileChangeListenerStubTest, OnCharacteristicProfileUpdateInner_001, { MessageParcel data; MessageParcel reply; - ASSERT_NE(listenerStub_, nullptr); int32_t ret = listenerStub_->OnCharacteristicProfileUpdateInner(data, reply); EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); } diff --git a/old/common/include/parcel_helper.h b/old/common/include/parcel_helper.h index baa49673e5849c9ce921e98bec7f0f11201052dd..5e4dfd77b43e976c81255ba1fe6e170d4c8492c5 100644 --- a/old/common/include/parcel_helper.h +++ b/old/common/include/parcel_helper.h @@ -107,4 +107,4 @@ namespace DeviceProfile { } while (0) } // namespace DeviceProfile } // namespace OHOS -#endif // OHOS_DEVICE_PROFILE_PARCEL_HELPER_H \ No newline at end of file +#endif // OHOS_DEVICE_PROFILE_PARCEL_HELPER_H diff --git a/old/services/core/src/authority/trust_group_manager.cpp b/old/services/core/src/authority/trust_group_manager.cpp index 8da10e67ff04893bb4ae9e968303752bc60ce396..46dc34f1e1a52398316e9abe6c7c7249547ff35d 100644 --- a/old/services/core/src/authority/trust_group_manager.cpp +++ b/old/services/core/src/authority/trust_group_manager.cpp @@ -78,10 +78,6 @@ bool TrustGroupManager::InitHichainService() void TrustGroupManager::InitDataChangeListener() { dataChangeListener_.onDeviceUnBound = OnDeviceUnBoundAdapter; - if (hichainGmInstance_ == nullptr) { - HILOGE("hichainGmInstance_ is nullptr"); - return; - } if (hichainGmInstance_->regDataChangeListener(AUTH_APPID.c_str(), &dataChangeListener_) != 0) { HILOGE("auth RegDataChangeListener failed"); } diff --git a/old/services/core/src/contentsensor/content_sensor_manager.cpp b/old/services/core/src/contentsensor/content_sensor_manager.cpp index 6792235b367d4ee1606bf28ec95264f0ab7a6c7d..86e13eb3dd7b2506400255be819f2cc243858f54 100644 --- a/old/services/core/src/contentsensor/content_sensor_manager.cpp +++ b/old/services/core/src/contentsensor/content_sensor_manager.cpp @@ -52,13 +52,13 @@ bool ContentSensorManager::Collect() HITRACE_METER_NAME(HITRACE_TAG_DEVICE_PROFILE, DP_CONTENT_SENSOR_TRACE); for (auto& task : taskList) { ServiceCharacteristicProfile profileData; - if (task == nullptr || !task->ConvertToProfileData(profileData)) { + if (!task->ConvertToProfileData(profileData)) { continue; } task->DoCollect(profileData); } }; - if (csCollectorHandler_ == nullptr || !csCollectorHandler_->PostTask(csTask)) { + if (!csCollectorHandler_->PostTask(csTask)) { HILOGE("post task failed"); return false; } diff --git a/old/services/core/src/dbstorage/device_profile_storage_manager.cpp b/old/services/core/src/dbstorage/device_profile_storage_manager.cpp index 6138571c13a0cb922bd521678e10160aa4d59770..56a2cd1ac83bd0528b8d8767a253fb1213ff6ab0 100644 --- a/old/services/core/src/dbstorage/device_profile_storage_manager.cpp +++ b/old/services/core/src/dbstorage/device_profile_storage_manager.cpp @@ -256,10 +256,7 @@ void DeviceProfileStorageManager::SetServiceType(const std::string& udid, } return; } - if (onlineSyncTbl_ == nullptr) { - HILOGE("onlineSyncTbl is nullptr"); - return; - } + std::string value; std::string key = GenerateKey(udid, SERVICES, KeyType::SERVICE_LIST); int32_t result = onlineSyncTbl_->GetDeviceProfile(key, value); @@ -332,7 +329,7 @@ int32_t DeviceProfileStorageManager::DeleteDeviceProfile(const std::string& serv int32_t DeviceProfileStorageManager::RemoveUnBoundDeviceProfile(const std::string& udid) { - if (onlineSyncTbl_ == nullptr || onlineSyncTbl_->GetInitStatus() == StorageInitStatus::INIT_FAILED) { + if (onlineSyncTbl_->GetInitStatus() == StorageInitStatus::INIT_FAILED) { HILOGE("kvstore init failed"); return ERR_DP_INIT_DB_FAILED; } @@ -357,7 +354,7 @@ int32_t DeviceProfileStorageManager::RemoveUnBoundDeviceProfile(const std::strin int32_t DeviceProfileStorageManager::RemoveRemoteDeviceProfile() { - if (onlineSyncTbl_ == nullptr || onlineSyncTbl_->GetInitStatus() == StorageInitStatus::INIT_FAILED) { + if (onlineSyncTbl_->GetInitStatus() == StorageInitStatus::INIT_FAILED) { HILOGE("kvstore init failed"); return ERR_DP_INIT_DB_FAILED; } @@ -480,9 +477,7 @@ bool DeviceProfileStorageManager::CheckSyncOption(const SyncOptions& syncOptions DpDeviceManager::GetInstance().GetDeviceList(onlineDevices); std::list onlineDeviceIds; for (const auto& onlineDevice : onlineDevices) { - if (onlineDevice != nullptr) { - onlineDeviceIds.emplace_back(onlineDevice->GetNetworkId()); - } + onlineDeviceIds.emplace_back(onlineDevice->GetNetworkId()); } // check whether deviceId is online @@ -514,10 +509,6 @@ void DeviceProfileStorageManager::FlushProfileItems() { std::string services; std::string servicesKey = GenerateKey(localUdid_, SERVICES, KeyType::SERVICE_LIST); - if (onlineSyncTbl_ == nullptr) { - HILOGE("onlineSyncTbl is nullptr"); - return; - } int32_t errCode = onlineSyncTbl_->GetDeviceProfile(servicesKey, services); std::unique_lock autoLock(serviceLock_); if (errCode == ERR_OK) { @@ -552,11 +543,11 @@ void DeviceProfileStorageManager::RegisterCallbacks() { HILOGI("called"); int32_t errCode = ERR_OK; - if (onlineSyncTbl_ != nullptr && kvStoreObserver_ != nullptr) { + if (kvStoreObserver_ != nullptr) { errCode = onlineSyncTbl_->SubscribeKvStore(kvStoreObserver_); HILOGI("SubscribeKvStore errCode = %{public}d", errCode); } - if (onlineSyncTbl_ != nullptr && kvStoreSyncCallback_ != nullptr) { + if (kvStoreSyncCallback_ != nullptr) { errCode = onlineSyncTbl_->RegisterSyncCallback(kvStoreSyncCallback_); HILOGI("RegisterSyncCallback errCode = %{public}d", errCode); } @@ -582,10 +573,6 @@ int32_t DeviceProfileStorageManager::UnSubscribeKvStore(const std::shared_ptr autoLock(callbackLock_); kvStoreObserver_ = nullptr; - if (onlineSyncTbl_ == nullptr) { - HILOGE("onlineSyncTbl is nullptr"); - return ERR_DP_INVALID_PARAMS; - } return onlineSyncTbl_->UnSubscribeKvStore(observer); } @@ -603,10 +590,6 @@ int32_t DeviceProfileStorageManager::UnRegisterSyncCallback() { std::lock_guard autoLock(callbackLock_); kvStoreSyncCallback_ = nullptr; - if (onlineSyncTbl_ == nullptr) { - HILOGE("onlineSyncTbl is nullptr"); - return ERR_DP_INVALID_PARAMS; - } return onlineSyncTbl_->UnRegisterSyncCallback(); } diff --git a/old/services/core/src/dbstorage/sync_coordinator.cpp b/old/services/core/src/dbstorage/sync_coordinator.cpp index 5fe340d26d6581aa605894e82e1714b4c021cd90..dc9059df23b46efe8a5a8111e2c46624df2e1c3e 100644 --- a/old/services/core/src/dbstorage/sync_coordinator.cpp +++ b/old/services/core/src/dbstorage/sync_coordinator.cpp @@ -70,7 +70,7 @@ bool SyncCoordinator::IsOnlineSync() bool SyncCoordinator::DispatchSyncTask(const SyncTask& syncTask, int64_t delayTime) { - if (syncHandler_ == nullptr || !syncHandler_->PostTask(syncTask, delayTime)) { + if (!syncHandler_->PostTask(syncTask, delayTime)) { HILOGE("post task failed"); isOnSync_ = false; return false; diff --git a/old/tools/dp/src/dp_command.cpp b/old/tools/dp/src/dp_command.cpp index 8d1205573ddf2b26846d8867a9f082385eac5978..05b53ff3030148c87054657bfac93af7fc1b6497 100644 --- a/old/tools/dp/src/dp_command.cpp +++ b/old/tools/dp/src/dp_command.cpp @@ -142,9 +142,6 @@ ErrCode DpShellCommand::GetDeviceCommand() return ret; } for (int32_t i = 0; i < infoNum; i++) { - if (info == nullptr) { - continue; - } resultReceiver_.append("networkId: " + std::string(info->networkId) + " deviceName:" + std::string(info->deviceName) + "\n"); info++; @@ -345,9 +342,7 @@ int32_t DpShellCommand::HandleNormalOption(int option, std::string& deviceId, int32_t result = ERR_OK; switch (option) { case 'h': { - if (optind - 1 < argc_) { - HILOGI("'dp query' %{public}s", argv_[optind - 1]); - } + HILOGI("'dp query' %{public}s", argv_[optind - 1]); result = OHOS::ERR_INVALID_VALUE; break; } @@ -393,9 +388,7 @@ int32_t DpShellCommand::HandleSyncOption(int option, std::string& mode, std::lis int32_t result = ERR_OK; switch (option) { case 'h': { - if (optind - 1 < argc_) { - HILOGI("'dp sync' %{public}s", argv_[optind - 1]); - } + HILOGI("'dp sync' %{public}s", argv_[optind - 1]); result = OHOS::ERR_INVALID_VALUE; break; } @@ -437,9 +430,7 @@ int32_t DpShellCommand::HandleSubscribeOption(int option, std::string& deviceId, int32_t result = ERR_OK; switch (option) { case 'h': { - if (optind - 1 < argc_) { - HILOGI("'dp subscribe' %{public}s", argv_[optind - 1]); - } + HILOGI("'dp subscribe' %{public}s", argv_[optind - 1]); result = OHOS::ERR_INVALID_VALUE; break; }