修改检视意见

Signed-off-by: wangzhaohao <wangzhaohao@huawei.com>
This commit is contained in:
wangzhaohao 2024-05-06 20:52:34 +08:00
parent d940f5ab72
commit 89deda3bbf
8 changed files with 51 additions and 41 deletions

View File

@ -94,7 +94,6 @@ int32_t LnnDestroyKvAdapter(int32_t dbId)
std::shared_ptr<KVAdapter> FindKvStorePtr(int32_t &dbId)
{
std::lock_guard<std::mutex> lock(g_kvAdapterWrapperMutex);
auto iter = g_dbID2KvAdapter.find(dbId);
if (iter == g_dbID2KvAdapter.end()) {
LNN_LOGE(LNN_LEDGER, "dbID is not exist, dbId = %{public}d", dbId);

View File

@ -551,7 +551,7 @@ static int32_t GetInfoFromSplitKey(char splitKey[][SPLIT_MAX_LEN], int64_t *acco
LNN_LOGE(LNN_BUILDER, "invalid param");
return SOFTBUS_INVALID_PARAM;
}
if (sscanf_s(splitKey[0], "%ld", accountId, sizeof(int64_t)) <= 0) {
if (sscanf_s(splitKey[0], "%ld", accountId) <= 0) {
LNN_LOGE(LNN_BUILDER, "fail:sscanf_s accountId fail.");
return SOFTBUS_ERR;
}
@ -996,4 +996,4 @@ void LnnDeInitCloudSyncModule(void)
if (LnnDestroyKvAdapter(dbId) != SOFTBUS_OK) {
LNN_LOGE(LNN_BUILDER, "DeInit Cloud Sync module fail");
}
}
}

View File

@ -80,7 +80,7 @@ static void UpdateStateVersionAndStore(void)
return;
}
char value[STATE_VERSION_VALUE_LENGTH] = {0};
(void) sprintf_s(value, STATE_VERSION_VALUE_LENGTH, "%d", g_localNetLedger.localInfo.stateVersion);
(void)sprintf_s(value, STATE_VERSION_VALUE_LENGTH, "%d", g_localNetLedger.localInfo.stateVersion);
if (LnnLedgerDataChangeSyncToDB(DEVICE_INFO_STATE_VERSION, value, strlen(value)) != SOFTBUS_OK) {
LNN_LOGE(LNN_LEDGER, "ledger state version change sync to cloud failed");
}
@ -581,8 +581,8 @@ static int32_t UpdateStateVersion(const void *buf)
LNN_LOGI(LNN_LEDGER, "no account info. no need update to cloud");
return SOFTBUS_OK;
}
char value[STATE_VERSION_VALUE_LENGTH] = {0};
(void) sprintf_s(value, STATE_VERSION_VALUE_LENGTH, "%d", g_localNetLedger.localInfo.stateVersion);
char value[STATE_VERSION_VALUE_LENGTH] = {0};
(void)sprintf_s(value, STATE_VERSION_VALUE_LENGTH, "%d", g_localNetLedger.localInfo.stateVersion);
if (LnnLedgerDataChangeSyncToDB(DEVICE_INFO_STATE_VERSION, value, strlen(value)) != SOFTBUS_OK) {
LNN_LOGE(LNN_LEDGER, "ledger state version change sync to cloud failed");
}

View File

@ -336,6 +336,17 @@ enum SoftBusErrNo {
SOFTBUS_NETWORK_JOIN_LNN_START_ERR,
SOFTBUS_NETWORK_LEAVE_LNN_START_ERR,
SOFTBUS_CENTER_SERVER_INIT_FAILED,
SOFTBUS_KV_DB_PTR_NULL,
SOFTBUS_KV_PUT_DB_FAIL,
SOFTBUS_KV_DB_INIT_FAIL,
SOFTBUS_KV_DEL_DB_FAIL,
SOFTBUS_KV_GET_DB_FAIL,
SOFTBUS_KV_CLOUD_DISABLED,
SOFTBUS_KV_CLOUD_SYNC_FAIL,
SOFTBUS_KV_REGISTER_SYNC_LISTENER_FAILED,
SOFTBUS_KV_UNREGISTER_SYNC_LISTENER_FAILED,
SOFTBUS_KV_REGISTER_DATA_LISTENER_FAILED,
SOFTBUS_KV_UNREGISTER_DATA_LISTENER_FAILED,
/* errno begin: -((203 << 21) | (4 << 16) | (1 << 12) | 0x0FFF) */
SOFTBUS_LANE_ERR_BASE = SOFTBUS_SUB_ERRNO(LNN_SUB_MODULE_CODE, LNN_LANE_MODULE_CODE),
@ -548,19 +559,7 @@ enum SoftBusErrNo {
SOFTBUS_BC_MGR_REG_DUP, // duplicate registration
SOFTBUS_BC_MGR_WAIT_COND_FAIL, // wait signal fail
SOFTBUS_BC_MGR_UNEXPECTED_PACKETS, // parse packets fail
SOFTBUS_KV_DB_PTR_NULL,
SOFTBUS_KV_PUT_DB_FAIL,
SOFTBUS_KV_DB_INIT_FAIL,
SOFTBUS_KV_DEL_DB_FAIL,
SOFTBUS_KV_GET_DB_FAIL,
SOFTBUS_KV_CLOUD_DISABLED,
SOFTBUS_KV_CLOUD_SYNC_FAIL,
SOFTBUS_KV_REGISTER_SYNC_LISTENER_FAILED,
SOFTBUS_KV_UNREGISTER_SYNC_LISTENER_FAILED,
SOFTBUS_KV_REGISTER_DATA_LISTENER_FAILED,
SOFTBUS_KV_UNREGISTER_DATA_LISTENER_FAILED,
/* softbus ok */
SOFTBUS_OK = 0,
};

View File

@ -40,17 +40,22 @@ protected:
void SetUp();
void TearDown();
};
void KVAdapterTest::SetUpTestCase(void)
{
kvStore = make_shared<KVAdapter>(APP_ID, STORE_ID,
make_shared<KvDataChangeListener>());
}
void KVAdapterTest::TearDownTestCase(void) {
void KVAdapterTest::TearDownTestCase(void)
{
}
void KVAdapterTest::SetUp()
{
kvStore->Init();
}
void KVAdapterTest::TearDown()
{
kvStore->DeInit();

View File

@ -45,12 +45,19 @@ void KVAdapterWrapperTest::SetUpTestCase(void)
LnnCreateKvAdapter(&dbID, APP_ID.c_str(), APP_ID_LEN, STORE_ID.c_str(), STORE_ID_LEN);
g_dbId = dbID;
}
void KVAdapterWrapperTest::TearDownTestCase(void)
{
LnnDestroyKvAdapter(g_dbId);
}
void KVAdapterWrapperTest::SetUp() { }
void KVAdapterWrapperTest::TearDown() { }
void KVAdapterWrapperTest::SetUp()
{
}
void KVAdapterWrapperTest::TearDown()
{
}
/**
* @tc.name: LnnPutDBData

View File

@ -64,7 +64,7 @@ void LNNDataCloudSyncTest::TearDown() {}
HWTEST_F(LNNDataCloudSyncTest, LnnLedgerAllDataSyncToDB_Test_001, TestSize.Level1)
{
LnnInitCloudSyncModule();
NodeInfo *info = NULL;
NodeInfo *info = nullptr;
int32_t ret = LnnLedgerAllDataSyncToDB(info);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
info = (NodeInfo *)SoftBusCalloc(sizeof(NodeInfo));
@ -88,8 +88,8 @@ HWTEST_F(LNNDataCloudSyncTest, LnnLedgerAllDataSyncToDB_Test_001, TestSize.Level
HWTEST_F(LNNDataCloudSyncTest, LnnLedgerDataChangeSyncToDB_Test_001, TestSize.Level1)
{
LnnInitCloudSyncModule();
char *key = NULL;
char *value = NULL;
char *key = nullptr;
char *value = nullptr;
int32_t ret = LnnLedgerDataChangeSyncToDB(key, value, strlen(value));
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
LnnDeleteSyncToDB();
@ -105,8 +105,8 @@ HWTEST_F(LNNDataCloudSyncTest, LnnLedgerDataChangeSyncToDB_Test_001, TestSize.Le
HWTEST_F(LNNDataCloudSyncTest, LnnDBDataChangeSyncToCache_Test_001, TestSize.Level1)
{
LnnInitCloudSyncModule();
char *key = NULL;
char *value = NULL;
char *key = nullptr;
char *value = nullptr;
ChangeType type = DB_UPDATE;
int32_t ret = LnnDBDataChangeSyncToCache(key, value, type);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
@ -132,8 +132,8 @@ HWTEST_F(LNNDataCloudSyncTest, LnnDBDataChangeSyncToCache_Test_001, TestSize.Lev
HWTEST_F(LNNDataCloudSyncTest, LnnDBDataAddChangeSyncToCache_Test_001, TestSize.Level1)
{
LnnInitCloudSyncModule();
const char **key = NULL;
const char **value = NULL;
const char **key = nullptr;
const char **value = nullptr;
int32_t keySize = 0;
int32_t ret = LnnDBDataAddChangeSyncToCache(key, value, keySize);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
@ -149,7 +149,7 @@ HWTEST_F(LNNDataCloudSyncTest, LnnDBDataAddChangeSyncToCache_Test_001, TestSize.
HWTEST_F(LNNDataCloudSyncTest, LnnGetAccountIdfromLocalCache_Test_001, TestSize.Level1)
{
LnnInitCloudSyncModule();
int64_t *buf = NULL;
int64_t *buf = nullptr;
int32_t ret = LnnGetAccountIdfromLocalCache(buf);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
int64_t buffer = 0;
@ -157,4 +157,4 @@ HWTEST_F(LNNDataCloudSyncTest, LnnGetAccountIdfromLocalCache_Test_001, TestSize.
EXPECT_EQ(ret, SOFTBUS_OK);
LnnDeInitCloudSyncModule();
}
} // namespace OHOS
} // namespace OHOS

View File

@ -955,8 +955,8 @@ HWTEST_F(LNNDisctributedLedgerTest, DLGET_REMOTE_PTK_Test_001, TestSize.Level1)
*/
HWTEST_F(LNNDisctributedLedgerTest, LnnSetDLUnifiedDeviceName_Test_001, TestSize.Level1)
{
char *udid = NULL;
char *name = NULL;
char *udid = nullptr;
char *name = nullptr;
bool ret = LnnSetDLUnifiedDeviceName(udid, name);
EXPECT_TRUE(ret == false);
const char *devUdid = "123456789";
@ -973,8 +973,8 @@ HWTEST_F(LNNDisctributedLedgerTest, LnnSetDLUnifiedDeviceName_Test_001, TestSize
*/
HWTEST_F(LNNDisctributedLedgerTest, LnnSetDLUnifiedDefaultDeviceName_Test_001, TestSize.Level1)
{
char *udid = NULL;
char *name = NULL;
char *udid = nullptr;
char *name = nullptr;
bool ret = LnnSetDLUnifiedDefaultDeviceName(udid, name);
EXPECT_TRUE(ret == false);
const char *devUdid = "111111111";
@ -991,8 +991,8 @@ HWTEST_F(LNNDisctributedLedgerTest, LnnSetDLUnifiedDefaultDeviceName_Test_001, T
*/
HWTEST_F(LNNDisctributedLedgerTest, LnnSetDLDeviceNickNameByUdid_Test_001, TestSize.Level1)
{
char *udid = NULL;
char *name = NULL;
char *udid = nullptr;
char *name = nullptr;
bool ret = LnnSetDLDeviceNickNameByUdid(udid, name);
EXPECT_TRUE(ret == false);
const char *devUdid = "2222222222";
@ -1009,7 +1009,7 @@ HWTEST_F(LNNDisctributedLedgerTest, LnnSetDLDeviceNickNameByUdid_Test_001, TestS
*/
HWTEST_F(LNNDisctributedLedgerTest, LnnSetDLDeviceStateVersion_Test_001, TestSize.Level1)
{
char *udid = NULL;
char *udid = nullptr;
int32_t stateVersion = 0;
bool ret = LnnSetDLDeviceStateVersion(udid, stateVersion);
EXPECT_TRUE(ret == false);
@ -1026,7 +1026,7 @@ HWTEST_F(LNNDisctributedLedgerTest, LnnSetDLDeviceStateVersion_Test_001, TestSiz
*/
HWTEST_F(LNNDisctributedLedgerTest, LnnSetDLDeviceBroadcastCipherKey_Test_001, TestSize.Level1)
{
char *udid = NULL;
char *udid = nullptr;
const char *cipherKey = "qqqqqqqqqqqq";
bool ret = LnnSetDLDeviceBroadcastCipherKey(udid, cipherKey);
EXPECT_TRUE(ret == false);
@ -1043,7 +1043,7 @@ HWTEST_F(LNNDisctributedLedgerTest, LnnSetDLDeviceBroadcastCipherKey_Test_001, T
*/
HWTEST_F(LNNDisctributedLedgerTest, LnnSetDLDeviceBroadcastCipherIv_Test_001, TestSize.Level1)
{
char *udid = NULL;
char *udid = nullptr;
const char *cipherIv = "qqqqqqqqqqqq";
bool ret = LnnSetDLDeviceBroadcastCipherIv(udid, cipherIv);
EXPECT_TRUE(ret == false);
@ -1062,7 +1062,7 @@ HWTEST_F(LNNDisctributedLedgerTest, LnnUpdateDistributedNodeInfo_Test_001, TestS
{
NodeInfo newInfo;
memset_s(&newInfo, sizeof(NodeInfo), 0, sizeof(NodeInfo));
const char *udid = NULL;
const char *udid = nullptr;
newInfo.accountId = 18390933952;
int32_t ret = LnnUpdateDistributedNodeInfo(&newInfo, udid);
EXPECT_TRUE(ret == SOFTBUS_INVALID_PARAM);