From ab4cd36b0df00c18eea2268866be52b1d31cad14 Mon Sep 17 00:00:00 2001 From: zjucx Date: Mon, 7 Mar 2022 16:00:03 +0800 Subject: [PATCH 1/4] modify NULL to nullptr Signed-off-by: zjucx --- tools/dp/src/dp_command.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/dp/src/dp_command.cpp b/tools/dp/src/dp_command.cpp index ddb871e..fdb15c7 100755 --- a/tools/dp/src/dp_command.cpp +++ b/tools/dp/src/dp_command.cpp @@ -78,7 +78,7 @@ ErrCode DpShellCommand::HelpCommand() ErrCode DpShellCommand::GetDeviceCommand() { resultReceiver_.append("[remote device list]\n"); - NodeBasicInfo *info = NULL; + NodeBasicInfo *info = nullptr; int32_t infoNum = 0; int32_t ret = GetAllNodeDeviceInfo("dp", &info, &infoNum); if (ret != ERR_OK) { From 3d2d590cfd44e70ba9aafd5717a26cf76968bf1a Mon Sep 17 00:00:00 2001 From: Gymee Date: Mon, 7 Mar 2022 19:10:23 +0800 Subject: [PATCH 2/4] fix logic problem when merge subscribe info Signed-off-by: Gymee Change-Id: Icd6a8d007a322c0d73577429f695281ef2266b32 --- .../core/src/distributed_device_profile_client.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/interfaces/innerkits/core/src/distributed_device_profile_client.cpp b/interfaces/innerkits/core/src/distributed_device_profile_client.cpp index 4ecaa98..9a7a664 100755 --- a/interfaces/innerkits/core/src/distributed_device_profile_client.cpp +++ b/interfaces/innerkits/core/src/distributed_device_profile_client.cpp @@ -241,14 +241,12 @@ void DistributedDeviceProfileClient::MergeSubscribeInfoLocked(std::list Date: Tue, 8 Mar 2022 20:16:09 +0800 Subject: [PATCH 3/4] fix code review problems Signed-off-by: Gymee Change-Id: I2e2adfd05a02b6b4650cdba29c0f99695b3bb97d --- .../core/src/distributed_device_profile_proxy.cpp | 8 ++++---- .../innerkits/core/src/profile_event_notifier_stub.cpp | 2 +- services/core/src/authority/trust_group_manager.cpp | 4 ++-- services/core/src/distributed_device_profile_stub.cpp | 2 +- .../core/src/subscribemanager/profile_change_handler.cpp | 3 +++ services/core/test/unittest/event_subscribe_test.cpp | 2 +- services/core/test/unittest/profile_authority_test.cpp | 2 +- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/interfaces/innerkits/core/src/distributed_device_profile_proxy.cpp b/interfaces/innerkits/core/src/distributed_device_profile_proxy.cpp index ef942bb..ff705c8 100755 --- a/interfaces/innerkits/core/src/distributed_device_profile_proxy.cpp +++ b/interfaces/innerkits/core/src/distributed_device_profile_proxy.cpp @@ -68,7 +68,7 @@ int32_t DistributedDeviceProfileProxy::DeleteDeviceProfile(const std::string& se sptr remote = Remote(); MessageParcel data; if (!data.WriteInterfaceToken(IDistributedDeviceProfile::GetDescriptor())) { - HILOGE("write inteface token failed"); + HILOGE("write interface token failed"); return ERR_FLATTEN_OBJECT; } PARCEL_WRITE_HELPER(data, String, serviceId); @@ -84,7 +84,7 @@ int32_t DistributedDeviceProfileProxy::SubscribeProfileEvents( sptr remote = Remote(); MessageParcel data; if (!data.WriteInterfaceToken(IDistributedDeviceProfile::GetDescriptor())) { - HILOGE("write inteface token failed"); + HILOGE("write interface token failed"); return ERR_FLATTEN_OBJECT; } size_t size = subscribeInfos.size(); @@ -116,7 +116,7 @@ int32_t DistributedDeviceProfileProxy::UnsubscribeProfileEvents( sptr remote = Remote(); MessageParcel data; if (!data.WriteInterfaceToken(IDistributedDeviceProfile::GetDescriptor())) { - HILOGE("write inteface token failed"); + HILOGE("write interface token failed"); return ERR_FLATTEN_OBJECT; } if (!DeviceProfileUtils::WriteProfileEvents(profileEvents, data)) { @@ -142,7 +142,7 @@ int32_t DistributedDeviceProfileProxy::SyncDeviceProfile(const SyncOptions& sync sptr remote = Remote(); MessageParcel data; if (!data.WriteInterfaceToken(IDistributedDeviceProfile::GetDescriptor())) { - HILOGE("write inteface token failed"); + HILOGE("write interface token failed"); return ERR_FLATTEN_OBJECT; } diff --git a/interfaces/innerkits/core/src/profile_event_notifier_stub.cpp b/interfaces/innerkits/core/src/profile_event_notifier_stub.cpp index 700be80..95a9a6b 100755 --- a/interfaces/innerkits/core/src/profile_event_notifier_stub.cpp +++ b/interfaces/innerkits/core/src/profile_event_notifier_stub.cpp @@ -39,7 +39,7 @@ ProfileEventNotifierStub::HandlersMap ProfileEventNotifierStub::InitHandlersMap( int32_t ProfileEventNotifierStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { - HILOGI("code = %{public}d", code); + HILOGI("code = %{public}u", code); std::u16string descriptor = ProfileEventNotifierStub::GetDescriptor(); std::u16string remoteDescriptor = data.ReadInterfaceToken(); if (descriptor != remoteDescriptor) { diff --git a/services/core/src/authority/trust_group_manager.cpp b/services/core/src/authority/trust_group_manager.cpp index 9a07aae..9d3bc33 100644 --- a/services/core/src/authority/trust_group_manager.cpp +++ b/services/core/src/authority/trust_group_manager.cpp @@ -69,12 +69,12 @@ bool TrustGroupManager::CheckTrustGroup(const std::string& deviceId) int32_t ret = hichainGmInstance_->getRelatedGroups(ANY_OS_ACCOUNT, AUTH_APPID.c_str(), deviceId.c_str(), &returnGroups, &groupNum); if (ret != ERR_OK) { - HILOGE("faild , ret: %d", ret); + HILOGE("failed, ret:%{public}d", ret); return false; } if (returnGroups == nullptr || groupNum == 0) { - HILOGE("faild, returnGroups is nullptr"); + HILOGE("failed, returnGroups is nullptr"); return false; } diff --git a/services/core/src/distributed_device_profile_stub.cpp b/services/core/src/distributed_device_profile_stub.cpp index 6158727..3ea0996 100755 --- a/services/core/src/distributed_device_profile_stub.cpp +++ b/services/core/src/distributed_device_profile_stub.cpp @@ -49,7 +49,7 @@ bool DistributedDeviceProfileStub::EnforceInterfaceToken(MessageParcel& data) int32_t DistributedDeviceProfileStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { - HILOGI("code = %{public}d, flags = %{public}d", code, option.GetFlags()); + HILOGI("code = %{public}u, flags = %{public}d", code, option.GetFlags()); auto iter = funcsMap_.find(code); if (iter != funcsMap_.end()) { diff --git a/services/core/src/subscribemanager/profile_change_handler.cpp b/services/core/src/subscribemanager/profile_change_handler.cpp index 72fc09a..b2670d6 100755 --- a/services/core/src/subscribemanager/profile_change_handler.cpp +++ b/services/core/src/subscribemanager/profile_change_handler.cpp @@ -57,6 +57,9 @@ std::unique_ptr ProfileKey::Parse(const std::string& entryKey) int32_t index = 0; auto profileKey = std::make_unique(); + if (profileKey == nullptr) { + return nullptr; + } profileKey->udid = std::move(vec[index++]); if (profileKey->udid.size() != DEVICE_ID_SIZE) { HILOGE("parse udid failed"); diff --git a/services/core/test/unittest/event_subscribe_test.cpp b/services/core/test/unittest/event_subscribe_test.cpp index c70d0e5..b75a70a 100755 --- a/services/core/test/unittest/event_subscribe_test.cpp +++ b/services/core/test/unittest/event_subscribe_test.cpp @@ -421,7 +421,7 @@ HWTEST_F(EventSubscribeTest, SubscribeWithUnsusbscribe002, TestSize.Level2) } /** - * @tc.steps: step4. put a other subscribed service profile + * @tc.steps: step4. put a subscribed service profile * @tc.expected: step4. can't receive notification. */ errCode = PutFakeStorage(); diff --git a/services/core/test/unittest/profile_authority_test.cpp b/services/core/test/unittest/profile_authority_test.cpp index 6e84557..b2b7308 100644 --- a/services/core/test/unittest/profile_authority_test.cpp +++ b/services/core/test/unittest/profile_authority_test.cpp @@ -119,7 +119,7 @@ HWTEST_F(ProfileAuthorityTest, CheckAuthority_003, TestSize.Level0) /** * @tc.name: CheckAuthority_004 - * @tc.desc: check authority of a empty serviceId + * @tc.desc: check authority of an empty serviceId * @tc.type: FUNC */ HWTEST_F(ProfileAuthorityTest, CheckAuthority_004, TestSize.Level0) From e6ff801c98a14ecc73172fb858d833cd1dfaf14c Mon Sep 17 00:00:00 2001 From: Gymee Date: Wed, 9 Mar 2022 21:26:55 +0800 Subject: [PATCH 4/4] fix typo Signed-off-by: Gymee Change-Id: I64eacb149e095e61072492daf27e3bbfa238ca37 --- .../innerkits/core/src/distributed_device_profile_client.cpp | 4 ++-- services/core/src/dbstorage/sync_coordinator.cpp | 4 ++-- services/core/src/subscribemanager/profile_change_handler.cpp | 2 +- services/core/test/unittest/profile_authority_test.cpp | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/interfaces/innerkits/core/src/distributed_device_profile_client.cpp b/interfaces/innerkits/core/src/distributed_device_profile_client.cpp index 9a7a664..5c919b9 100755 --- a/interfaces/innerkits/core/src/distributed_device_profile_client.cpp +++ b/interfaces/innerkits/core/src/distributed_device_profile_client.cpp @@ -245,7 +245,7 @@ void DistributedDeviceProfileClient::MergeSubscribeInfoLocked(std::list