diff --git a/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_impl.cpp b/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_impl.cpp index d4e44d7a1e3e0672b60c22441ef3f380b5e9d12c..4a70a3aeb61d910483ebcec502664dad5e118647 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_impl.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_impl.cpp @@ -368,7 +368,7 @@ int EventImpl::Dispatch() bool EventImpl::IsValidArg(EventsMask events) const { EventsMask allEvents = ET_READ | ET_WRITE | ET_ERROR | ET_TIMEOUT; - return events && !(events & (~allEvents)); + return ((events != 0) && ((events & (~allEvents)) == 0)); } bool EventImpl::IsValidArg(EventTime timeout) const diff --git a/services/distributeddataservice/libs/distributeddb/common/src/flatbuffer_schema.cpp b/services/distributeddataservice/libs/distributeddb/common/src/flatbuffer_schema.cpp index 3ba5419beeecc57da34cacc17afc18d2f8faa317..021b5ec74002ce034825320a1e621d398e42d5de 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/flatbuffer_schema.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/flatbuffer_schema.cpp @@ -710,13 +710,8 @@ int SchemaObject::FlatBufferSchema::ParseCheckStructDefine(const reflection::Sch namespace { inline bool IsNotCompositeIndex(const std::string &indexStr) { - if (indexStr.empty()) { - return true; - } - if (indexStr == std::string("0")) { // In fact, test found that attrValue will be "0" if not exist - return true; - } - return false; + // In fact, test found that attrValue will be "0" if not exist + return indexStr.empty() || indexStr == std::string("0"); } } diff --git a/services/distributeddataservice/libs/distributeddb/common/src/json_object.cpp b/services/distributeddataservice/libs/distributeddb/common/src/json_object.cpp index 53b53e0eac4e5a65fed67bcd170640804688ac4a..eeaf99652214944485fa2f0ef854b0ebedcc2d55 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/json_object.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/json_object.cpp @@ -249,7 +249,7 @@ bool JsonObject::IsFieldPathExist(const FieldPath &inPath) const } int errCode = E_OK; (void)GetJsonValueByFieldPath(inPath, errCode); // Ignore return const reference - return (errCode == E_OK) ? true : false; + return (errCode == E_OK); } int JsonObject::GetFieldTypeByFieldPath(const FieldPath &inPath, FieldType &outType) const @@ -456,13 +456,8 @@ bool InsertFieldCheckParameter(const FieldPath &inPath, FieldType inType, const void LeafJsonNodeAppendValue(Json::Value &leafNode, FieldType inType, const FieldValue &inValue) { - switch (inType) { - case FieldType::LEAF_FIELD_STRING: - leafNode.append(Json::Value(inValue.stringValue)); - break; - default: - // Do nothing. - break; + if (inType == FieldType::LEAF_FIELD_STRING) { + leafNode.append(Json::Value(inValue.stringValue)); } } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_relational_storage_engine.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_relational_storage_engine.cpp index 3040d91e9a27ed88e604e39bfbdfc879d5e476d6..a6e113162d2f96da4ad402ebf9f4918847163fce 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_relational_storage_engine.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_single_relational_storage_engine.cpp @@ -69,7 +69,7 @@ int SQLiteSingleRelationalStorageEngine::CreateNewExecutor(bool isWrite, Storage break; } - errCode = Upgrade(db); // cerate meta_data table. + errCode = Upgrade(db); // create meta_data table. if (errCode != E_OK) { break; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp index 2ace92b4cb12b4d8c2c4fac090872b2c90dfdbf6..62e8f57afa78486ba1f9e7ee72a903694d7615dc 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp @@ -402,7 +402,7 @@ int SQLiteSingleVerStorageExecutor::MigrateSyncDataByVersion(uint64_t recordVer, // fix dataItem timestamp for migrate errCode = ProcessTimestampForSyncDataInCacheDB(dataItems); if (errCode != E_OK) { - LOGE("Chang the time stamp for migrate failed! errCode = [%d]", errCode); + LOGE("Change the time stamp for migrate failed! errCode = [%d]", errCode); goto END; } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp index 75ed7cdfcd994be7c203b60e6adbe15972ee83db..bc97fb4479db82733a9d11f57550100d547ea6df 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp @@ -534,9 +534,6 @@ int Metadata::ResetMetaDataAfterRemoveData(const DeviceID &deviceId) if (metadataMap_.find(hashDeviceId) != metadataMap_.end()) { metadata = metadataMap_[hashDeviceId]; metadata.clearDeviceDataMark = 0; - // when finished remove data, should reset send watermark between high version sync - // recv watermark has already reset in removedata func. - metadata.localWaterMark = 0; return SaveMetaDataValue(deviceId, metadata); } return -E_NOT_FOUND; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync.cpp index 70317ff5ef142d54957e857cbd5213afa8b1eff4..8275581e0f044659c67efbeb1c01c3754388cb1b 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync.cpp @@ -1638,7 +1638,7 @@ void SingleVerDataSync::FillRequestReSendPacket(const SingleVerSyncTaskContext * GetPeerWaterMark(curType, context->GetQuerySyncId(), context->GetDeviceId(), peerMark); uint32_t version = std::min(context->GetRemoteSoftwareVersion(), SOFTWARE_VERSION_CURRENT); - // transer reSend mode, RESPONSE_PULL transfer to push or query push + // transfer reSend mode, RESPONSE_PULL transfer to push or query push // PUSH_AND_PULL mode which sequenceId lager than first transfer to push or query push int reSendMode = SingleVerDataSyncUtils::GetReSendMode(context->GetMode(), reSendInfo.sequenceId, curType); if (GetSessionEndTimestamp() == std::max(reSendInfo.end, reSendInfo.deleteDataEnd) || diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp index d0e52aa8ba6896068a8fefdfe15991cdabf5e05f..680e617854903afff3dfc8afe8a92c383a038194 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_kv_syncer.cpp @@ -102,7 +102,7 @@ void SingleVerKVSyncer::LocalDataChanged(int notifyEvent) RefObject::DecObjRef(syncEngine_); }); // if task schedule failed, but triggerSyncTask_ is not set to true, other thread may skip the schedule time - // when task schedule failed, it means unormal status, it is unable to shedule next time probably + // when task schedule failed, it means unormal status, it is unable to schedule next time probably // so it is ok if other thread skip the schedule if last task schedule failed if (errCode != E_OK) { triggerSyncTask_ = true; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp index 8ebefdd9ab2cb7bbc41fadfb0e317559a6d05202..2466b6c0f2c6f93706c98f71c231934984981899 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp @@ -619,7 +619,7 @@ int SyncEngine::ExecSyncTask(ISyncTaskContext *context) if (!context->IsTargetQueueEmpty()) { context->MoveToNextTarget(); int checkErrCode = E_OK; - // rdb dont support PermissionCheck + // rdb don't support PermissionCheck if (syncInterface_->GetInterfaceType() != ISyncInterface::SYNC_RELATION) { checkErrCode = RunPermissionCheck(context->GetDeviceId(), GetPermissionCheckFlag(context->IsAutoSync(), context->GetMode())); @@ -1013,8 +1013,8 @@ bool SyncEngine::IsEngineActive() const void SyncEngine::SchemaChange() { std::lock_guard lock(contextMapLock_); - for (auto &enrty : syncTaskContextMap_) { - auto context = enrty.second; + for (auto &entry : syncTaskContextMap_) { + auto context = entry.second; if (context->IsKilled()) { continue; } diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_register_syncdb_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_register_syncdb_test.cpp index cd6e357a6c624f4f0312d3ad1e4635fae1404258..9c46b69b1adb9ae9325293b9b59af52b9ca12248 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_register_syncdb_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_register_syncdb_test.cpp @@ -1599,7 +1599,7 @@ HWTEST_F(DistributedDBInterfacesRegisterSyncDBTest, SnapshotUnRegisterObserver00 /** * @tc.name: SnapshotUnRegisterObserver002 - * @tc.desc: Unregister a null snaphot observer + * @tc.desc: Unregister a null snapshot observer * @tc.require: AR000BVDFP AR000CQDVI * @tc.author: liujialei */ @@ -1616,7 +1616,7 @@ HWTEST_F(DistributedDBInterfacesRegisterSyncDBTest, SnapshotUnRegisterObserver00 /** * @tc.name: SnapshotUnRegisterObserver003 - * @tc.desc: Unregister a unregister snaphot observer + * @tc.desc: Unregister a unregister snapshot observer * @tc.require: AR000BVDFP AR000CQDVI * @tc.author: liujialei */ @@ -1675,7 +1675,7 @@ static void SnapshotUnRegisterObserver004Inner() /** * @tc.name: SnapshotUnRegisterObserver004 - * @tc.desc: Check a unregister snaphot observer + * @tc.desc: Check a unregister snapshot observer * @tc.require: AR000BVDFP AR000CQDVI * @tc.author: liujialei */ @@ -1869,4 +1869,3 @@ HWTEST_F(DistributedDBInterfacesRegisterSyncDBTest, GetSnapshotObserverData001, EXPECT_EQ(g_kvDelegatePtr->ReleaseKvStoreSnapshot(g_snapshotDelegatePtr), OK); g_snapshotDelegatePtr = nullptr; } - diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_schema_database_upgrade_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_schema_database_upgrade_test.cpp index d8e4caf6f71fdefb23d3b9d87145bd916fd6ee92..c0dd063026e1c17546fe5d6fef2abe2f6c4ba9e4 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_schema_database_upgrade_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_schema_database_upgrade_test.cpp @@ -369,7 +369,7 @@ HWTEST_F(DistributedDBInterfacesSchemaDatabaseUpgradeTest, UpgradeFromSchema002, */ HWTEST_F(DistributedDBInterfacesSchemaDatabaseUpgradeTest, UpgradeFromSchema003, TestSize.Level1) { - // Compatible schema can increase field, but must not be null without defaut. + // Compatible schema can increase field, but must not be null without default. g_baseSchema = SCHEMA_BASE; g_expectError = SCHEMA_MISMATCH; TestUpgradeFromSchema("UpgradeFromSchema003_1", std::vector{"LACK", "BASE", "FULL", "FULL_NULL"}, diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_space_management_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_space_management_test.cpp index 818c81babccff2b25d1da7a30e534630090d1149..0a837aded51ff49a4e32edf9b67c44a849841d2d 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_space_management_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_space_management_test.cpp @@ -264,7 +264,7 @@ HWTEST_F(DistributedDBInterfacesSpaceManagementTest, GetKvStoreDiskSize002, Test * @tc.steps: step5/6. Get Db size by GetKvStoreDiskSize. * @tc.expected: step5/6. Return right size and ok. */ - std::this_thread::sleep_for(std::chrono::milliseconds(100)); // for vaccum + std::this_thread::sleep_for(std::chrono::milliseconds(100)); // for vacuum singleAndMultiDbSize = 0; EXPECT_EQ(g_mgr.GetKvStoreDiskSize(g_storeId, singleAndMultiDbSize), OK); ASSERT_TRUE(dbSizeForCheck != singleAndMultiDbSize); diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_mock_sync_module_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_mock_sync_module_test.cpp index 9080824ffc5ba21da492c352e522ef00c83d4467..a97202590b874c24fc46d7318da4f4cc5880a5ce 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_mock_sync_module_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_mock_sync_module_test.cpp @@ -139,7 +139,7 @@ HWTEST_F(DistributedDBMockSyncModuleTest, StateMachineCheck003, TestSize.Level1) EXPECT_CALL(syncTaskContext, IsCurrentSyncTaskCanBeSkipped()) .WillOnce(Return(true)) .WillOnce(Return(false)); - // we expect machine dont change context status when queue not empty + // we expect machine don't change context status when queue not empty EXPECT_CALL(syncTaskContext, SetOperationStatus(_)).WillOnce(Return()); EXPECT_CALL(syncTaskContext, SetTaskExecStatus(_)).Times(0); @@ -219,7 +219,7 @@ HWTEST_F(DistributedDBMockSyncModuleTest, StateMachineCheck006, TestSize.Level1) EXPECT_CALL(syncTaskContext, IsCurrentSyncTaskCanBeSkipped()) .WillRepeatedly(Return(syncTaskContext.CallIsCurrentSyncTaskCanBeSkipped())); EXPECT_CALL(syncTaskContext, MoveToNextTarget()).WillOnce(Return()); - // we expect machine dont change context status when queue not empty + // we expect machine don't change context status when queue not empty EXPECT_CALL(syncTaskContext, SetOperationStatus(_)).WillOnce(Return()); EXPECT_CALL(syncTaskContext, SetTaskExecStatus(_)).WillOnce(Return()); EXPECT_CALL(syncTaskContext, Clear()).WillOnce(Return()); @@ -488,7 +488,7 @@ HWTEST_F(DistributedDBMockSyncModuleTest, AbilitySync003, TestSize.Level1) context->SetIsNeedResetAbilitySync(true); EXPECT_EQ(context->GetSyncStrategy(query).permitSync, true); /** - * @tc.steps: step3. set table is schema change now it dont permit sync + * @tc.steps: step3. set table is schema change now it don't permit sync */ context->SchemaChange(); EXPECT_EQ(context->GetSyncStrategy(query).permitSync, false); diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_multi_ver_p2p_sync_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_multi_ver_p2p_sync_test.cpp index 08ce2c0c640d9961a52017cafc421f98378a04e2..70d3ffbcd2af86d0aef10dfcec00985654e753de 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_multi_ver_p2p_sync_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_multi_ver_p2p_sync_test.cpp @@ -1503,7 +1503,7 @@ HWTEST_F(DistributedDBMultiVerP2PSyncTest, NetDisconnectSync001, TestSize.Level3 /** * @tc.name: SyncQueue006 - * @tc.desc: multi version not surport sync queue + * @tc.desc: multi version not support sync queue * @tc.type: FUNC * @tc.require: AR000D4876 * @tc.author: wangchuanqing diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_relational_ver_p2p_sync_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_relational_ver_p2p_sync_test.cpp index 37d41afcf67ee78e652152097c2613668edd7883..75a8193b3dde3c3c870c097d13599dc3e76e75a5 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_relational_ver_p2p_sync_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_relational_ver_p2p_sync_test.cpp @@ -935,7 +935,7 @@ HWTEST_F(DistributedDBRelationalVerP2PSyncTest, AutoLaunchSync003, TestSize.Leve g_mgr.CloseStore(g_rdbDelegatePtr); g_rdbDelegatePtr = nullptr; /** - * @tc.steps: step3. store cann't autoLaunch because callback is nullptr + * @tc.steps: step3. store can't autoLaunch because callback is nullptr */ LabelType labelType(g_id.begin(), g_id.end()); g_communicatorAggregator->RunCommunicatorLackCallback(labelType); diff --git a/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_kv_backup_test.cpp b/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_kv_backup_test.cpp index a92b7d9feaa24c30decaabf1eb65106023b51b04..b168cdb5d8b4dcee15a7e05fa38725cfafe9be47 100644 --- a/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_kv_backup_test.cpp +++ b/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_kv_backup_test.cpp @@ -206,7 +206,7 @@ HWTEST_F(DistributeddbKvBackupTest, ExportTest003, TestSize.Level3) DBStatus status = g_kvBackupDelegate->Export(filePath, NULL_PASSWD); /** - * @tc.steps: step2. start thread to commit transaction and check the number od files in the exportion directory. + * @tc.steps: step2. start thread to commit transaction and check the number of files in the exportion directory. * @tc.expected: step2. commit successfully and the number of files is 1. */ bool exportFlag = false; @@ -235,7 +235,7 @@ HWTEST_F(DistributeddbKvBackupTest, ExportTest003, TestSize.Level3) filePath = exportPath + "/bkpDB2.bin"; /** - * @tc.steps: step3. start thread to rollback transaction and check the number od files in the exportion directory. + * @tc.steps: step3. start thread to rollback transaction and check the number of files in the exportion directory. * @tc.expected: step3. rollback successfully and the number of files is 2. */ thread subThread2([&]() { diff --git a/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_nb_db_damage_test.cpp b/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_nb_db_damage_test.cpp index d3e1ddefabe47ddff9d1a77dd97625d8da19ef71..fbb3cfdd8a75a560030f2998ce8c80b19c042320 100644 --- a/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_nb_db_damage_test.cpp +++ b/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_nb_db_damage_test.cpp @@ -61,7 +61,7 @@ void DistributedbNbDbDamageTest::TearDown(void) /* * @tc.name: DbDamageRecover 001 - * @tc.desc: Verify that set isNeedIntegrityCheck and isNeedRmCorruptedDb when open db, if open failed the calback will + * @tc.desc: Verify that set isNeedIntegrityCheck and isNeedRmCorruptedDb when open db, if open failed the callback will * be triggered when has register corruption callback. * @tc.type: FUNC * @tc.require: SR000D4878