diff --git a/services/distributeddataservice/libs/distributeddb/common/include/db_ability.h b/services/distributeddataservice/libs/distributeddb/common/include/db_ability.h index 16c5abcb58d30d6768c4420a684ffc8a8b0e9290..a1bb45eb93f2c2d4158c09e87318aa23168887ac 100644 --- a/services/distributeddataservice/libs/distributeddb/common/include/db_ability.h +++ b/services/distributeddataservice/libs/distributeddb/common/include/db_ability.h @@ -29,7 +29,7 @@ public: DbAbility(); DbAbility(const DbAbility &other); DbAbility& operator=(const DbAbility &other); - ~DbAbility() {}; + ~DbAbility() = default; bool operator==(const DbAbility &other) const; // translate dbAbility_ to std::vector diff --git a/services/distributeddataservice/libs/distributeddb/common/include/log_print.h b/services/distributeddataservice/libs/distributeddb/common/include/log_print.h index 8cdffe88bef7ced1398f71ade2a0006800bb5399..697a2986cbc931d3445469b54ddc53cd746ae8de 100644 --- a/services/distributeddataservice/libs/distributeddb/common/include/log_print.h +++ b/services/distributeddataservice/libs/distributeddb/common/include/log_print.h @@ -16,6 +16,8 @@ #ifndef DISTRIBUTEDDB_LOG_PRINT_H #define DISTRIBUTEDDB_LOG_PRINT_H +#define __STDC_FORMAT_MACROS +#include #include #include #include diff --git a/services/distributeddataservice/libs/distributeddb/common/include/macro_utils.h b/services/distributeddataservice/libs/distributeddb/common/include/macro_utils.h index dc36c2faaa43d3d76af5b89c06c06a34580a7a04..ec2ccd61cb4d90ce479cd0c2b9dd06203568b9b7 100644 --- a/services/distributeddataservice/libs/distributeddb/common/include/macro_utils.h +++ b/services/distributeddataservice/libs/distributeddb/common/include/macro_utils.h @@ -24,7 +24,7 @@ namespace DistributedDB { ClassName& operator=(ClassName &&) = delete #define DECLARE_OBJECT_TAG(ClassName) \ - virtual std::string GetObjectTag() const override; \ + std::string GetObjectTag() const override; \ constexpr static const char * const classTag = "Class-"#ClassName #define DEFINE_OBJECT_TAG_FACILITIES(ClassName) \ diff --git a/services/distributeddataservice/libs/distributeddb/common/include/schema_object.h b/services/distributeddataservice/libs/distributeddb/common/include/schema_object.h index b788def45e1a3aa46eaeff1a60da3a2a3d6dfc45..2cf9091a6783a115cf4476fe7a75e680156a38ef 100644 --- a/services/distributeddataservice/libs/distributeddb/common/include/schema_object.h +++ b/services/distributeddataservice/libs/distributeddb/common/include/schema_object.h @@ -51,7 +51,7 @@ public: SchemaObject(const SchemaObject &); SchemaObject& operator=(const SchemaObject &); #ifdef RELATIONAL_STORE - SchemaObject(const TableInfo &tableInfo); // The construct func can only be used for query. + explicit SchemaObject(const TableInfo &tableInfo); // The construct func can only be used for query. #endif // RELATIONAL_STORE // Move constructor and move assignment is not need currently @@ -145,7 +145,7 @@ private: // Choose inner-class other than friend-class to avoid forward declaration and using pointer. class FlatBufferSchema { public: - FlatBufferSchema(SchemaObject &owner) : owner_(owner) {}; + explicit FlatBufferSchema(SchemaObject &owner) : owner_(owner) {}; ~FlatBufferSchema() = default; DISABLE_COPY_ASSIGN_MOVE(FlatBufferSchema); // Copy-Constructor can not define due to Const-Ref member. Code standard require copy assignment be deleted. diff --git a/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp b/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp index 3ad52cb035df49fea16e5cb362dab5d4b1ac0a47..6085a9d98f72a4c0ccc5248d1e97b33497e9dce8 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp @@ -179,7 +179,7 @@ int AutoLaunch::EnableKvStoreAutoLaunch(const KvDBProperties &properties, AutoLa if (isDualTupleMode && !RuntimeContext::GetInstance()->IsSyncerNeedActive(userId, appId, storeId)) { std::lock_guard autoLock(dataLock_); std::string tmpIdentifier = isDualTupleMode ? dualTupleIdentifier : identifier; - LOGI("[AutoLaunch] GetDoOpenMap identifier=%0.6s no need to open", STR_TO_HEX(tmpIdentifier)); + LOGI("[AutoLaunch] GetDoOpenMap identifier=%.6s no need to open", STR_TO_HEX(tmpIdentifier)); autoLaunchItemMap_[tmpIdentifier][userId].state = AutoLaunchItemState::IDLE; return errCode; } @@ -285,7 +285,7 @@ void AutoLaunch::TryCloseConnection(AutoLaunchItem &autoLaunchItem) TryCloseRelationConnection(autoLaunchItem); break; default: - LOGD("[AutoLaunch] Unknown type[%d] when try to close connection", autoLaunchItem.type); + LOGD("[AutoLaunch] Unknown type[%d] when try to close connection", static_cast(autoLaunchItem.type)); break; } } @@ -321,7 +321,7 @@ int AutoLaunch::RegisterObserver(AutoLaunchItem &autoLaunchItem, const std::stri LOGE("[AutoLaunch] autoLaunchItem.conn is nullptr"); return -E_INTERNAL_ERROR; } - LOGI("[AutoLaunch] RegisterObserver type=%d", autoLaunchItem.type); + LOGI("[AutoLaunch] RegisterObserver type=%d", static_cast(autoLaunchItem.type)); if (autoLaunchItem.type == DBType::DB_RELATION) { RelationalStoreConnection *conn = static_cast(autoLaunchItem.conn); conn->RegisterObserverAction([autoLaunchItem](const std::string &changedDevice) { @@ -366,7 +366,7 @@ int AutoLaunch::RegisterObserver(AutoLaunchItem &autoLaunchItem, const std::stri void AutoLaunch::ObserverFunc(const KvDBCommitNotifyData ¬ifyData, const std::string &identifier, const std::string &userId) { - LOGD("[AutoLaunch] ObserverFunc identifier=%0.6s", STR_TO_HEX(identifier)); + LOGD("[AutoLaunch] ObserverFunc identifier=%.6s", STR_TO_HEX(identifier)); AutoLaunchItem autoLaunchItem; std::string appId; std::string storeId; @@ -420,7 +420,7 @@ int AutoLaunch::DisableKvStoreAutoLaunch(const std::string &normalIdentifier, co const std::string &userId) { std::string identifier = (autoLaunchItemMap_.count(normalIdentifier) == 0) ? dualTupleIdentifier : normalIdentifier; - LOGI("[AutoLaunch] DisableKvStoreAutoLaunch identifier=%0.6s", STR_TO_HEX(identifier)); + LOGI("[AutoLaunch] DisableKvStoreAutoLaunch identifier=%.6s", STR_TO_HEX(identifier)); AutoLaunchItem autoLaunchItem; { std::unique_lock autoLock(dataLock_); @@ -499,7 +499,7 @@ void AutoLaunch::CloseNotifier(const AutoLaunchItem &autoLaunchItem) void AutoLaunch::ConnectionLifeCycleCallbackTask(const std::string &identifier, const std::string &userId) { - LOGI("[AutoLaunch] ConnectionLifeCycleCallbackTask identifier=%0.6s", STR_TO_HEX(identifier)); + LOGI("[AutoLaunch] ConnectionLifeCycleCallbackTask identifier=%.6s", STR_TO_HEX(identifier)); AutoLaunchItem autoLaunchItem; { std::lock_guard autoLock(dataLock_); @@ -513,7 +513,7 @@ void AutoLaunch::ConnectionLifeCycleCallbackTask(const std::string &identifier, } if (autoLaunchItemMap_[identifier][userId].state != AutoLaunchItemState::IDLE) { LOGI("[AutoLaunch] ConnectionLifeCycleCallback state:%d is not idle, do nothing", - autoLaunchItemMap_[identifier][userId].state); + static_cast(autoLaunchItemMap_[identifier][userId].state)); return; } autoLaunchItemMap_[identifier][userId].state = AutoLaunchItemState::IN_LIFE_CYCLE_CALL_BACK; @@ -537,7 +537,7 @@ void AutoLaunch::ConnectionLifeCycleCallbackTask(const std::string &identifier, void AutoLaunch::ConnectionLifeCycleCallback(const std::string &identifier, const std::string &userId) { - LOGI("[AutoLaunch] ConnectionLifeCycleCallback identifier=%0.6s", STR_TO_HEX(identifier)); + LOGI("[AutoLaunch] ConnectionLifeCycleCallback identifier=%.6s", STR_TO_HEX(identifier)); int errCode = RuntimeContext::GetInstance()->ScheduleTask(std::bind(&AutoLaunch::ConnectionLifeCycleCallbackTask, this, identifier, userId)); if (errCode != E_OK) { @@ -601,7 +601,8 @@ void AutoLaunch::GetDoOpenMap(std::map(iter.second.state)); continue; } else if (iter.second.conn != nullptr) { LOGI("[AutoLaunch] GetDoOpenMap this item is opened"); @@ -620,7 +621,7 @@ void AutoLaunch::GetDoOpenMap(std::map> &doOpenMap) { - LOGI("[AutoLaunch] GetConnInDoOpenMap doOpenMap.size():%llu", doOpenMap.size()); + LOGI("[AutoLaunch] GetConnInDoOpenMap doOpenMap.size():%zu", doOpenMap.size()); if (doOpenMap.empty()) { return; } @@ -681,7 +682,7 @@ void AutoLaunch::UpdateGlobalMap(std::map autoLock(dataLock_); @@ -731,7 +732,7 @@ int AutoLaunch::ReceiveUnknownIdentifierCallBack(const LabelType &label, const s // normal tuple mode userId = autoLaunchItemMap_[identifier].begin()->first; } - LOGI("[AutoLaunch] ReceiveUnknownIdentifierCallBack identifier=%0.6s", STR_TO_HEX(identifier)); + LOGI("[AutoLaunch] ReceiveUnknownIdentifierCallBack identifier=%.6s", STR_TO_HEX(identifier)); int errCode; { std::lock_guard autoLock(dataLock_); @@ -746,7 +747,7 @@ int AutoLaunch::ReceiveUnknownIdentifierCallBack(const LabelType &label, const s return E_OK; } else if (autoLaunchItemMap_[identifier][userId].state != AutoLaunchItemState::IDLE) { LOGI("[AutoLaunch] ReceiveUnknownIdentifierCallBack state:%d is not idle, do nothing", - autoLaunchItemMap_[identifier][userId].state); + static_cast(autoLaunchItemMap_[identifier][userId].state)); return E_OK; } autoLaunchItemMap_[identifier][userId].state = AutoLaunchItemState::IN_COMMUNICATOR_CALL_BACK; @@ -768,7 +769,7 @@ EXT: void AutoLaunch::SetAutoLaunchRequestCallback(const AutoLaunchRequestCallback &callback, DBType type) { - LOGI("[AutoLaunch] SetAutoLaunchRequestCallback type[%d]", type); + LOGI("[AutoLaunch] SetAutoLaunchRequestCallback type[%d]", static_cast(type)); std::lock_guard lock(extLock_); if (callback) { autoLaunchRequestCallbackMap_[type] = callback; @@ -865,7 +866,7 @@ void AutoLaunch::AutoLaunchExtTask(const std::string identifier, const std::stri void AutoLaunch::ExtObserverFunc(const KvDBCommitNotifyData ¬ifyData, const std::string &identifier, const std::string &userId) { - LOGD("[AutoLaunch] ExtObserverFunc identifier=%0.6s", STR_TO_HEX(identifier)); + LOGD("[AutoLaunch] ExtObserverFunc identifier=%.6s", STR_TO_HEX(identifier)); AutoLaunchItem autoLaunchItem; AutoLaunchNotifier notifier; { @@ -907,7 +908,7 @@ void AutoLaunch::ExtObserverFunc(const KvDBCommitNotifyData ¬ifyData, const s void AutoLaunch::ExtConnectionLifeCycleCallback(const std::string &identifier, const std::string &userId) { - LOGI("[AutoLaunch] ExtConnectionLifeCycleCallback identifier=%0.6s", STR_TO_HEX(identifier)); + LOGI("[AutoLaunch] ExtConnectionLifeCycleCallback identifier=%.6s", STR_TO_HEX(identifier)); int errCode = RuntimeContext::GetInstance()->ScheduleTask(std::bind( &AutoLaunch::ExtConnectionLifeCycleCallbackTask, this, identifier, userId)); if (errCode != E_OK) { @@ -917,7 +918,7 @@ void AutoLaunch::ExtConnectionLifeCycleCallback(const std::string &identifier, c void AutoLaunch::ExtConnectionLifeCycleCallbackTask(const std::string &identifier, const std::string &userId) { - LOGI("[AutoLaunch] ExtConnectionLifeCycleCallbackTask identifier=%0.6s", STR_TO_HEX(identifier)); + LOGI("[AutoLaunch] ExtConnectionLifeCycleCallbackTask identifier=%.6s", STR_TO_HEX(identifier)); AutoLaunchItem autoLaunchItem; { std::lock_guard autoLock(extLock_); @@ -941,7 +942,7 @@ void AutoLaunch::ExtConnectionLifeCycleCallbackTask(const std::string &identifie int AutoLaunch::SetConflictNotifier(AutoLaunchItem &autoLaunchItem) { if (autoLaunchItem.type != DBType::DB_KV) { - LOGD("[AutoLaunch] Current Type[%d] Not Support ConflictNotifier Now", autoLaunchItem.type); + LOGD("[AutoLaunch] Current Type[%d] Not Support ConflictNotifier Now", static_cast(autoLaunchItem.type)); return E_OK; } @@ -1131,7 +1132,7 @@ int AutoLaunch::RegisterLifeCycleCallback(AutoLaunchItem &autoLaunchItem, const static_cast(autoLaunchItem.conn)->RegisterLifeCycleCallback(notifier); break; default: - LOGD("[AutoLaunch] Unknown Type[%d]", autoLaunchItem.type); + LOGD("[AutoLaunch] Unknown Type[%d]", static_cast(autoLaunchItem.type)); break; } return errCode; @@ -1141,7 +1142,7 @@ int AutoLaunch::PragmaAutoSync(AutoLaunchItem &autoLaunchItem) { int errCode = E_OK; if (autoLaunchItem.type != DBType::DB_KV) { - LOGD("[AutoLaunch] Current Type[%d] Not Support AutoSync Now", autoLaunchItem.type); + LOGD("[AutoLaunch] Current Type[%d] Not Support AutoSync Now", static_cast(autoLaunchItem.type)); return errCode; } diff --git a/services/distributeddataservice/libs/distributeddb/common/src/db_ability.cpp b/services/distributeddataservice/libs/distributeddb/common/src/db_ability.cpp index 87d0ca7eb8fa63e520e67b2ebf1c0374d4449d54..54631a3ccd31875232e5acc2fe97fb17379d9390 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/db_ability.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/db_ability.cpp @@ -131,8 +131,8 @@ uint8_t DbAbility::GetAbilityItem(const AbilityItem &abilityType) const auto iter = dbAbilityItemSet_.find(abilityType); if (iter != dbAbilityItemSet_.end()) { if ((iter->first + iter->second) > dbAbility_.size()) { - LOGE("[DbAbility] abilityType is error, start=%d, use_bit=%d, totalLen=%d", iter->first, iter->second, - dbAbility_.size()); + LOGE("[DbAbility] abilityType is error, start=%" PRIu32 ", use_bit=%" PRIu32 ", totalLen=%zu", + iter->first, iter->second, dbAbility_.size()); return 0; } uint32_t skip = 0; diff --git a/services/distributeddataservice/libs/distributeddb/common/src/parcel.cpp b/services/distributeddataservice/libs/distributeddb/common/src/parcel.cpp index 9fedced192aff4ada04bc59973dad594e882781b..d7eb4d9eefd822c3abeabcbd7d3d89d65baf16b5 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/parcel.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/parcel.cpp @@ -164,13 +164,15 @@ int Parcel::WriteString(const std::string &inVal) uint64_t stepLen = sizeof(uint32_t) + static_cast(inVal.size()); len = HostToNet(len); if (stepLen > INT32_MAX || parcelLen_ + BYTE_8_ALIGN(stepLen) > totalLen_) { - LOGE("[WriteString] stepLen:%llu, totalLen:%llu, parcelLen:%llu", stepLen, totalLen_, parcelLen_); + LOGE("[WriteString] stepLen:%" PRIu64 ", totalLen:%" PRIu64 ", parcelLen:%" PRIu64 , stepLen, totalLen_, + parcelLen_); isError_ = true; return -E_PARSE_FAIL; } errno_t errCode = memcpy_s(bufPtr_, totalLen_ - parcelLen_, &len, sizeof(uint32_t)); if (errCode != EOK) { - LOGE("[WriteString] bufPtr:%d, totalLen:%llu, parcelLen:%llu", bufPtr_ != nullptr, totalLen_, parcelLen_); + LOGE("[WriteString] bufPtr:%d, totalLen:%" PRIu64 ", parcelLen:%" PRIu64 , bufPtr_ != nullptr, totalLen_, + parcelLen_); isError_ = true; return -E_SECUREC_ERROR; } @@ -182,7 +184,7 @@ int Parcel::WriteString(const std::string &inVal) } errCode = memcpy_s(bufPtr_, totalLen_ - parcelLen_ - sizeof(uint32_t), inVal.c_str(), inVal.size()); if (errCode != EOK) { - LOGE("[WriteString] totalLen:%llu, parcelLen:%llu, inVal.size:%zu.", + LOGE("[WriteString] totalLen:%" PRIu64 ", parcelLen:%" PRIu64 ", inVal.size:%zu.", totalLen_, parcelLen_, inVal.size()); isError_ = true; return -E_SECUREC_ERROR; @@ -199,7 +201,8 @@ uint32_t Parcel::ReadString(std::string &outVal) return 0; } if (bufPtr_ == nullptr || parcelLen_ + sizeof(uint32_t) > totalLen_) { - LOGE("[ReadString] bufPtr:%d, totalLen:%llu, parcelLen:%llu", bufPtr_ != nullptr, totalLen_, parcelLen_); + LOGE("[ReadString] bufPtr:%d, totalLen:%" PRIu64 ", parcelLen:%" PRIu64, bufPtr_ != nullptr, totalLen_, + parcelLen_); isError_ = true; return 0; } @@ -207,7 +210,8 @@ uint32_t Parcel::ReadString(std::string &outVal) len = NetToHost(len); uint64_t stepLen = static_cast(len) + sizeof(uint32_t); if (stepLen > INT32_MAX || parcelLen_ + BYTE_8_ALIGN(stepLen) > totalLen_) { - LOGE("[ReadString] stepLen:%llu, totalLen:%llu, parcelLen:%llu", stepLen, totalLen_, parcelLen_); + LOGE("[ReadString] stepLen:%" PRIu64 ", totalLen:%" PRIu64 ", parcelLen:%" PRIu64, stepLen, totalLen_, + parcelLen_); isError_ = true; return 0; } @@ -344,7 +348,7 @@ uint32_t Parcel::ReadMultiVerCommits(std::vector &commits) } if (size > DBConstant::MAX_COMMIT_SIZE) { isError_ = true; - LOGE("Parcel::ReadMultiVerCommits commits size too large: %llu", size); + LOGE("Parcel::ReadMultiVerCommits commits size too large: %" PRIu64, size); return 0; } for (uint64_t i = 0; i < size; i++) { @@ -381,7 +385,7 @@ int Parcel::WriteBlob(const char *buffer, uint32_t bufLen) return -E_PARSE_FAIL; } if (parcelLen_ + bufLen > totalLen_) { - LOGE("[WriteBlob] bufLen:%u, totalLen:%llu, parcelLen:%llu", bufLen, totalLen_, parcelLen_); + LOGE("[WriteBlob] bufLen:%" PRIu32 ", totalLen:%" PRIu64 ", parcelLen:%" PRIu64, bufLen, totalLen_, parcelLen_); isError_ = true; return -E_PARSE_FAIL; } @@ -409,7 +413,7 @@ uint32_t Parcel::ReadBlob(char *buffer, uint32_t bufLen) } uint32_t leftLen = static_cast(totalLen_ - parcelLen_); if (parcelLen_ + bufLen > totalLen_) { - LOGE("[ReadBlob] bufLen:%u, totalLen:%llu, parcelLen:%llu", bufLen, totalLen_, parcelLen_); + LOGE("[ReadBlob] bufLen:%" PRIu32 ", totalLen:%" PRIu64 ", parcelLen:%" PRIu64, bufLen, totalLen_, parcelLen_); isError_ = true; return 0; } diff --git a/services/distributeddataservice/libs/distributeddb/common/src/relational/relational_schema_object.cpp b/services/distributeddataservice/libs/distributeddb/common/src/relational/relational_schema_object.cpp index c087a3a537f1972d13e2b05651030ac3d3a1ff62..3642c7fb28ece5a47c5f76620ebf8e6b138f8294 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/relational/relational_schema_object.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/relational/relational_schema_object.cpp @@ -510,7 +510,8 @@ int GetMemberFromJsonObject(const JsonObject &inJsonObject, const std::string &f } if (fieldType != expectType) { - LOGE("[RelationalSchema][Parse] Expect %s fieldType %d but: %d.", fieldName.c_str(), expectType, fieldType); + LOGE("[RelationalSchema][Parse] Expect %s fieldType %d but: %d.", fieldName.c_str(), + static_cast(expectType), static_cast(fieldType)); return -E_SCHEMA_PARSE_FAIL; } diff --git a/services/distributeddataservice/libs/distributeddb/common/src/schema_object.cpp b/services/distributeddataservice/libs/distributeddb/common/src/schema_object.cpp index 07565295a5f1d193b3640b54492843cd99c0ae47..e8bb982d6168011786fcee723e06e03bb618efa3 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/schema_object.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/schema_object.cpp @@ -323,7 +323,7 @@ int SchemaObject::VerifyValue(ValueSource sourceType, const RawValue &inValue) c return -E_NOT_PERMIT; } if (inValue.second <= schemaSkipSize_) { - LOGE("[Schema][Verify] Value length=%zu invalid, skipsize=%u.", inValue.second, schemaSkipSize_); + LOGE("[Schema][Verify] Value length=%" PRIu32 " invalid, skipsize=%" PRIu32, inValue.second, schemaSkipSize_); return -E_FLATBUFFER_VERIFY_FAIL; } @@ -442,8 +442,8 @@ int CheckOptionalMetaFieldCountAndType(const std::map &met } if (metaFieldPathType.size() != (SchemaConstant::SCHEMA_META_FEILD_COUNT_MIN + indexMetaFieldCount + skipSizeMetaFieldCount)) { - LOGE("[Schema][CheckMeta] Unrecognized metaField exist: total=%u, indexField=%u, skipSizeField=%u.", - metaFieldPathType.size(), indexMetaFieldCount, skipSizeMetaFieldCount); + LOGE("[Schema][CheckMeta] Unrecognized metaField exist: total=%zu, indexField=%" PRIu32 ", skipSizeField=%" + PRIu32, metaFieldPathType.size(), indexMetaFieldCount, skipSizeMetaFieldCount); return -E_SCHEMA_PARSE_FAIL; } return E_OK; @@ -791,14 +791,14 @@ int SchemaObject::CompareSchemaDefine(const SchemaObject &newSchema) const } // No matter strict or compatible mode, newSchema can't have less field than oldSchema if (defineInNewSchema.size() < defineInOldSchema.size()) { - LOGE("[Schema][CompareDefine] newSize=%u less than oldSize=%u at depth=%u.", defineInNewSchema.size(), - defineInOldSchema.size(), depth); + LOGE("[Schema][CompareDefine] newSize=%zu less than oldSize=%zu at depth=%" PRIu32, + defineInNewSchema.size(), defineInOldSchema.size(), depth); return -E_SCHEMA_UNEQUAL_INCOMPATIBLE; } if (defineInNewSchema.size() > defineInOldSchema.size()) { // Strict mode not support increase fieldDefine if (schemaMode_ == SchemaMode::STRICT) { - LOGE("[Schema][CompareDefine] newSize=%u more than oldSize=%u at depth=%u in STRICT mode.", + LOGE("[Schema][CompareDefine] newSize=%zu more than oldSize=%zu at depth=%" PRIu32 " in STRICT mode.", defineInNewSchema.size(), defineInOldSchema.size(), depth); return -E_SCHEMA_UNEQUAL_INCOMPATIBLE; } @@ -916,8 +916,8 @@ int SchemaObject::CompareSchemaDefaultValue(const SchemaAttribute &oldAttr, cons } } else if (oldAttr.type == FieldType::LEAF_FIELD_LONG) { if (oldAttr.defaultValue.longValue != newAttr.defaultValue.longValue) { - LOGE("[Schema][CompareDefault] OldDefault=%lld mismatch newDefault=%lld.", oldAttr.defaultValue.longValue, - newAttr.defaultValue.longValue); + LOGE("[Schema][CompareDefault] OldDefault=%" PRId64 " mismatch newDefault=%" PRId64 ".", + oldAttr.defaultValue.longValue, newAttr.defaultValue.longValue); return -E_SCHEMA_UNEQUAL_INCOMPATIBLE; } } else if (oldAttr.type == FieldType::LEAF_FIELD_DOUBLE) { diff --git a/services/distributeddataservice/libs/distributeddb/common/src/schema_utils.cpp b/services/distributeddataservice/libs/distributeddb/common/src/schema_utils.cpp index 802d9f6ade2152111591aed5d563c6371d17ce34..cb6fbb42de6e88d914c9125fd3c41e18dda15152 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/schema_utils.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/schema_utils.cpp @@ -269,7 +269,7 @@ int SchemaUtils::TransformDefaultValue(std::string &defaultContent, SchemaAttrib break; } - LOGD("SchemaAttribute type is [%d], transfer result is [%d]", outAttr.type, errCode); + LOGD("SchemaAttribute type is [%d], transfer result is [%d]", static_cast(outAttr.type), errCode); return errCode; } diff --git a/services/distributeddataservice/libs/distributeddb/common/src/value_object.cpp b/services/distributeddataservice/libs/distributeddb/common/src/value_object.cpp index def2c810b6a7b3167385ebc12c7d6740084d0fa3..9a91eec91297bec7ce08d0dd0ccc5e5fbee741be 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/value_object.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/value_object.cpp @@ -61,7 +61,7 @@ int ValueObject::Parse(const uint8_t *dataBegin, const uint8_t *dataEnd, uint32_ return -E_NOT_PERMIT; } if (dataBegin == nullptr || dataBegin >= dataEnd || offset >= static_cast(dataEnd - dataBegin)) { - LOGE("[Value][Parse] Data range invalid: dataEnd - dataBegin=%lld, offset=%u", + LOGE("[Value][Parse] Data range invalid: dataEnd - dataBegin=%" PRId64 ", offset=%" PRIu32, static_cast(dataEnd - dataBegin), offset); return -E_INVALID_ARGS; } diff --git a/services/distributeddataservice/libs/distributeddb/common/src/zlib_compression.cpp b/services/distributeddataservice/libs/distributeddb/common/src/zlib_compression.cpp index aeef6b3eafc44a182b028eb8f270fb82281d8230..045fc6d2d7f21a0b45268c9832a3f0d0ad34a322 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/zlib_compression.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/zlib_compression.cpp @@ -35,7 +35,7 @@ int ZlibCompression::Compress(const std::vector &srcData, std::vector DBConstant::MAX_SYNC_BLOCK_SIZE || destLen > DBConstant::MAX_SYNC_BLOCK_SIZE) { - LOGE("Too long to compress, srcLen:%u, destLen:%u.", srcLen, destLen); + LOGE("Too long to compress, srcLen:%zu, destLen:%lu.", srcLen, destLen); return -E_INVALID_ARGS; } @@ -59,7 +59,7 @@ int ZlibCompression::Uncompress(const std::vector &srcData, std::vector { auto srcLen = srcData.size(); if (srcLen > DBConstant::MAX_SYNC_BLOCK_SIZE || destLen > DBConstant::MAX_SYNC_BLOCK_SIZE) { - LOGE("Too long to uncompress, srcLen:%u, destLen:%u.", srcLen, destLen); + LOGE("Too long to uncompress, srcLen:%zu, destLen:%lu.", srcLen, destLen); return -E_INVALID_ARGS; } diff --git a/services/distributeddataservice/libs/distributeddb/communicator/include/message.h b/services/distributeddataservice/libs/distributeddb/communicator/include/message.h index 7c99c9def64ebb9a69c1eb99a2a91127c2ee3ff8..416e083169cfcdc97e4f464f378ee21e9820d6af 100644 --- a/services/distributeddataservice/libs/distributeddb/communicator/include/message.h +++ b/services/distributeddataservice/libs/distributeddb/communicator/include/message.h @@ -39,7 +39,7 @@ class Message { public: Message() = default; - Message(uint32_t inMsgId) + explicit Message(uint32_t inMsgId) { messageId_ = inMsgId; } diff --git a/services/distributeddataservice/libs/distributeddb/communicator/include/network_adapter.h b/services/distributeddataservice/libs/distributeddb/communicator/include/network_adapter.h index 620814acb02c9c17d7ef4f4ea09cc8a00696014e..580e48c0deacd6ce296b702f60b5ff6a83bca80b 100644 --- a/services/distributeddataservice/libs/distributeddb/communicator/include/network_adapter.h +++ b/services/distributeddataservice/libs/distributeddb/communicator/include/network_adapter.h @@ -29,7 +29,7 @@ namespace DistributedDB { class NetworkAdapter : public IAdapter { public: NetworkAdapter(); - NetworkAdapter(const std::string &inProcessLabel); + explicit NetworkAdapter(const std::string &inProcessLabel); NetworkAdapter(const std::string &inProcessLabel, const std::shared_ptr &inCommunicator); ~NetworkAdapter() override; diff --git a/services/distributeddataservice/libs/distributeddb/communicator/include/object_holder_typed.h b/services/distributeddataservice/libs/distributeddb/communicator/include/object_holder_typed.h index abb8dad9c0aa0f15fabdf3424b7bea1b5975e55a..4156e3dc7b95b73db9cccd7cb5fde8167083b0bb 100644 --- a/services/distributeddataservice/libs/distributeddb/communicator/include/object_holder_typed.h +++ b/services/distributeddataservice/libs/distributeddb/communicator/include/object_holder_typed.h @@ -23,7 +23,7 @@ template class ObjectHolderTyped : public ObjectHolder { public: // Accept a heap object - ObjectHolderTyped(T *inObject) + explicit ObjectHolderTyped(T *inObject) { objectPtr_ = inObject; } diff --git a/services/distributeddataservice/libs/distributeddb/communicator/src/communicator.cpp b/services/distributeddataservice/libs/distributeddb/communicator/src/communicator.cpp index 0a2161a96a4f5bcb3de386fc9b517cc4478875f7..4478696e4c86f9bbbed8f0361480824e946445c8 100644 --- a/services/distributeddataservice/libs/distributeddb/communicator/src/communicator.cpp +++ b/services/distributeddataservice/libs/distributeddb/communicator/src/communicator.cpp @@ -103,7 +103,7 @@ int Communicator::SendMessage(const std::string &dstTarget, const Message *inMsg int Communicator::SendMessage(const std::string &dstTarget, const Message *inMsg, SendConfig &config, const OnSendEnd &onEnd) { - if (dstTarget.size() == 0 || inMsg == nullptr) { + if (dstTarget.empty() || inMsg == nullptr) { return -E_INVALID_ARGS; } std::shared_ptr extendHandle = nullptr; diff --git a/services/distributeddataservice/libs/distributeddb/communicator/src/frame_combiner.cpp b/services/distributeddataservice/libs/distributeddb/communicator/src/frame_combiner.cpp index 44a7c8ab48396b9d52251afbea276ac3e5bfd3eb..bbca2164878b6ae8c06f9edef4b61cfce7d02bda 100644 --- a/services/distributeddataservice/libs/distributeddb/communicator/src/frame_combiner.cpp +++ b/services/distributeddataservice/libs/distributeddb/communicator/src/frame_combiner.cpp @@ -129,7 +129,7 @@ int FrameCombiner::ContinueExistCombineWork(const uint8_t *bytes, uint32_t lengt uint32_t frameId = inPacketInfo.GetFrameId(); CombineWork &oriWork = combineWorkPool_[sourceId][frameId]; // Be care here must be reference if (!CheckPacketWithOriWork(inPacketInfo, oriWork)) { - LOGE("[Combiner][ContinueWork] Check packet fail, sourceId=%llu, frameId=%u.", ULL(sourceId), ULL(frameId)); + LOGE("[Combiner][ContinueWork] Check packet fail, sourceId=%" PRIu64 ", frameId=%" PRIu32, sourceId, frameId); return -E_COMBINE_FAIL; } @@ -138,7 +138,7 @@ int FrameCombiner::ContinueExistCombineWork(const uint8_t *bytes, uint32_t lengt int errCode = ProtocolProto::CombinePacketIntoFrame(oriWork.buffer, bytes, length, fragOffset, fragLength); if (errCode != E_OK) { // We can consider abort this work, but here we choose not to affect it - LOGE("[Combiner][ContinueWork] Combine packet fail, sourceId=%llu, frameId=%u.", ULL(sourceId), ULL(frameId)); + LOGE("[Combiner][ContinueWork] Combine packet fail, sourceId=%" PRIu64 ", frameId=%" PRIu32, sourceId, frameId); return -E_COMBINE_FAIL; } diff --git a/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp b/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp index 93c7e14a9147a0092430a08f4081e2596ba4abd5..a31c2689b00f91d90f3f40f9c23318e24bc7bc86 100644 --- a/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp +++ b/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp @@ -51,7 +51,7 @@ void SetFrameType(uint8_t &inPacketType, FrameType inFrameType) } FrameType GetFrameType(uint8_t inPacketType) { - uint8_t frameType = ((inPacketType & 0xF0) >> 4); // Use 0x0F to get high 4 bits + uint8_t frameType = ((inPacketType & 0xF0) >> 4); // Use 0xF0 to get high 4 bits if (frameType >= static_cast(FrameType::INVALID_MAX_FRAME_TYPE)) { return FrameType::INVALID_MAX_FRAME_TYPE; } diff --git a/services/distributeddataservice/libs/distributeddb/include/query.h b/services/distributeddataservice/libs/distributeddb/include/query.h index 5480939c3007fa810773f19e7e042ff3919aa80a..2f01c676c05b1e9859b114fe1901a390aa871391 100644 --- a/services/distributeddataservice/libs/distributeddb/include/query.h +++ b/services/distributeddataservice/libs/distributeddb/include/query.h @@ -148,7 +148,7 @@ public: private: Query() = default; - Query(const std::string &tableName); + explicit Query(const std::string &tableName); DB_SYMBOL void ExecuteCompareOperation(QueryObjType operType, const std::string &field, const QueryValueType type, const FieldValue &fieldValue); diff --git a/services/distributeddataservice/libs/distributeddb/storage/include/kvdb_pragma.h b/services/distributeddataservice/libs/distributeddb/storage/include/kvdb_pragma.h index fca5abdfdc81286d3e59e72d3661bf51306c2f7c..649ae2c15a216ac2a6416dbf80c4629c14b1b482 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/include/kvdb_pragma.h +++ b/services/distributeddataservice/libs/distributeddb/storage/include/kvdb_pragma.h @@ -87,7 +87,7 @@ struct PragmaSync { }; struct PragmaRemotePushNotify { - PragmaRemotePushNotify(RemotePushFinishedNotifier notifier) : notifier_(notifier) {} + explicit PragmaRemotePushNotify(RemotePushFinishedNotifier notifier) : notifier_(notifier) {} RemotePushFinishedNotifier notifier_; }; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp index 3ca30a82bd73273b2e3f00424cf0594e38182659..22a8f3f352db463b48030163fef397de4c64d02c 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp @@ -204,7 +204,7 @@ std::map GetChangedIndexes(const TableInfo &oldTab itOld++; itNew++; } else if (itOld->first < itNew->first) { - indexes.insert({itOld->first,{}}); + indexes.insert({itOld->first, {}}); itOld++; } else if (itOld->first > itNew->first) { indexes.insert({itNew->first, itNew->second}); @@ -213,7 +213,7 @@ std::map GetChangedIndexes(const TableInfo &oldTab } while (itOld != itOldEnd) { - indexes.insert({itOld->first,{}}); + indexes.insert({itOld->first, {}}); itOld++; } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp index 8f5ac620a6e2802cb0545aaf3f53257a3d79f3d3..4b4821e9d784b34cc00a6bb687e5e042aa65c7ef 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp @@ -140,6 +140,7 @@ int SyncEngine::Close() if (inMsg != nullptr) { queueCacheSize_ -= GetMsgSize(inMsg); delete inMsg; + inMsg = nullptr; } } // close db, rekey or import scene, need clear all remote query info diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_auto_launch_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_auto_launch_test.cpp index dfd911c585c58bc3be411f41bb4a735679352992..e75c7cd63a8767028b04c2e050a29c80aeee9481 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_auto_launch_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_auto_launch_test.cpp @@ -175,7 +175,7 @@ static void PutSyncData(const KvDBProperties &prop, const Key &key, const Value TimeStamp time; kvStore->GetMaxTimeStamp(time); time += TIME_ADD; - LOGD("time:%lld", time); + LOGD("time:%" PRIu64, time); vect.push_back({key, value, time, 0, DBCommon::TransferHashString(REMOTE_DEVICE_ID)}); EXPECT_EQ(DistributedDBToolsUnitTest::PutSyncDataTest(kvStore, vect, REMOTE_DEVICE_ID), E_OK); } @@ -350,7 +350,7 @@ HWTEST_F(DistributedDBAutoLaunchUnitTest, AutoLaunch003, TestSize.Level3) std::string identifier = DBCommon::TransferHashString(userId + "-" + appId + "-" + storeId); std::unique_lock lock(cvMutex); statusMap[identifier] = status; - LOGD("int AutoLaunch002 notifier statusMap.size():%d", statusMap.size()); + LOGD("int AutoLaunch002 notifier statusMap.size():%zu", statusMap.size()); finished = true; cv.notify_one(); }; @@ -494,7 +494,7 @@ HWTEST_F(DistributedDBAutoLaunchUnitTest, AutoLaunch005, TestSize.Level3) std::string identifier = DBCommon::TransferHashString(userId + "-" + appId + "-" + storeId); std::unique_lock lock(cvMutex); statusMap[identifier] = status; - LOGD("int AutoLaunch002 notifier statusMap.size():%d", statusMap.size()); + LOGD("int AutoLaunch002 notifier statusMap.size():%zu", statusMap.size()); finished = true; cv.notify_one(); }; diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_relational_schema_object_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_relational_schema_object_test.cpp index d71962ed1b15305cc15c7420a15c201a0632eadc..2192f068889f03a470ca12c815a137eb2e0d9c31 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_relational_schema_object_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_relational_schema_object_test.cpp @@ -186,7 +186,7 @@ class DistributedDBRelationalSchemaObjectTest : public testing::Test { public: static void SetUpTestCase(void) {}; static void TearDownTestCase(void) {}; - void SetUp() override ; + void SetUp() override; void TearDown() override {}; }; diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_tools_unit_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_tools_unit_test.cpp index cb4d16398bf14aff6ad861a9e844a067e9bfa119..e3c5551a3b5cce585742a2348cab2522a5dacdf5 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_tools_unit_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/common/distributeddb_tools_unit_test.cpp @@ -372,13 +372,13 @@ bool DistributedDBToolsUnitTest::IsEntryEqual(const DistributedDB::Entry &entryO const DistributedDB::Entry &entryRet) { if (entryOrg.key != entryRet.key) { - LOGD("key not equal, entryOrg key size is [%d], entryRet key size is [%d]", entryOrg.key.size(), + LOGD("key not equal, entryOrg key size is [%zu], entryRet key size is [%zu]", entryOrg.key.size(), entryRet.key.size()); return false; } if (entryOrg.value != entryRet.value) { - LOGD("value not equal, entryOrg value size is [%d], entryRet value size is [%d]", entryOrg.value.size(), + LOGD("value not equal, entryOrg value size is [%zu], entryRet value size is [%zu]", entryOrg.value.size(), entryRet.value.size()); return false; } @@ -389,7 +389,7 @@ bool DistributedDBToolsUnitTest::IsEntryEqual(const DistributedDB::Entry &entryO bool DistributedDBToolsUnitTest::IsEntriesEqual(const std::vector &entriesOrg, const std::vector &entriesRet, bool needSort) { - LOGD("entriesOrg size is [%d], entriesRet size is [%d]", entriesOrg.size(), + LOGD("entriesOrg size is [%zu], entriesRet size is [%zu]", entriesOrg.size(), entriesRet.size()); if (entriesOrg.size() != entriesRet.size()) { @@ -405,11 +405,11 @@ bool DistributedDBToolsUnitTest::IsEntriesEqual(const std::vector &orgEntries, const std::list &resultLst) { - LOGD("orgEntries.size() is [%d], resultLst.size() is [%d]", orgEntries.size(), + LOGD("orgEntries.size() is [%zu], resultLst.size() is [%zu]", orgEntries.size(), resultLst.size()); if (orgEntries.size() != resultLst.size()) { @@ -537,7 +537,7 @@ int DistributedDBToolsUnitTest::ModifyDatabaseFile(const std::string &fileDir, u } else { fileSize = static_cast(pos); if (fileSize < 1024) { // the least page size is 1024 bytes. - LOGE("Invalid database file:%llu.", fileSize); + LOGE("Invalid database file:%" PRIu64 ".", fileSize); return -E_UNEXPECTED_DATA; } } @@ -674,7 +674,7 @@ void KvStoreObserverUnitTest::OnChange(const KvStoreChangedData& data) updated_ = data.GetEntriesUpdated(); deleted_ = data.GetEntriesDeleted(); isCleared_ = data.IsCleared(); - LOGD("Onchangedata :%lu -- %lu -- %lu -- %d", inserted_.size(), updated_.size(), deleted_.size(), isCleared_); + LOGD("Onchangedata :%zu -- %zu -- %zu -- %d", inserted_.size(), updated_.size(), deleted_.size(), isCleared_); LOGD("Onchange() called success!"); } diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/communicator/adapter_stub.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/communicator/adapter_stub.cpp index dbc76c0b0973e9fe4dc6fd63497e7907ad991c69..6304efdd2a15bfc24ba95e84584b4208a6c25ecb 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/communicator/adapter_stub.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/communicator/adapter_stub.cpp @@ -54,6 +54,7 @@ uint32_t AdapterStub::GetMtuSize() uint32_t AdapterStub::GetMtuSize(const std::string &target) { + (void)target; return GetMtuSize(); } @@ -64,7 +65,7 @@ uint32_t AdapterStub::GetTimeout() uint32_t AdapterStub::GetTimeout(const std::string &target) { - (void) target; + (void)target; return GetTimeout(); } @@ -129,7 +130,7 @@ int AdapterStub::RegSendableCallback(const SendableCallback &onSendable, const F bool AdapterStub::IsDeviceOnline(const std::string &device) { - (void) device; + (void)device; return true; } diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_relational_sync_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_relational_sync_test.cpp index 6ca71a9a47368e1bb886a928391e117277426770..dda185f9a7e35af85140ede62a7db65a37782d8e 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_relational_sync_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_relational_sync_test.cpp @@ -58,7 +58,7 @@ class DistributedDBInterfacesRelationalSyncTest : public testing::Test { public: static void SetUpTestCase(void); static void TearDownTestCase(void); - void SetUp() override ; + void SetUp() override; void TearDown() override; protected: sqlite3 *db = nullptr; 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 c2de7b7ee6b386a83ae77258f8ff1745115698a4..818c81babccff2b25d1da7a30e534630090d1149 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 @@ -270,7 +270,8 @@ HWTEST_F(DistributedDBInterfacesSpaceManagementTest, GetKvStoreDiskSize002, Test ASSERT_TRUE(dbSizeForCheck != singleAndMultiDbSize); dbSizeForCheck = CheckRealFileSize(g_singleVerFileNames) + CheckRealFileSize(GetMultiVerFilelist()); EXPECT_EQ(dbSizeForCheck, singleAndMultiDbSize); - LOGE("single:%lld,mul:%lld", CheckRealFileSize(g_singleVerFileNames), CheckRealFileSize(GetMultiVerFilelist())); + LOGE("single:%" PRIu64 ",mul:%" PRIu64, CheckRealFileSize(g_singleVerFileNames), + CheckRealFileSize(GetMultiVerFilelist())); /** * @tc.steps: step7. Close and Delete Db. diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_encrypt_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_encrypt_test.cpp index 8b3a0b7e456a03b29f222ffeb1d125df63112095..ca927e8b6c1794598bf321108c1205051e577fdc 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_encrypt_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_encrypt_test.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include "db_types.h" #include "log_print.h" diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.cpp index bdaf46efb1054bf9e778d47b8ab976deb7a16539..889ffe032384112f098c120888a77ee797d36bda 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.cpp @@ -1146,7 +1146,7 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::DeleteUserKeyValue003(SQ DataItem dataItem1; dataItem1.key = KV_ENTRY_1.key; dataItem1.value = KV_ENTRY_3.value; - dataItem1.timeStamp= timeStamp - 100UL; // less than current timeStamp + dataItem1.timeStamp = timeStamp - 100UL; // less than current timeStamp dataItem1.writeTimeStamp = dataItem1.timeStamp; dataItem1.flag = 0; diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_p2p_sync_check_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_p2p_sync_check_test.cpp index b869131ec418d2dee6669214b67707a032742d72..8e050440fc7bc855a783cec1f2b1a08954b12f76 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_p2p_sync_check_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_p2p_sync_check_test.cpp @@ -526,7 +526,7 @@ void RegOnDispatchWithOffline(bool &offlineFlag, bool &invalid, condition_variab offlineFlag = true; conditionOffline.notify_all(); LOGW("[Dispatch] NOTIFY OFFLINE"); - std::this_thread::sleep_for(std::chrono::microseconds (EIGHT_HUNDRED)); + std::this_thread::sleep_for(std::chrono::microseconds(EIGHT_HUNDRED)); } } else if (!invalid && inMsg->GetMessageType() == TYPE_REQUEST) { LOGW("[Dispatch] NOW INVALID THIS MSG"); @@ -1002,7 +1002,7 @@ HWTEST_F(DistributedDBSingleVerP2PSyncCheckTest, SyncMergeCheck005, TestSize.Lev * @tc.steps: step2. deviceA call sync and don't wait * @tc.expected: step2. sync should return TIME_OUT. */ - status =g_kvDelegatePtr->Sync(devices, SYNC_MODE_PUSH_ONLY, + status = g_kvDelegatePtr->Sync(devices, SYNC_MODE_PUSH_ONLY, [&sendRequestCount, devices, this](const std::map& statusMap) { ASSERT_TRUE(statusMap.size() == devices.size()); for (const auto &deviceId : devices) { diff --git a/services/distributeddataservice/test/common/distributeddb/include/distributed_rdb_tools.h b/services/distributeddataservice/test/common/distributeddb/include/distributed_rdb_tools.h index 45b007bd6118bc933d2ec58e2120822e66ac15a6..95b15b9d39e6e2044390ba3d6e9647687e8927fa 100644 --- a/services/distributeddataservice/test/common/distributeddb/include/distributed_rdb_tools.h +++ b/services/distributeddataservice/test/common/distributeddb/include/distributed_rdb_tools.h @@ -44,7 +44,7 @@ const static std::string NON_EXISTENT_PATH = "/data/test/nonExistent_rdb/"; const static std::string UNREADABLE_PATH = "/data/test/unreadable_rdb/"; const static std::string UNWRITABLE_PATH = "/data/test/unwritable_rdb/"; -const static std::string NULL_STOREID = ""; +const static std::string NULL_STOREID = {}; const static std::string ILLEGAL_STOREID = "rdb_$%#@~%"; const static std::string MODE_STOREID = "rdb_mode"; const static std::string FULL_STOREID = "rdb_full"; diff --git a/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_kv_create_test.cpp b/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_kv_create_test.cpp index c2ef56631733b89bd7b4dc8f141a7ece4a85d60a..68418f442946f89b6e5de2807f777513e6b4f51d 100644 --- a/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_kv_create_test.cpp +++ b/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_kv_create_test.cpp @@ -1939,7 +1939,7 @@ HWTEST_F(DistributeddbKvCreateTest, MergeRepeat001, TestSize.Level2) vector entriesBatch; vector allKeys; DistributedDB::Entry entry; - int putCount=0; + int putCount = 0; entry.value.assign(TWO_M_LONG_STRING, 'v'); GenerateTenThousandRecords(OPER_CNT_END, DEFAULT_START, allKeys, entriesBatch); for (vector::iterator iter = entriesBatch.begin(); iter != entriesBatch.end(); iter++) { diff --git a/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_nb_predicate_query_expand_test.cpp b/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_nb_predicate_query_expand_test.cpp index 8c39c277b2502ac407519706cbda5fb80ed85923..d5301b6e949b40e4ec9a98407784a32b42f626f9 100644 --- a/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_nb_predicate_query_expand_test.cpp +++ b/services/distributeddataservice/test/moduletest/common/distributeddb/src/distributeddb_nb_predicate_query_expand_test.cpp @@ -568,7 +568,7 @@ HWTEST_F(DistributeddbNbPredicateQueryExpandTest, NotNullTest003, TestSize.Level * and check the query use GetEntries(query, Entries), GetEntries(query, resultSet), GetCount(). * @tc.expected: step6. query success but the GetEntries will return INVALID_QUERY_FORMAT. */ - Query query5= Query::Select().IsNotNull(".field2.field3"); + Query query5 = Query::Select().IsNotNull(".field2.field3"); EXPECT_TRUE(DistributedDBSchemaTestTools::CombinationCheckQueryResult(*g_nbQueryDelegate, query5, entriesExpect, DBStatus::INVALID_QUERY_FORMAT, true)); }