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..0c164d3efb4d8e1d4c91ac3fc2317183d906d5e0 100644 --- a/services/distributeddataservice/libs/distributeddb/common/include/log_print.h +++ b/services/distributeddataservice/libs/distributeddb/common/include/log_print.h @@ -16,6 +16,7 @@ #ifndef DISTRIBUTEDDB_LOG_PRINT_H #define DISTRIBUTEDDB_LOG_PRINT_H +#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/data_compression.cpp b/services/distributeddataservice/libs/distributeddb/common/src/data_compression.cpp index 8465e9df45f17ddb7f7ad2f149e43983cd13ddfb..c0b221f062821856669d18cafdd8e6878dd4a09a 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/data_compression.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/data_compression.cpp @@ -24,7 +24,6 @@ void DataCompression::GetCompressionAlgo(std::set &algorithmS for (const auto &item : GetCompressionAlgos()) { algorithmSet.insert(item.first); } - return; } int DataCompression::TransferCompressionAlgo(uint32_t compressAlgoType, CompressAlgorithm &algoType) 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/evloop/src/event_impl.cpp b/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_impl.cpp index c33970d9b5283e40b8ba3e537a48904049915730..d4e44d7a1e3e0672b60c22441ef3f380b5e9d12c 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,20 +368,13 @@ int EventImpl::Dispatch() bool EventImpl::IsValidArg(EventsMask events) const { EventsMask allEvents = ET_READ | ET_WRITE | ET_ERROR | ET_TIMEOUT; - if (!events || (events & (~allEvents))) { - return false; - } - return true; + return events && !(events & (~allEvents)); } bool EventImpl::IsValidArg(EventTime timeout) const { - if ((timeout < 0) || (timeout > MAX_TIME_VALUE)) { - return false; - } - return true; + return (timeout >= 0) && (timeout <= MAX_TIME_VALUE); } DEFINE_OBJECT_TAG_FACILITIES(EventImpl) -} - +} // namespace DistributedDB diff --git a/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp b/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp index 826a65322f4306bc1be1fadc5f7ad1b0d0a9e3d4..bc920a86464796defbdc12b7a31d327ccca6f4a7 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp @@ -308,11 +308,7 @@ bool EventLoopImpl::IsInLoopThread(bool &started) const bool EventLoopImpl::EventObjectExists(EventImpl *event) const { - auto it = polling_.find(event); - if (it != polling_.end()) { - return true; - } - return false; + return polling_.find(event) != polling_.end(); } bool EventLoopImpl::EventFdExists(const EventImpl *event) const diff --git a/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp b/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp index a9ba7c3119ad0bccdd52c3abaa8e22e780990bb3..b26b382ff63fba84bd1e563d7bf5dc69791808cc 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_select.cpp @@ -82,6 +82,6 @@ int EventLoopSelect::ModifyEvent(EventImpl *event, bool isAdd, EventsMask events } DEFINE_OBJECT_TAG_FACILITIES(EventLoopSelect) -} +} // namespace DistributedDB -#endif +#endif // EVENT_LOOP_USE_SELECT diff --git a/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_select.h b/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_select.h index 79a6fbdd6c36c4d65272db92babcd7156ee9e36e..a4d77d15f47b2b64e412fb6b84a5f14898031b0c 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_select.h +++ b/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/event_loop_select.h @@ -44,6 +44,6 @@ private: std::mutex wakeUpMutex_; std::condition_variable wakeUpCondition_; }; -} +} // namespace DistributedDB #endif // EVENT_LOOP_USE_SELECT #endif // EVENT_LOOP_SELECT_H diff --git a/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/ievent.cpp b/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/ievent.cpp index a033d06b948d899f58507ae6c541e878ea46c2e0..361edfe06a508b0f66c45ec6e0d9d2f06b72e2a9 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/ievent.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/evloop/src/ievent.cpp @@ -56,4 +56,4 @@ IEvent *IEvent::CreateEvent(EventFd fd, EventsMask events, errCode = E_OK; return event; } -} +} // namespace DistributedDB diff --git a/services/distributeddataservice/libs/distributeddb/common/src/flatbuffer_schema.cpp b/services/distributeddataservice/libs/distributeddb/common/src/flatbuffer_schema.cpp index e1524f4f94b7bcd18652f48d4adaebf7c59e3289..3ba5419beeecc57da34cacc17afc18d2f8faa317 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/flatbuffer_schema.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/flatbuffer_schema.cpp @@ -503,7 +503,7 @@ int SchemaObject::FlatBufferSchema::ParseCheckRootTableAttribute(const reflectio return E_OK; } std::string skipsizeStr = SchemaUtils::Strip(skipsizeAttr->value()->str()); - int skipsizeInt = std::atoi(skipsizeStr.c_str()); // std::stoi will throw exception + int skipsizeInt = strtol(skipsizeStr.c_str(), nullptr, 10); // 10: decimal if (std::to_string(skipsizeInt) != skipsizeStr || skipsizeInt < 0 || static_cast(skipsizeInt) > SchemaConstant::SCHEMA_SKIPSIZE_MAX) { LOGE("[FBSchema][ParseRootAttr] Unexpect SCHEMA_SKIPSIZE value=%s.", skipsizeAttr->value()->c_str()); diff --git a/services/distributeddataservice/libs/distributeddb/common/src/parcel.cpp b/services/distributeddataservice/libs/distributeddb/common/src/parcel.cpp index 9fedced192aff4ada04bc59973dad594e882781b..372a9bfc66ffdf914b708338762688ce4fbd0084 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..fe8cdd610f8212b7bcaf338f011e5645c8446d43 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/schema_utils.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/schema_utils.cpp @@ -157,7 +157,7 @@ int SchemaUtils::TransToInteger(const std::string &defaultContent, SchemaAttribu if (defaultContent.empty()) { return -E_SCHEMA_PARSE_FAIL; } - int transRes = std::atoi(defaultContent.c_str()); + int transRes = strtol(defaultContent.c_str(), nullptr, 10); // 10: decimal std::string resReview = std::to_string(transRes); if (defaultContent.compare(defaultContent.find_first_not_of("+- "), defaultContent.size(), resReview, resReview.find_first_not_of("+- "), resReview.size()) == 0) { @@ -179,7 +179,7 @@ int SchemaUtils::TransToLong(const std::string &defaultContent, SchemaAttribute if (defaultContent.empty()) { return -E_SCHEMA_PARSE_FAIL; } - int64_t transRes = std::atoll(defaultContent.c_str()); + int64_t transRes = strtoll(defaultContent.c_str(), nullptr, 10); // 10: decimal std::string resReview = std::to_string(transRes); if (defaultContent.compare(defaultContent.find_first_not_of("+- "), defaultContent.size(), resReview, resReview.find_first_not_of("+- "), resReview.size()) == 0) { @@ -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..84d3cca61fdc2be64a55ce9bc797e9d6610b9fd3 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; } @@ -811,7 +811,7 @@ int ProtocolProto::ParseCommDivergeHeader(const uint8_t *bytes, uint32_t length, } uint16_t version = NetToHost(*(reinterpret_cast(bytes + sizeof(CommPhyHeader)))); if (version != PROTOCOL_VERSION) { - LOGE("[Proto][ParseDiverge] Version=%u not support.", version); + LOGE("[Proto][ParseDiverge] Version=%" PRIu16 " not support.", version); return -E_VERSION_NOT_SUPPORT; } @@ -930,7 +930,7 @@ int ProtocolProto::FrameFragmentation(const uint8_t *splitStartBytes, const Fram const CommPhyHeader &framePhyHeader, std::vector, uint32_t>> &outPieces) { // It can be guaranteed that fragCount >= 2 and also won't be too large - if (fragmentInfo.fragCount < 2) { + if (fragmentInfo.fragCount < MIN_FRAGMENT_COUNT) { return -E_INVALID_ARGS; } outPieces.resize(fragmentInfo.fragCount); // Note: should use resize other than reserve @@ -979,7 +979,8 @@ int ProtocolProto::FrameFragmentation(const uint8_t *splitStartBytes, const Fram pieceFragLen, packet); entry.second = fragmentInfo.extendHeadSize; if (err != E_OK) { - LOGE("[Proto][FrameFrag] Fill packet fail, fragCount=%u, fragNo=%u", fragmentInfo.fragCount, fragNo); + LOGE("[Proto][FrameFrag] Fill packet fail, fragCount=%" PRIu16 ", fragNo=%" PRIu16, fragmentInfo.fragCount, + fragNo); return err; } 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/data_transformer.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/data_transformer.cpp index a019cbda930a9440ac411e103138c12b558a1cba..70f8d33c2e74b383353f4bad8380d50c3ab286af 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/data_transformer.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/data_transformer.cpp @@ -261,7 +261,7 @@ int SerializeDataValue(const DataValue &dataValue, Parcel &parcel) StorageType type = dataValue.GetType(); parcel.WriteUInt32(static_cast(type)); if (type < StorageType::STORAGE_TYPE_NULL || type > StorageType::STORAGE_TYPE_BLOB) { - LOGE("Cannot serialize %u", type); + LOGE("Cannot serialize %u", static_cast(type)); return -E_NOT_SUPPORT; } return funcs[static_cast(type) - 1](dataValue, parcel); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb.cpp index e19fbaf4a62b44522ae5884df3e2eae44ce4b85c..4184ad26870c165286eea344769ab7906f935a90 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb.cpp @@ -342,11 +342,15 @@ uint32_t GenericKvDB::GetRegisterFunctionCount(RegisterFuncType type) const int GenericKvDB::TransObserverTypeToRegisterFunctionType(int observerType, RegisterFuncType &type) const { + (void)observerType; + (void)type; return -E_NOT_SUPPORT; } int GenericKvDB::TransConflictTypeToRegisterFunctionType(int conflictType, RegisterFuncType &type) const { + (void)conflictType; + (void)type; return -E_NOT_SUPPORT; } @@ -371,6 +375,7 @@ bool GenericKvDB::IsDataMigrating() const void GenericKvDB::SetConnectionFlag(bool isExisted) const { + (void)isExisted; return; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb_connection.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb_connection.cpp index d3602d5cecb5793ec98616aea7bb1dc137dcd85f..464d9850aec86cacb01de5ac0d122bb3a17c8d9d 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb_connection.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/generic_kvdb_connection.cpp @@ -168,6 +168,8 @@ int GenericKvDBConnection::UnRegisterObserver(const KvDBObserverHandle *observer int GenericKvDBConnection::SetConflictNotifier(int conflictType, const KvDBConflictAction &action) { + (void)conflictType; + (void)action; return -E_NOT_SUPPORT; } @@ -203,6 +205,8 @@ std::string GenericKvDBConnection::GetIdentifier() const int GenericKvDBConnection::Pragma(int cmd, void *parameter) { + (void)cmd; + (void)parameter; return -E_NOT_SUPPORT; } @@ -218,38 +222,53 @@ void GenericKvDBConnection::SetSafeDeleted() int GenericKvDBConnection::GetEntries(const IOption &option, const Key &keyPrefix, std::vector &entries) const { + (void)option; + (void)keyPrefix; + (void)entries; return -E_NOT_SUPPORT; } int GenericKvDBConnection::GetEntries(const IOption &option, const Query &query, std::vector &entries) const { + (void)option; + (void)query; + (void)entries; return -E_NOT_SUPPORT; } -int GenericKvDBConnection::GetResultSet(const IOption &option, const Key &keyPrefix, - IKvDBResultSet *&resultSet) const +int GenericKvDBConnection::GetResultSet(const IOption &option, const Key &keyPrefix, IKvDBResultSet *&resultSet) const { + (void)option; + (void)keyPrefix; + (void)resultSet; return -E_NOT_SUPPORT; } int GenericKvDBConnection::GetResultSet(const IOption &option, const Query &query, IKvDBResultSet *&resultSet) const { + (void)option; + (void)query; + (void)resultSet; return -E_NOT_SUPPORT; } int GenericKvDBConnection::GetCount(const IOption &option, const Query &query, int &count) const { + (void)option; + (void)query; + (void)count; return -E_NOT_SUPPORT; } void GenericKvDBConnection::ReleaseResultSet(IKvDBResultSet *&resultSet) { + (void)resultSet; return; } int GenericKvDBConnection::RegisterLifeCycleCallback(const DatabaseLifeCycleNotifier ¬ifier) { - (void) notifier; + (void)notifier; return -E_NOT_SUPPORT; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp index ee3dd9233e0c1afacbe99167a2ca46701ca49898..3007d8566a99f88e5ad0c53b3429cb5c357631da 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/kvdb_commit_notify_filterable_data.cpp @@ -75,7 +75,7 @@ bool KvDBCommitNotifyFilterAbleData::IsConflictedDataEmpty() const void KvDBCommitNotifyFilterAbleData::SetFilterKey(const Key &key) { - (void) key; + (void)key; return; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/kvdb_manager.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/kvdb_manager.cpp index b6b589db49d6b190e9c2b3454c2d6b6668b1a101..49603ad0c5c2b3661641b0c2857ba930939d0136 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/kvdb_manager.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/kvdb_manager.cpp @@ -442,7 +442,7 @@ int KvDBManager::CalculateKvStoreSize(const KvDBProperties &properties, uint64_t if (innerErrCode != E_OK && innerErrCode != -E_NOT_FOUND) { return innerErrCode; } - LOGD("DB type [%d], size[%llu]", kvDbType, dbSize); + LOGD("DB type [%u], size[%" PRIu64 "]", static_cast(kvDbType), dbSize); totalSize = totalSize + dbSize; } // This represent Db file size(Unit is byte), It is small than max size(max uint64_t represent 2^64B) diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp index a492db363ed7d3b8acb50fb338744585017befd2..709724567463489f6be8ca07e30951fde93e2187 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store.cpp @@ -423,10 +423,6 @@ int MultiVerNaturalStore::Open(const KvDBProperties &kvDBProp) } multiVerEngine_ = std::make_unique(); - if (multiVerEngine_ == nullptr) { - errCode = -E_OUT_OF_MEMORY; - goto ERROR; - } errCode = multiVerEngine_->InitDatabases(this, multiVerData_, commitHistory_, multiVerKvStorage_, poolSize); if (errCode != E_OK) { goto ERROR; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp index 85f76b10e185b7bab102710c3b83acc1149a4637..abc5cd470cdabddea01ce0fb4bcd6a667f681fd9 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_natural_store_commit_storage.cpp @@ -706,7 +706,7 @@ int MultiVerNaturalStoreCommitStorage::TransferValueToCommit(const Value &value, { size_t valueLength = value.size(); if (valueLength == 0 || valueLength >= MAX_COMMIT_ST_LENGTH) { - LOGE("Failed to transfer value to commit struct! invalid value length:%ul.", valueLength); + LOGE("Failed to transfer value to commit struct! invalid value length:%zu.", valueLength); return -E_UNEXPECTED_DATA; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp index 6f52d8e3024075184084f6391d5e096cf789485e..d34e8eabbfc372b0893b9d937421da2d32680da8 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_storage_executor.cpp @@ -409,7 +409,7 @@ int MultiVerStorageExecutor::ReInitTransactionVersion(const MultiVerCommitNode & errCode = E_OK; } } else { - LOGD("Reput the version:%llu", readCommit->GetCommitVersion()); + LOGD("Reput the version:%" PRIu64, readCommit->GetCommitVersion()); transaction_->SetVersion(readCommit->GetCommitVersion()); commitStorage_->ReleaseCommit(readCommit); } @@ -559,7 +559,7 @@ int MultiVerStorageExecutor::MergeCommits(const std::vector } if (item.deviceInfo.size() == MULTI_VER_TAG_SIZE || item.deviceInfo.compare(0, SHA256_DIGEST_LENGTH, rootNodeDeviceInfo, 0, SHA256_DIGEST_LENGTH) != 0) { - LOGD("Skip the version:%llu", item.version); + LOGD("Skip the version:%" PRIu64, item.version); continue; } errCode = MergeOneCommit(item); @@ -871,7 +871,7 @@ int MultiVerStorageExecutor::CommitTransaction(MultiTransactionType type) dataStorage_->RollbackWritePhaseOne(transaction_, commitVersion); goto END; } - LOGD("local commit version:%llu", commitVersion); + LOGD("local commit version:%" PRIu64, commitVersion); static_cast(kvDB_)->SetMaxTimeStamp(multiVerTimeStamp.timestamp); dataStorage_->CommitWritePhaseTwo(transaction_); static_cast(kvDB_)->SetMaxCommitVersion(commitVersion); @@ -1107,7 +1107,7 @@ int MultiVerStorageExecutor::GetResolvedConflictEntries(const MultiVerCommitNode entries.clear(); entries.shrink_to_fit(); Version version = commit->GetCommitVersion(); - LOGD("Version is %llu", version); + LOGD("Version is %" PRIu64, version); if (transaction_ != nullptr) { errCode = transaction_->GetEntriesByVersion(version, entries); if (errCode != E_OK) { @@ -1318,7 +1318,7 @@ int MultiVerStorageExecutor::CommitTransaction(const MultiVerCommitNode &multiVe dataStorage_->CommitWritePhaseTwo(transaction_); static_cast(kvDB_)->SetMaxTimeStamp(multiVerTimeStamp.timestamp); static_cast(kvDB_)->SetMaxCommitVersion(commitVersion); - LOGD("sync commit version:%llu", commitVersion); + LOGD("sync commit version:%" PRIu64, commitVersion); END: dataStorage_->ReleaseTransaction(transaction_); transaction_ = nullptr; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp index e5b63ee426264fa0a7cc58f6dcd7efa69d6fa6ef..9014b4707a9c5aecd9a906eeed347ab2c0b08db9 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/multiver/multi_ver_vacuum.cpp @@ -356,8 +356,8 @@ int MultiVerVacuum::DealWithLeftBranchVacuumNeedRecord(VacuumTaskContext &inTask // No other thread will access handle, node and record field of a RUN_NING, PAUSE_WAIT, ABORT_WAIT status task // So it is concurrency safe to access or change these field without protection of lockguard const MultiVerRecordInfo &record = inTask.vacuumNeedRecords.front(); - LOGD("[Vacuum][DealLeftRecord] Type=%d, Version=%llu, HashKey=%s.", record.type, ULL(record.version), - VEC_TO_STR(record.hashKey)); + LOGD("[Vacuum][DealLeftRecord] Type=%" PRIu32 ", Version=%" PRIu64 ", HashKey=%s.", + static_cast(record.type), record.version, VEC_TO_STR(record.hashKey)); if (inTask.shadowRecords.empty()) { if (record.type == RecordType::CLEAR) { errCode = inTask.databaseHandle->GetShadowRecordsOfClearTypeRecord(record.version, record.hashKey, @@ -368,7 +368,7 @@ int MultiVerVacuum::DealWithLeftBranchVacuumNeedRecord(VacuumTaskContext &inTask } if (errCode != E_OK) { LOGE("[Vacuum][DealLeftRecord] GetShadowRecords fail, Type=%d, Version=%llu, HashKey=%s, errCode=%d.", - record.type, ULL(record.version), VEC_TO_STR(record.hashKey), errCode); + static_cast(record.type), ULL(record.version), VEC_TO_STR(record.hashKey), errCode); DoRollBackAndFinish(inTask); return errCode; } @@ -391,7 +391,7 @@ int MultiVerVacuum::DealWithLeftBranchVacuumNeedRecord(VacuumTaskContext &inTask errCode = inTask.databaseHandle->MarkRecordAsVacuumDone(record.version, record.hashKey); if (errCode != E_OK) { LOGE("[Vacuum][DealLeftRecord] MarkRecordAsVacuumDone fail, Type=%d, Version=%llu, HashKey=%s, errCode=%d.", - record.type, ULL(record.version), VEC_TO_STR(record.hashKey), errCode); + static_cast(record.type), ULL(record.version), VEC_TO_STR(record.hashKey), errCode); DoRollBackAndFinish(inTask); return errCode; } @@ -477,8 +477,8 @@ int MultiVerVacuum::DoDeleteRecordOfLeftShadowOrRightVacuumNeed(VacuumTaskContex // No other thread will access handle, node and record field of a RUN_NING, PAUSE_WAIT, ABORT_WAIT status task // So it is concurrency safe to access or change these field without protection of lockguard const MultiVerRecordInfo &record = recordList.front(); - LOGD("[Vacuum][DoDeleteRecord] Type=%d, Version=%llu, HashKey=%s.", record.type, ULL(record.version), - VEC_TO_STR(record.hashKey)); + LOGD("[Vacuum][DoDeleteRecord] Type=%u, Version=%llu, HashKey=%s.", static_cast(record.type), + ULL(record.version), VEC_TO_STR(record.hashKey)); errCode = StartTransactionIfNotYet(inTask); if (errCode != E_OK) { std::lock_guard vacuumTaskLockGuard(vacuumTaskMutex_); @@ -487,8 +487,8 @@ int MultiVerVacuum::DoDeleteRecordOfLeftShadowOrRightVacuumNeed(VacuumTaskContex } errCode = inTask.databaseHandle->DeleteRecordTotally(record.version, record.hashKey); if (errCode != E_OK) { - LOGE("[Vacuum][DoDeleteRecord] DeleteRecordTotally fail, Type=%d, Version=%llu, HashKey=%s, errCode=%d.", - record.type, ULL(record.version), VEC_TO_STR(record.hashKey), errCode); + LOGE("[Vacuum][DoDeleteRecord] DeleteRecordTotally fail, Type=%u, Version=%llu, HashKey=%s, errCode=%d.", + static_cast(record.type), ULL(record.version), VEC_TO_STR(record.hashKey), errCode); DoRollBackAndFinish(inTask); return errCode; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_object.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_object.cpp index 55c749d27346db62a34d4ff2393e919f71323413..4f474755549106318f2f247219278e8e4d95cf8f 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_object.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_object.cpp @@ -302,7 +302,8 @@ int QueryObject::CheckEqualFormat(const std::list::iterator &iter) FieldType schemaFieldType = FieldType::LEAF_FIELD_BOOL; errCode = schema_.CheckQueryableAndGetFieldType(fieldPath, schemaFieldType); if (errCode != E_OK) { - LOGE("Get field type fail when check compare format! errCode = %d, fieldType = %d", errCode, schemaFieldType); + LOGE("Get field type fail when check compare format! errCode = %d, fieldType = %u", + errCode, static_cast(schemaFieldType)); return -E_INVALID_QUERY_FIELD; } @@ -343,7 +344,8 @@ int QueryObject::CheckLinkerFormat(const std::list::iterator &iter } SymbolType symbolType = SqliteQueryHelper::GetSymbolType(nextIter->operFlag); if (symbolType == INVALID_SYMBOL || symbolType == LINK_SYMBOL || symbolType == SPECIAL_SYMBOL) { - LOGE("Must be followed by comparison operation! operflag[%d], symbolType[%d]", nextIter->operFlag, symbolType); + LOGE("Must be followed by comparison operation! operflag[%u], symbolType[%u]", + static_cast(nextIter->operFlag), static_cast(symbolType)); return -E_INVALID_QUERY_FORMAT; } return CheckLinkerBefore(iter); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp index c43ef227d64ef39ec5c6dfa6b60905b133fc8ef6..41a30fabc1f332ea9e7916ad54ff9afd5a0c1e9c 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp @@ -164,6 +164,8 @@ int SQLiteRelationalStoreConnection::RemoveDeviceData(const std::string &device, int SQLiteRelationalStoreConnection::Pragma(int cmd, void *parameter) // reserve for interface function fix { + (void)cmd; + (void)parameter; return E_OK; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp index 53712b1e8b7c0d1e166810123ef81b8b569cf986..a6f2940fdf4ff33a7060d4a49670c47ddbe56544 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_multi_ver_transaction.cpp @@ -364,7 +364,7 @@ int SQLiteMultiVerTransaction::CheckToSaveRecord(const MultiVerKvEntry *entry, b (static_cast(entry))->GetOperFlag(operFlag); entry->GetTimestamp(timestamp); if ((operFlag & OPERATE_MASK) == CLEAR_FLAG && version_ != 0) { - LOGD("Erase one version:%llu ", version_); + LOGD("Erase one version:%" PRIu64, version_); errCode = GetPrePutValues(version_, timestamp, values); if (errCode != E_OK) { return errCode; @@ -792,7 +792,7 @@ int SQLiteMultiVerTransaction::UpdateTimestampByVersion(const Version &version, if (errCode == SQLiteUtils::MapSQLiteErrno(SQLITE_DONE)) { errCode = E_OK; currentMaxTimestamp_ = (stamp > currentMaxTimestamp_) ? stamp : currentMaxTimestamp_; - LOGD("Update the timestamp of version:%llu - %llu", version, stamp); + LOGD("Update the timestamp of version:%" PRIu64 " - %" PRIu64, version, stamp); } else { LOGE("Failed to update the timestamp of the version:%d", errCode); } @@ -1079,7 +1079,7 @@ int SQLiteMultiVerTransaction::AddRecord(const Key &key, const Value &value, dataCopy.timestamp = currentMaxTimestamp_++; if ((dataCopy.operFlag & LOCAL_FLAG) != 0) { dataCopy.oriTimestamp = currentMaxTimestamp_; - LOGD("Origin timestamp:%llu", currentMaxTimestamp_); + LOGD("Origin timestamp:%" PRIu64, currentMaxTimestamp_); } } @@ -1404,8 +1404,8 @@ int SQLiteMultiVerTransaction::CheckIfNeedSaveRecord(sqlite3_stmt *statement, co static_cast(multiVerKvEntry)->GetOriTimestamp(oriTimestamp); // Only the latest origin time is same or the reading time is bigger than putting time. isNeedSave = ((readTime < timestamp) && (readOriTime != oriTimestamp || value != origVal)); - LOGD("Timestamp :%llu vs %llu, %llu vs %llu, readVersion:%llu, version:%llu, %d", - readOriTime, oriTimestamp, readTime, timestamp, readVersion, version_, isNeedSave); + LOGD("Timestamp :%" PRIu64 " vs %" PRIu64 ", %" PRIu64 " vs %" PRIu64 ", readVersion:%" PRIu64 ", version:" + "%" PRIu64 ", %d", readOriTime, oriTimestamp, readTime, timestamp, readVersion, version_, isNeedSave); // if the version of the data to be saved is same to the original, you should notify the caller. if (readVersion != version_) { origVal.resize(0); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp index 58f1811f87ec7b6377b91647c881b1471113999c..efd8b59f7bf75b9f765147ac10b4647f88e1ada1 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp @@ -770,8 +770,8 @@ int SQLiteSingleVerNaturalStore::GetSyncDataForQuerySync(std::vector & // Get query data. if (!continueStmtToken->IsGetQueryDataFinished()) { - LOGD("[SingleVerNStore] Get query data between %llu and %llu.", continueStmtToken->GetQueryBeginTime(), - continueStmtToken->GetQueryEndTime()); + LOGD("[SingleVerNStore] Get query data between %" PRIu64 " and %" PRIu64 ".", + continueStmtToken->GetQueryBeginTime(), continueStmtToken->GetQueryEndTime()); errCode = handle->GetSyncDataWithQuery(continueStmtToken->GetQuery(), GetAppendedLen(), dataSizeInfo, std::make_pair(continueStmtToken->GetQueryBeginTime(), continueStmtToken->GetQueryEndTime()), dataItems); } @@ -784,7 +784,7 @@ int SQLiteSingleVerNaturalStore::GetSyncDataForQuerySync(std::vector & errCode = -E_UNFINISHED; // Get delete time next. if (CanHoldDeletedData(dataItems, dataSizeInfo, GetAppendedLen())) { - LOGD("[SingleVerNStore] Get deleted data between %llu and %llu.", + LOGD("[SingleVerNStore] Get deleted data between %" PRIu64 " and %" PRIu64 ".", continueStmtToken->GetDeletedBeginTime(), continueStmtToken->GetDeletedEndTime()); errCode = handle->GetDeletedSyncDataByTimestamp(dataItems, GetAppendedLen(), continueStmtToken->GetDeletedBeginTime(), continueStmtToken->GetDeletedEndTime(), dataSizeInfo); @@ -956,7 +956,7 @@ int SQLiteSingleVerNaturalStore::RemoveDeviceData(const std::string &deviceName, uint64_t logFileSize = handle->GetLogFileSize(); ReleaseHandle(handle); if (logFileSize > GetMaxLogSize()) { - LOGW("[SingleVerNStore] RmDevData log size[%llu] over the limit", logFileSize); + LOGW("[SingleVerNStore] RmDevData log size[%" PRIu64 "] over the limit", logFileSize); return -E_LOG_OVER_LIMITS; } @@ -988,7 +988,7 @@ int SQLiteSingleVerNaturalStore::RemoveDeviceDataInCacheMode(const std::string & return errCode; } uint64_t recordVersion = GetAndIncreaseCacheRecordVersion(); - LOGI("Remove device data in cache mode isNeedNotify : %d, recordVersion : %d", isNeedNotify, recordVersion); + LOGI("Remove device data in cache mode isNeedNotify:%d, recordVersion:%" PRIu64, isNeedNotify, recordVersion); errCode = handle->RemoveDeviceDataInCacheMode(deviceName, isNeedNotify, recordVersion); if (errCode != E_OK) { LOGE("[SingleVerNStore] RemoveDeviceDataInCacheMode failed:%d", errCode); @@ -1159,7 +1159,7 @@ void SQLiteSingleVerNaturalStore::InitCurrentMaxStamp() } handle->InitCurrentMaxStamp(currentMaxTimeStamp_); - LOGD("Init max timestamp:%llu", currentMaxTimeStamp_); + LOGD("Init max timestamp:%" PRIu64, currentMaxTimeStamp_); ReleaseHandle(handle); } @@ -2251,7 +2251,7 @@ int SQLiteSingleVerNaturalStore::RemoveSubscribe(const std::string &subscribeId) int SQLiteSingleVerNaturalStore::SetMaxLogSize(uint64_t limit) { - LOGI("Set the max log size to %llu", limit); + LOGI("Set the max log size to %" PRIu64, limit); maxLogSize_.store(limit); return E_OK; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp index 5d014b0105b5b8b20a43e85ea8eda065b775141f..958b5acebca0d941c67c086f36e67d51ad2bf7dd 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp @@ -1015,7 +1015,7 @@ int SQLiteSingleVerNaturalStoreConnection::SaveLocalEntry(const Entry &entry, bo dataItem.flag = DataItem::DELETE_FLAG; } dataItem.timeStamp = naturalStore->GetCurrentTimeStamp(); - LOGD("TimeStamp is %llu", dataItem.timeStamp); + LOGD("TimeStamp is %" PRIu64, dataItem.timeStamp); if (IsCacheDBMode()) { return SaveLocalItemInCacheMode(dataItem); @@ -1750,7 +1750,7 @@ bool SQLiteSingleVerNaturalStoreConnection::CheckLogOverLimit(SQLiteSingleVerSto uint64_t logFileSize = executor->GetLogFileSize(); bool result = logFileSize > naturalStore->GetMaxLogSize(); if (result) { - LOGW("Log size[%llu] over the limit", logFileSize); + LOGW("Log size[%" PRIu64 "] over the limit", logFileSize); } return result; } 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..cf008c14bedf4bcd02b5652dbae6bb2c2471436a 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++; } @@ -280,7 +280,7 @@ int SQLiteSingleVerRelationalStorageExecutor::AlterAuxTableForUpgrade(const Tabl return errCode; } - LOGD("Begin to alter table: upgrade fields[%d], indexces[%d], deviceTable[%d]", upgradeFields.size(), + LOGD("Begin to alter table: upgrade fields[%zu], indexces[%zu], deviceTable[%zu]", upgradeFields.size(), upgradeIndexces.size(), deviceTables.size()); errCode = UpgradeFields(dbHandle_, deviceTables, upgradeFields); if (errCode != E_OK) { @@ -763,7 +763,7 @@ int SQLiteSingleVerRelationalStorageExecutor::SaveSyncDataItem(const DataItem &d const auto &fieldData = data.optionalData[cid]; errCode = BindDataValueByType(saveDataStmt, fieldData, cid + 1); if (errCode != E_OK) { - LOGE("Bind data failed, errCode:%d, cid:%d.", errCode, cid + 1); + LOGE("Bind data failed, errCode:%d, cid:%zu.", errCode, cid + 1); return errCode; } } @@ -1122,7 +1122,7 @@ int SQLiteSingleVerRelationalStorageExecutor::DeleteDistributedDeviceTable(const return errCode; } - LOGD("Begin to delete device table: deviceTable[%d]", deviceTables.size()); + LOGD("Begin to delete device table: deviceTable[%zu]", deviceTables.size()); for (const auto &table : deviceTables) { std::string deleteSql = "DROP TABLE IF EXISTS " + table + ";"; // drop the found table errCode = SQLiteUtils::ExecuteRawSQL(dbHandle_, deleteSql); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp index b24863a853a36317d019141ab5a6d49fd8c6deee..6f77bb141c010c39ace6382f3c3eb7564d44d935 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_result_set.cpp @@ -95,7 +95,7 @@ int SQLiteSingleVerResultSet::OpenForCacheFullEntryMode(bool isMemDb) } count_ = window_->GetTotalCount(); isOpen_ = true; - LOGD("[SqlSinResSet][OpenForEntry] Type=%d, CacheMaxSize=%d(MB), Count=%d, IsMem=%d.", type_, + LOGD("[SqlSinResSet][OpenForEntry] Type=%d, CacheMaxSize=%d(MB), Count=%d, IsMem=%d.", static_cast(type_), option_.cacheMaxSize, count_, isMemDb); return E_OK; } @@ -126,7 +126,7 @@ int SQLiteSingleVerResultSet::OpenForCacheEntryIdMode() cacheStartPosition_ = 0; } isOpen_ = true; - LOGD("[SqlSinResSet][OpenForRowId] Type=%d, CacheMaxSize=%d(MB), Count=%d, Cached=%zu.", type_, + LOGD("[SqlSinResSet][OpenForRowId] Type=%d, CacheMaxSize=%d(MB), Count=%d, Cached=%zu.", static_cast(type_), option_.cacheMaxSize, count_, cachedRowIds_.size()); return E_OK; } @@ -279,7 +279,7 @@ void SQLiteSingleVerResultSet::Close() isOpen_ = false; count_ = 0; position_ = INIT_POSTION; - LOGD("[SqlSinResSet][Close] Done, Type=%d, Mode=%d.", type_, option_.cacheMode); + LOGD("[SqlSinResSet][Close] Done, Type=%d, Mode=%d.", static_cast(type_), static_cast(option_.cacheMode)); } void SQLiteSingleVerResultSet::CloseForCacheFullEntryMode() diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp index 85714b270d7e13e70e4bb8d40f4c31f50a15f8f8..f999cdb5fefe274e35ddffb6c74b7c13155f064a 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp @@ -155,7 +155,8 @@ int SQLiteSingleVerStorageEngine::MigrateSyncDataByVersion(SQLiteSingleVerStorag } // next version need process - LOGD("MigrateVer[%llu], minVer[%llu] maxVer[%llu]", curMigrateVer, minVerIncurCacheDb, GetCacheRecordVersion()); + LOGD("MigrateVer[%" PRIu64 "], minVer[%" PRIu64 "] maxVer[%" PRIu64 "]", + curMigrateVer, minVerIncurCacheDb, GetCacheRecordVersion()); errCode = handle->MigrateSyncDataByVersion(curMigrateVer++, syncData, dataItems); if (errCode != E_OK) { LOGE("Migrate sync data fail and rollback, errCode = [%d]", errCode); @@ -238,7 +239,7 @@ int SQLiteSingleVerStorageEngine::MigrateSyncData(SQLiteSingleVerStorageExecutor } } - LOGD("Begin migrate sync data, need migrate version[%llu]", GetCacheRecordVersion() - 1); + LOGD("Begin migrate sync data, need migrate version[%" PRIu64 "]", GetCacheRecordVersion() - 1); uint64_t curMigrateVer = 0; // The migration process is asynchronous and continuous NotifyMigrateSyncData syncData; auto kvdbManager = KvDBManager::GetInstance(); @@ -258,7 +259,7 @@ int SQLiteSingleVerStorageEngine::MigrateSyncData(SQLiteSingleVerStorageExecutor while (curMigrateVer < GetCacheRecordVersion()) { errCode = MigrateSyncDataByVersion(handle, syncData, curMigrateVer); if (errCode != E_OK) { - LOGE("Migrate version[%llu] failed! errCode = [%d]", curMigrateVer, errCode); + LOGE("Migrate version[%" PRIu64 "] failed! errCode = [%d]", curMigrateVer, errCode); break; } if (!syncData.isRemote) { @@ -448,7 +449,7 @@ int SQLiteSingleVerStorageEngine::ExecuteMigrate() if (preState == EngineState::MIGRATING || preState == EngineState::INVALID || !OS::CheckPathExistence(GetDbDir(option_.subdir, DbType::CACHE) + "/" + DBConstant::SINGLE_VER_CACHE_STORE + DBConstant::SQLITE_DB_EXTENSION)) { - LOGD("[SqlSingleVerEngine] Being single ver migrating or never create db! engine state [%d]", preState); + LOGD("[SqlSingleVerEngine] Being single ver migrating or never create db! engine state [%u]", preState); return E_OK; } @@ -469,8 +470,8 @@ int SQLiteSingleVerStorageEngine::ExecuteMigrate() goto END; } - LOGD("[SqlSingleVerEngine] Current engineState [%d] executorState [%d], begin to executing singleVer db migrate!", - preState, executorState_); + LOGD("[SqlSingleVerEngine] Current engineState [%u] executorState [%u], begin to executing singleVer db migrate!", + static_cast(preState), static_cast(executorState_)); // has been attached, Mark start of migration and it can migrate data errCode = MigrateLocalData(handle); if (errCode != E_OK) { diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp index 07257fcf199206031dcfcbc9fb8839bc96224d12..5744bc88c73eac33b803d761cdc9aec85b06ede5 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp @@ -1228,7 +1228,8 @@ DataOperStatus SQLiteSingleVerStorageExecutor::JudgeSyncSaveType(DataItem &dataI if (itemGet.writeTimeStamp >= dataItem.writeTimeStamp) { // for multi user mode, no permit to forcewrite if ((!deviceName.empty()) && (itemGet.dev == deviceName) && isPermitForceWrite) { - LOGI("Force overwrite the data:%llu vs %llu", itemGet.writeTimeStamp, dataItem.writeTimeStamp); + LOGI("Force overwrite the data:%" PRIu64 " vs %" PRIu64, + itemGet.writeTimeStamp, dataItem.writeTimeStamp); status.isDefeated = false; dataItem.writeTimeStamp = itemGet.writeTimeStamp + 1; dataItem.timeStamp = itemGet.timeStamp; @@ -1506,7 +1507,8 @@ int SQLiteSingleVerStorageExecutor::BindSavedSyncData(sqlite3_stmt *statement, c const int writeTimeIndex = isUpdate ? BIND_SYNC_UPDATE_W_TIME_INDEX : BIND_SYNC_W_TIME_INDEX; errCode = SQLiteUtils::BindInt64ToStatement(statement, writeTimeIndex, dataItem.writeTimeStamp); - LOGD("Write timestamp:%llu timestamp:%llu, %llu", dataItem.writeTimeStamp, dataItem.timeStamp, dataItem.flag); + LOGD("Write timestamp:%" PRIu64 " timestamp:%" PRIu64 ", %" PRIu64, + dataItem.writeTimeStamp, dataItem.timeStamp, dataItem.flag); if (errCode != E_OK) { LOGE("Bind saved sync data write stamp failed:%d", errCode); return errCode; 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 0c2d447548fbcac54bb10057a103bac5337f4b0a..41dce838451fc29502e4e3f12f49554d63855efa 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 @@ -219,8 +219,8 @@ int SQLiteSingleVerStorageExecutor::AttachMainDbAndCacheDb(CipherType type, cons } else { return -E_INVALID_ARGS; } - LOGD("[singleVerExecutor][attachDb] current engineState[%d], executorState[%d]", engineState, executorState_); - + LOGD("[singleVerExecutor][attachDb] current engineState[%u], executorState[%u]", static_cast(engineState), + static_cast(executorState_)); return errCode; } @@ -532,8 +532,8 @@ int SQLiteSingleVerStorageExecutor::BindSyncDataInCacheMode(sqlite3_stmt *statem return errCode; } - LOGD("Write timestamp:%llu timestamp%llu, %llu, version %llu", dataItem.writeTimeStamp, dataItem.timeStamp, - dataItem.flag, recordVersion); + LOGD("Write timestamp:%" PRIu64 " timestamp:%" PRIu64 ", flag:%" PRIu64 ", version:%" PRIu64, + dataItem.writeTimeStamp, dataItem.timeStamp, dataItem.flag, recordVersion); errCode = SQLiteUtils::BindInt64ToStatement(statement, BIND_CACHE_SYNC_FLAG_INDEX, static_cast(dataItem.flag)); if (errCode != E_OK) { @@ -800,7 +800,7 @@ int SQLiteSingleVerStorageExecutor::GetMinTimestampInCacheDB(TimeStamp &minStamp errCode = SQLiteUtils::StepWithRetry(statement, isMemDb_); if (errCode == SQLiteUtils::MapSQLiteErrno(SQLITE_ROW)) { minStamp = static_cast(sqlite3_column_int64(statement, 0)); // get the first column - LOGD("Min time stamp in cacheDB is %llu", minStamp); + LOGD("Min time stamp in cacheDB is %" PRIu64, minStamp); errCode = E_OK; } else { LOGE("GetMinTimestampInCacheDB failed, errCode = %d.", errCode); @@ -840,8 +840,8 @@ int SQLiteSingleVerStorageExecutor::InitMigrateTimeStampOffset() // The purpose of -1 is to ensure that the first data record in the original cacheDB is 1 greater than // the last data record in the original mainDB after the migration. migrateTimeOffset_ = minTimeInCache - maxTimeInMain - 1; - LOGI("Min timestamp in cacheDB is %llu, max timestamp in mainDB is %llu. Time offset during migrating is %lld.", - minTimeInCache, maxTimeInMain, migrateTimeOffset_); + LOGI("Min timestamp in cacheDB is %" PRIu64 ", max timestamp in mainDB is %" PRIu64 ". Time offset during migrating" + " is %" PRId64 ".", minTimeInCache, maxTimeInMain, migrateTimeOffset_); return E_OK; } @@ -907,7 +907,7 @@ int SQLiteSingleVerStorageExecutor::InitMigrateData() insertSQL = MIGRATE_INSERT_DATA_TO_MAINDB_FROM_CACHEHANDLE; updateSQL = MIGRATE_UPDATE_DATA_TO_MAINDB_FROM_CACHEHANDLE; } else { - LOGE("[InitMigrateData] executor in an error state[%d]!", executorState_); + LOGE("[InitMigrateData] executor in an error state[%u]!", static_cast(executorState_)); return -E_INVALID_DB; } int errCode = PrepareForSavingData(querySQL, insertSQL, updateSQL, migrateSyncStatements_); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp index 5f79dbecd1c76f04b8c192c7020fd3e9c1e85394..e7217e167ffe03bb9b216176a975edd97514f719 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_subscribe.cpp @@ -172,13 +172,14 @@ int SQLiteSingleVerStorageExecutor::AddSubscribeTrigger(QueryObject &query, cons std::string subscribeCondition; errCode = helper.GetSubscribeSql(subscribeId, mode, subscribeCondition); if (errCode != E_OK) { - LOGE("Get subscribe trigger create sql failed. mode: %d, errCode: %d", mode, errCode); + LOGE("Get subscribe trigger create sql failed. mode: %u, errCode: %d", static_cast(mode), + errCode); return errCode; } std::string sql = FormatSubscribeTriggerSql(subscribeId, subscribeCondition, mode); errCode = SQLiteUtils::ExecuteRawSQL(dbHandle_, sql); if (errCode != E_OK) { - LOGE("Add subscribe trigger failed. mode: %d, errCode: %d", mode, errCode); + LOGE("Add subscribe trigger failed. mode: %u, errCode: %d", static_cast(mode), errCode); return errCode; } } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp index 0d6084c9a014e5e85fe2dda7a6408838761a32a4..b7ed3b1fc438e5798b8a4837641efdd0e2cad3ed 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_storage_engine.cpp @@ -63,6 +63,7 @@ int SQLiteStorageEngine::Upgrade(sqlite3 *db) // SQLiteLocalStorageEngine do not override this function so content upgrade can only be done by the Storage // who use the SQLiteLocalKvDB. // MultiVerStorageEngine do not inherit SQLiteStorageEngine. + (void)db; return E_OK; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/storage_engine.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/storage_engine.cpp index 007a87bf368e887cdacedcfdda33d8619be02d3b..73727a8d9b4faae50477bd3d9903d31e4df13176 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/storage_engine.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/storage_engine.cpp @@ -114,7 +114,7 @@ StorageExecutor *StorageEngine::FindWriteExecutor(OperatePerm perm, int &errCode std::unique_lock lock(writeMutex_); errCode = -E_BUSY; if (perm_ == OperatePerm::DISABLE_PERM || perm_ != perm) { - LOGI("Not permitted to get the executor[%d]", perm_); + LOGI("Not permitted to get the executor[%u]", static_cast(perm_)); return nullptr; } if (waitTime <= 0) { // non-blocking. @@ -137,8 +137,9 @@ StorageExecutor *StorageEngine::FindWriteExecutor(OperatePerm perm, int &errCode return nullptr; } if (!result) { - LOGI("Get write handle result[%d], permissType[%d], operType[%d], write[%d-%d-%d]", - result, perm_, perm, writeIdleList_.size(), writeUsingList_.size(), engineAttr_.maxWriteNum); + LOGI("Get write handle result[%d], permissType[%u], operType[%u], write[%zu-%zu-%" PRIu32 "]", result, + static_cast(perm_), static_cast(perm), writeIdleList_.size(), writeUsingList_.size(), + engineAttr_.maxWriteNum); return nullptr; } return FetchStorageExecutor(true, writeIdleList_, writeUsingList_, errCode); @@ -149,7 +150,7 @@ StorageExecutor *StorageEngine::FindReadExecutor(OperatePerm perm, int &errCode, std::unique_lock lock(readMutex_); errCode = -E_BUSY; if (perm_ == OperatePerm::DISABLE_PERM || perm_ != perm) { - LOGI("Not permitted to get the executor[%d]", perm_); + LOGI("Not permitted to get the executor[%u]", static_cast(perm_)); return nullptr; } @@ -173,8 +174,9 @@ StorageExecutor *StorageEngine::FindReadExecutor(OperatePerm perm, int &errCode, return nullptr; } if (!result) { - LOGI("Get read handle result[%d], permissType[%d], operType[%d], read[%d-%d-%d]", - result, perm_, perm, readIdleList_.size(), readUsingList_.size(), engineAttr_.maxReadNum); + LOGI("Get read handle result[%d], permissType[%u], operType[%u], read[%zu-%zu-%" PRIu32 "]", result, + static_cast(perm_), static_cast(perm), readIdleList_.size(), readUsingList_.size(), + engineAttr_.maxReadNum); return nullptr; } return FetchStorageExecutor(false, readIdleList_, readUsingList_, errCode); @@ -411,7 +413,7 @@ StorageExecutor *StorageEngine::FetchStorageExecutor(bool isWrite, std::list INT32_MAX) { - LOGE("[AbilitySyncRequestPacket][CalculateLen] err len:%llu", len); + LOGE("[AbilitySyncRequestPacket][CalculateLen] err len:%" PRIu64, len); return 0; } return len; @@ -299,7 +299,7 @@ uint32_t AbilitySyncAckPacket::CalculateLen() const len += DbAbility::CalculateLen(dbAbility_); // dbAbility_ len += SchemaNegotiate::CalculateParcelLen(relationalSyncOpinion_); if (len > INT32_MAX) { - LOGE("[AbilitySyncAckPacket][CalculateLen] err len:%llu", len); + LOGE("[AbilitySyncAckPacket][CalculateLen] err len:%" PRIu64, len); return 0; } return len; @@ -459,7 +459,7 @@ int AbilitySync::AckNotifyRecv(const Message *message, ISyncTaskContext *context } int errCode = packet->GetAckCode(); if (errCode != E_OK) { - LOGE("[AbilitySync][AckNotifyRecv] received a errCode %d", errCode); + LOGE("[AbilitySync][AckNotifyRecv] received an errCode %d", errCode); return errCode; } std::string schema = packet->GetSchema(); @@ -930,7 +930,7 @@ int AbilitySync::SetAbilityRequestBodyInfo(AbilitySyncRequestPacket &packet, uin packet.SetSecFlag(option.securityFlag); packet.SetDbCreateTime(dbCreateTime); packet.SetDbAbility(dbAbility); - LOGI("[AbilitySync][FillRequest] ver=%u,Lab=%d,Flag=%d,dbCreateTime=%llu", SOFTWARE_VERSION_CURRENT, + LOGI("[AbilitySync][FillRequest] ver=%u,Lab=%d,Flag=%d,dbCreateTime=%" PRId64, SOFTWARE_VERSION_CURRENT, option.securityLabel, option.securityFlag, dbCreateTime); return E_OK; } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/commit_history_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/commit_history_sync.cpp index 350dc4596ff09a9daf3dd305417b17262ee3c464..cb5f3a16c8314cb2c2ec6572c838f51a9365cdca 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/commit_history_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/commit_history_sync.cpp @@ -312,7 +312,7 @@ int CommitHistorySync::AckRecvCallback(MultiVerSyncTaskContext *context, const M context->SetCommits(commits); context->SetCommitIndex(0); context->SetCommitsSize(static_cast(commits.size())); - LOGD("CommitHistorySync::AckRecvCallback end, CommitsSize = %llu, dst = %s{private}, ver = %d, myversion = %u", + LOGD("CommitHistorySync::AckRecvCallback end, CommitsSize = %zu, dst = %s{private}, ver = %d, myversion = %u", commits.size(), context->GetDeviceId().c_str(), ver, SOFTWARE_VERSION_CURRENT); return E_OK; } @@ -386,7 +386,7 @@ int CommitHistorySync::RequestPacketDeSerialization(const uint8_t *buffer, uint3 Parcel parcel(const_cast(buffer), length); packLen += parcel.ReadUInt64(len); if (len > DBConstant::MAX_DEVICES_SIZE) { - LOGE("CommitHistorySync::RequestPacketDeSerialization : commitMap size too large = %llu", len); + LOGE("CommitHistorySync::RequestPacketDeSerialization : commitMap size too large = %" PRIu64, len); return -E_INVALID_ARGS; } // commitMap DeSerialization @@ -408,8 +408,8 @@ int CommitHistorySync::RequestPacketDeSerialization(const uint8_t *buffer, uint3 packLen += parcel.ReadVector(reserved); packLen = Parcel::GetEightByteAlign(packLen); if (packLen != length || parcel.IsError()) { - LOGE("CommitHistorySync::RequestPacketDeSerialization : length error, input len = %lu, cac len = %llu", - length, packLen); + LOGE("CommitHistorySync::RequestPacketDeSerialization : length error, input len = %" PRIu32 + ", cac len = %" PRIu64, length, packLen); return -E_INVALID_ARGS; } CommitHistorySyncRequestPacket *packet = new (std::nothrow) CommitHistorySyncRequestPacket(); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp index 6eb4ee538fd22eb7a696cf56637925c27d62c1d5..ed1060c76c4ebf31f68429224ec5527a92497ccb 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp @@ -80,7 +80,7 @@ int Metadata::SaveTimeOffset(const DeviceID &deviceId, TimeOffset inValue) GetMetaDataValue(deviceId, metadata, true); metadata.timeOffset = inValue; metadata.lastUpdateTime = TimeHelper::GetSysCurrentTime(); - LOGD("Metadata::SaveTimeOffset = %lld dev %s", inValue, STR_MASK(deviceId)); + LOGD("Metadata::SaveTimeOffset = %" PRId64 " dev %s", inValue, STR_MASK(deviceId)); return SaveMetaDataValue(deviceId, metadata); } @@ -106,7 +106,7 @@ int Metadata::SaveLocalWaterMark(const DeviceID &deviceId, uint64_t inValue) std::lock_guard lockGuard(metadataLock_); GetMetaDataValue(deviceId, metadata, true); metadata.localWaterMark = inValue; - LOGD("Metadata::SaveLocalWaterMark = %llu", inValue); + LOGD("Metadata::SaveLocalWaterMark = %" PRIu64, inValue); return SaveMetaDataValue(deviceId, metadata); } @@ -124,7 +124,7 @@ int Metadata::SavePeerWaterMark(const DeviceID &deviceId, uint64_t inValue, bool std::lock_guard lockGuard(metadataLock_); GetMetaDataValue(deviceId, metadata, isNeedHash); metadata.peerWaterMark = inValue; - LOGD("Metadata::SavePeerWaterMark = %llu", inValue); + LOGD("Metadata::SavePeerWaterMark = %" PRIu64, inValue); return SaveMetaDataValue(deviceId, metadata); } @@ -137,7 +137,7 @@ int Metadata::SaveLocalTimeOffset(TimeOffset timeOffset) std::lock_guard lockGuard(localTimeOffsetLock_); localTimeOffset_ = timeOffset; - LOGD("Metadata::SaveLocalTimeOffset offset = %lld", timeOffset); + LOGD("Metadata::SaveLocalTimeOffset offset = %" PRId64, timeOffset); int errCode = SetMetadataToDb(localTimeOffsetValue, timeOffsetValue); if (errCode != E_OK) { LOGE("Metadata::SaveLocalTimeOffset SetMetadataToDb failed errCode:%d", errCode); @@ -284,7 +284,7 @@ int64_t Metadata::StringToLong(const std::vector &value) const { std::string valueString(value.begin(), value.end()); int64_t longData = std::strtoll(valueString.c_str(), nullptr, STR_TO_LL_BY_DEVALUE); - LOGD("Metadata::StringToLong longData = %lld", longData); + LOGD("Metadata::StringToLong longData = %" PRId64, longData); return longData; } @@ -365,7 +365,7 @@ uint64_t Metadata::GetRandTimeOffset() const // use a 16 bit rand data to make a rand timeoffset uint64_t randTimeOffset = (static_cast(randBytes[1]) << 8) | randBytes[0]; // 16 bit data, 8 is offset randTimeOffset = randTimeOffset * 1000 * 1000 * 10; // second, 1000 is scale - LOGD("[Metadata] GetRandTimeOffset %llu", randTimeOffset); + LOGD("[Metadata] GetRandTimeOffset %" PRIu64, randTimeOffset); return randTimeOffset; } @@ -514,10 +514,11 @@ int Metadata::SetDbCreateTime(const DeviceID &deviceId, uint64_t inValue, bool i metadata = metadataMap_[hashDeviceId]; if (metadata.dbCreateTime != 0 && metadata.dbCreateTime != inValue) { metadata.clearDeviceDataMark = REMOVE_DEVICE_DATA_MARK; - LOGI("Metadata::SetDbCreateTime,set cleardata mark,dev=%s,dbCreateTime=%llu", STR_MASK(deviceId), inValue); + LOGI("Metadata::SetDbCreateTime,set cleardata mark,dev=%s,dbCreateTime=%" PRIu64, + STR_MASK(deviceId), inValue); } if (metadata.dbCreateTime == 0) { - LOGI("Metadata::SetDbCreateTime,update dev=%s,dbCreateTime=%llu", STR_MASK(deviceId), inValue); + LOGI("Metadata::SetDbCreateTime,update dev=%s,dbCreateTime=%" PRIu64, STR_MASK(deviceId), inValue); } } metadata.dbCreateTime = inValue; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp index 662c6bb3fad8eb3af3500dfc927656c701a176be..9bc8c84f7d577b5dd5ba893b3ddcf160662bd547 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp @@ -279,7 +279,7 @@ int MultiVerDataSync::AckRecvCallback(MultiVerSyncTaskContext *context, const Me context->SetEntries(entries); context->SetEntriesIndex(0); context->SetEntriesSize(static_cast(entries.size())); - LOGD("MultiVerDataSync::AckRecvCallback src=%s{private}, entries num = %llu", + LOGD("MultiVerDataSync::AckRecvCallback src=%s{private}, entries num = %zu", context->GetDeviceId().c_str(), entries.size()); if (entries.size() > 0) { @@ -292,7 +292,7 @@ int MultiVerDataSync::AckRecvCallback(MultiVerSyncTaskContext *context, const Me context->SetValueSliceHashNodes(valueHashes); context->SetValueSlicesIndex(0); context->SetValueSlicesSize(valueHashes.size()); - LOGD("MultiVerDataSync::AckRecvCallback src=%s{private}, ValueSlicesSize num = %llu", + LOGD("MultiVerDataSync::AckRecvCallback src=%s{private}, ValueSlicesSize num = %zu", context->GetDeviceId().c_str(), valueHashes.size()); return errCode; } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp index 2235a8fc6f574630a05722573ceec0709412bfe9..1a9c5a9a5f42165d891766dd7964f487b0d9de78 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp @@ -305,7 +305,9 @@ int MultiVerSyncStateMachine::PrepareNextSyncTask() void MultiVerSyncStateMachine::SendSaveDataNotifyPacket(uint32_t sessionId, uint32_t sequenceId, uint32_t inMsgId) { - (void) sequenceId; + (void)sessionId; + (void)sequenceId; + (void)inMsgId; } void MultiVerSyncStateMachine::CommErrAbort() @@ -473,7 +475,7 @@ int MultiVerSyncStateMachine::OneCommitSyncFinish() // Due to time sync error, commit timestamp may bigger than currentLocalTime, we need to fix the timestamp TimeOffset timefixOffset = (commit.timestamp < currentLocalTime) ? 0 : (commit.timestamp - static_cast(currentLocalTime)); - LOGD("MultiVerSyncStateMachine::OneCommitSyncFinish src=%s, timefixOffset = %lld", + LOGD("MultiVerSyncStateMachine::OneCommitSyncFinish src=%s, timefixOffset = %" PRId64, STR_MASK(context_->GetDeviceId()), timefixOffset); commit.timestamp -= static_cast(timefixOffset); ChangeEntriesTimeStamp(entries, outOffset, timefixOffset); @@ -595,7 +597,7 @@ int MultiVerSyncStateMachine::SyncResponseTimeout(TimerId timerId) return info.timerId == timerId; }); if (iter == responseInfos_.end()) { - LOGW("[MultiVerSyncStateMachine][SyncResponseTimeout] Can't find sync response timerId %d", timerId); + LOGW("[MultiVerSyncStateMachine][SyncResponseTimeout] Can't find sync response timerId %" PRIu64, timerId); return E_OK; } sessionId = iter->sessionId; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp index f9ccc4ffa498e9ca92123a33848c9b33c548e28c..b958ee8f3c60c2af3ab00a74412a1166d274d7f0 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp @@ -94,8 +94,8 @@ void SingleVerDataMessageSchedule::ScheduleInfoHandle(bool isNeedHandleStatus, b ClearMsgMapWithNoLock(); expectedSequenceId_ = 1; } else { - LOGI("[DataMsgSchedule] DealMsg seqId=%u finishedPacketId=%llu ok,label=%s,dev=%s", expectedSequenceId_, - finishedPacketId_, label_.c_str(), STR_MASK(deviceId_)); + LOGI("[DataMsgSchedule] DealMsg seqId=%" PRIu32 " finishedPacketId=%" PRIu64 " ok,label=%s,dev=%s", + expectedSequenceId_, finishedPacketId_, label_.c_str(), STR_MASK(deviceId_)); expectedSequenceId_++; } } @@ -246,7 +246,7 @@ void SingleVerDataMessageSchedule::StartTimer(SingleVerSyncTaskContext *context) return; } timerId_ = timerId; - LOGD("[DataMsgSchedule] StartTimer,TimerId=%llu", timerId_); + LOGD("[DataMsgSchedule] StartTimer,TimerId=%" PRIu64, timerId_); } void SingleVerDataMessageSchedule::StopTimer() @@ -254,7 +254,7 @@ void SingleVerDataMessageSchedule::StopTimer() TimerId timerId; { std::lock_guard lock(lock_); - LOGD("[DataMsgSchedule] StopTimer,remove TimerId=%llu", timerId_); + LOGD("[DataMsgSchedule] StopTimer,remove TimerId=%" PRIu64, timerId_); if (timerId_ == 0) { return; } @@ -285,7 +285,7 @@ int SingleVerDataMessageSchedule::TimeOut(TimerId timerId) } { std::lock_guard lock(lock_); - LOGI("[DataMsgSchedule] timeout handling, stop timerId_[%llu]", timerId, timerId_); + LOGI("[DataMsgSchedule] timeout handling, stop timerId_[%" PRIu64 "]", timerId); if (timerId == timerId_) { ClearMsgMapWithNoLock(); timerId_ = 0; @@ -308,6 +308,8 @@ int SingleVerDataMessageSchedule::UpdateMsgMapIfNeed(Message *msg) uint32_t sequenceId = msg->GetSequenceId(); uint64_t packetId = packet->GetPacketId(); if (prevSessionId_ != 0 && sessionId == prevSessionId_) { + LOGD("[DataMsgSchedule] recv prev sessionId msg, drop msg, label=%s, dev=%s", label_.c_str(), + STR_MASK(deviceId_)); return -E_INVALID_ARGS; } if (sessionId != currentSessionId_) { @@ -322,6 +324,8 @@ int SingleVerDataMessageSchedule::UpdateMsgMapIfNeed(Message *msg) const auto *cachePacket = messageMap_[sequenceId]->GetObject(); if (cachePacket != nullptr) { if (packetId != 0 && packetId < cachePacket->GetPacketId()) { + LOGD("[DataMsgSchedule] drop msg packetId=%" PRIu64 ", cachePacketId=%" PRIu64 ", label=%s, dev=%s", + packetId, cachePacket->GetPacketId(), label_.c_str(), STR_MASK(deviceId_)); return -E_INVALID_ARGS; } } @@ -329,6 +333,8 @@ int SingleVerDataMessageSchedule::UpdateMsgMapIfNeed(Message *msg) messageMap_[sequenceId] = nullptr; } messageMap_[sequenceId] = msg; + LOGD("[DataMsgSchedule] put into msgMap seqId=%" PRIu32 ", packetId=%" PRIu64 ", label=%s, dev=%s", sequenceId, + packetId, label_.c_str(), STR_MASK(deviceId_)); return E_OK; } } \ No newline at end of file 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 69263d5651c0a41daadf253a2597cd101acc0649..0fbc3153f743b164fd71813427ca5454e71f9636 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 @@ -160,8 +160,8 @@ int SingleVerDataSync::TryContinueSync(SingleVerSyncTaskContext *context, const uint32_t sequenceId = message->GetSequenceId(); std::lock_guard lock(lock_); - LOGI("[DataSync] recv ack seqId=%d,packetId=%llu,winSize=%d,label=%s,dev=%s", sequenceId, packetId, windowSize_, - label_.c_str(), STR_MASK(deviceId_)); + LOGI("[DataSync] recv ack seqId=%" PRIu32 ",packetId=%" PRIu64 ",winSize=%d,label=%s,dev=%s", sequenceId, packetId, + windowSize_, label_.c_str(), STR_MASK(deviceId_)); if (sessionId != sessionId_) { LOGI("[DataSync] ignore ack,sessionId is different"); return E_OK; @@ -209,9 +209,10 @@ int SingleVerDataSync::ReSendData(SingleVerSyncTaskContext *context) } uint32_t sequenceId = reSendMap_.begin()->first; ReSendInfo reSendInfo = reSendMap_.begin()->second; - LOGI("[DataSync] ReSend mode=%d,start=%llu,end=%llu,delStart=%llu,delEnd=%llu,seqId=%d,packetId=%llu,windowsize=%d," - "label=%s,deviceId=%s", mode_, reSendInfo.start, reSendInfo.end, reSendInfo.deleteBeginTime, - reSendInfo.deleteEndTime, sequenceId, reSendInfo.packetId, windowSize_, label_.c_str(), STR_MASK(deviceId_)); + LOGI("[DataSync] ReSend mode=%d,start=%" PRIu64 ",end=%" PRIu64 ",delStart=%" PRIu64 ",delEnd=%" PRIu64 "," + "seqId=%" PRIu32 ",packetId=%" PRIu64 ",windowsize=%d,label=%s,deviceId=%s", mode_, reSendInfo.start, + reSendInfo.end, reSendInfo.deleteBeginTime, reSendInfo.deleteEndTime, sequenceId, reSendInfo.packetId, + windowSize_, label_.c_str(), STR_MASK(deviceId_)); DataSyncReSendInfo dataReSendInfo = {sessionId_, sequenceId, reSendInfo.start, reSendInfo.end, reSendInfo.deleteBeginTime, reSendInfo.deleteEndTime, reSendInfo.packetId}; return ReSend(context, dataReSendInfo); @@ -452,7 +453,7 @@ int SingleVerDataSync::SaveLocalWaterMark(SyncType syncType, const SingleVerSync } } if (isNeedUpdateMark) { - LOGD("label=%s,dev=%s,endTime=%llu", label_.c_str(), STR_MASK(GetDeviceId()), dataTimeRange.endTime); + LOGD("label=%s,dev=%s,endTime=%" PRIu64, label_.c_str(), STR_MASK(GetDeviceId()), dataTimeRange.endTime); errCode = metadata_->SetSendQueryWaterMark(queryId, deviceId, dataTimeRange.endTime); if (errCode != E_OK) { LOGE("[DataSync][SaveLocalWaterMark] save query metadata watermark failed,errCode=%d", errCode); @@ -460,7 +461,7 @@ int SingleVerDataSync::SaveLocalWaterMark(SyncType syncType, const SingleVerSync } } if (isNeedUpdateDeleteMark) { - LOGD("label=%s,dev=%s,deleteEndTime=%llu", label_.c_str(), STR_MASK(GetDeviceId()), + LOGD("label=%s,dev=%s,deleteEndTime=%" PRIu64, label_.c_str(), STR_MASK(GetDeviceId()), dataTimeRange.deleteEndTime); errCode = metadata_->SetSendDeleteSyncWaterMark(context->GetDeleteSyncId(), dataTimeRange.deleteEndTime); } @@ -610,10 +611,10 @@ void SingleVerDataSync::UpdateSendInfo(SyncTimeRange dataTimeRange, SingleVerSyn if (token == nullptr) { isAllDataHasSent_ = true; } - LOGI("[DataSync] mode=%d,start=%llu,end=%llu,deleteStart=%llu,deleteEnd=%llu,seqId=%d,packetId=%llu,window_size=%d," - "isAllSend=%d,label=%s,device=%s", mode_, reSendInfo.start, reSendInfo.end, reSendInfo.deleteBeginTime, - reSendInfo.deleteEndTime, maxSequenceIdHasSent_, reSendInfo.packetId, windowSize_, isAllDataHasSent_, - label_.c_str(), STR_MASK(deviceId_)); + LOGI("[DataSync] mode=%d,start=%" PRIu64 ",end=%" PRIu64 ",deleteStart=%" PRIu64 ",deleteEnd=%" PRIu64 "," + "seqId=%" PRIu32 ",packetId=%" PRIu64 ",window_size=%d,isAllSend=%d,label=%s,device=%s", mode_, + reSendInfo.start, reSendInfo.end, reSendInfo.deleteBeginTime, reSendInfo.deleteEndTime, maxSequenceIdHasSent_, + reSendInfo.packetId, windowSize_, isAllDataHasSent_, label_.c_str(), STR_MASK(deviceId_)); } void SingleVerDataSync::FillDataRequestPacket(DataRequestPacket *packet, SingleVerSyncTaskContext *context, @@ -659,9 +660,9 @@ void SingleVerDataSync::FillDataRequestPacket(DataRequestPacket *packet, SingleV context->GetQuery().HasOrderBy())) { packet->SetUpdateWaterMark(); } - LOGD("[DataSync] curType=%d,local=%llu,del=%llu,end=%llu,label=%s,dev=%s,queryId=%s,isCompress=%d", curType, - localMark, deleteMark, context->GetEndMark(), label_.c_str(), STR_MASK(GetDeviceId()), - STR_MASK(context->GetQuery().GetIdentify()), packet->IsCompressData()); + LOGD("[DataSync] curType=%d,local=%" PRIu64 ",del=%" PRIu64 ",end=%" PRIu64 ",label=%s,dev=%s,queryId=%s," + "isCompress=%d", static_cast(curType), localMark, deleteMark, context->GetEndMark(), label_.c_str(), + STR_MASK(GetDeviceId()), STR_MASK(context->GetQuery().GetIdentify()), packet->IsCompressData()); } int SingleVerDataSync::RequestStart(SingleVerSyncTaskContext *context, int mode) @@ -775,8 +776,9 @@ int SingleVerDataSync::PullRequestStart(SingleVerSyncTaskContext *context) packet->SetLastSequence(); SingleVerDataSyncUtils::SetPacketId(packet, context, version); - LOGD("[DataSync][Pull] curType=%d,local=%llu,del=%llu,end=%llu,peer=%llu,label=%s,dev=%s", syncType, localMark, - deleteMark, peerMark, endMark, label_.c_str(), STR_MASK(GetDeviceId())); + LOGD("[DataSync][Pull] curType=%d,local=%" PRIu64 ",del=%" PRIu64 ",end=%" PRIu64 ",peer=%" PRIu64 ",label=%s," + "dev=%s", static_cast(syncType), localMark, deleteMark, endMark, peerMark, label_.c_str(), + STR_MASK(GetDeviceId())); UpdateSendInfo(dataTime, context); return SendDataPacket(syncType, packet, context); } @@ -850,14 +852,14 @@ void SingleVerDataSync::UpdatePeerWaterMark(SyncType syncType, const std::string errCode = metadata_->SavePeerWaterMark(context->GetDeviceId(), peerWatermark, true); } else { if (peerWatermark != 0) { - LOGD("label=%s,dev=%s,endTime=%llu", label_.c_str(), STR_MASK(GetDeviceId()), peerWatermark); + LOGD("label=%s,dev=%s,endTime=%" PRIu64, label_.c_str(), STR_MASK(GetDeviceId()), peerWatermark); errCode = metadata_->SetRecvQueryWaterMark(queryId, context->GetDeviceId(), peerWatermark); if (errCode != E_OK) { LOGE("[DataSync][UpdatePeerWaterMark] save query peer water mark failed,errCode=%d", errCode); } } if (peerDeletedWatermark != 0) { - LOGD("label=%s,dev=%s,peerDeletedTime=%llu", + LOGD("label=%s,dev=%s,peerDeletedTime=%" PRIu64, label_.c_str(), STR_MASK(GetDeviceId()), peerDeletedWatermark); errCode = metadata_->SetRecvDeleteSyncWaterMark(context->GetDeleteSyncId(), peerDeletedWatermark); } @@ -941,9 +943,9 @@ int SingleVerDataSync::DataRequestRecv(SingleVerSyncTaskContext *context, const const DataRequestPacket *packet = message->GetObject(); const std::vector &data = packet->GetData(); SyncType curType = SyncOperation::GetSyncType(packet->GetMode()); - LOGI("[DataSync][DataRequestRecv] curType=%d,remote ver=%u,size=%d,errCode=%d,queryId=%s,Label=%s,dev=%s", curType, - packet->GetVersion(), data.size(), packet->GetSendCode(), STR_MASK(packet->GetQueryId()), label_.c_str(), - STR_MASK(GetDeviceId())); + LOGI("[DataSync][DataRequestRecv] curType=%d, remote ver=%" PRIu32 ", size=%zu, errCode=%d, queryId=%s," + " Label=%s, dev=%s", static_cast(curType), packet->GetVersion(), data.size(), packet->GetSendCode(), + STR_MASK(packet->GetQueryId()), label_.c_str(), STR_MASK(GetDeviceId())); context->SetReceiveWaterMarkErr(false); UpdateWaterMark isUpdateWaterMark; SyncTimeRange dataTime = SingleVerDataSyncUtils::GetRecvDataTimeRange(curType, data, isUpdateWaterMark); @@ -1115,7 +1117,8 @@ bool SingleVerDataSync::AckPacketIdCheck(const Message *message) if (reSendMap_.count(sequenceId) != 0) { uint64_t originalPacketId = reSendMap_[sequenceId].packetId; if (DataAckPacket::IsPacketIdValid(packetId) && packetId != originalPacketId) { - LOGE("[DataSync] packetId[%llu] is not match with original[%llu]", packetId, originalPacketId); + LOGE("[DataSync] packetId[%" PRIu64 "] is not match with original[%" PRIu64 "]", packetId, + originalPacketId); return false; } } @@ -1155,7 +1158,7 @@ int SingleVerDataSync::AckRecv(SingleVerSyncTaskContext *context, const Message if (recvCode == -E_SAVE_DATA_NOTIFY && data != 0) { // data only use low 32bit context->StartFeedDogForSync(static_cast(data), SyncDirectionFlag::RECEIVE); - LOGI("[DataSync][AckRecv] notify ResetWatchDog=%llu,label=%s,dev=%s", data, label_.c_str(), + LOGI("[DataSync][AckRecv] notify ResetWatchDog=%" PRIu64 ",label=%s,dev=%s", data, label_.c_str(), STR_MASK(GetDeviceId())); } @@ -1223,8 +1226,8 @@ void SingleVerDataSync::GetPullEndWatermark(const SingleVerSyncTaskContext *cont TimeOffset offset; metadata_->GetTimeOffset(context->GetDeviceId(), offset); pullEndWatermark = endMark - static_cast(offset); - LOGD("[DataSync][PullEndWatermark] packetEndMark=%llu,offset=%llu,endWaterMark=%llu,label=%s,dev=%s", - endMark, offset, pullEndWatermark, label_.c_str(), STR_MASK(GetDeviceId())); + LOGD("[DataSync][PullEndWatermark] packetEndMark=%" PRIu64 ",offset=%" PRId64 ",endWaterMark=%" PRIu64 "," + "label=%s,dev=%s", endMark, offset, pullEndWatermark, label_.c_str(), STR_MASK(GetDeviceId())); } } @@ -1240,8 +1243,8 @@ int SingleVerDataSync::DealWaterMarkException(SingleVerSyncTaskContext *context, } deletedWaterMark = reserved[ACK_PACKET_RESERVED_INDEX_DELETE_WATER_MARK]; } - LOGI("[DataSync][WaterMarkException] AckRecv water error, mark=%llu,deleteMark=%llu,label=%s,dev=%s", ackWaterMark, - deletedWaterMark, label_.c_str(), STR_MASK(GetDeviceId())); + LOGI("[DataSync][WaterMarkException] AckRecv water error, mark=%" PRIu64 ",deleteMark=%" PRIu64 "," + "label=%s,dev=%s", ackWaterMark, deletedWaterMark, label_.c_str(), STR_MASK(GetDeviceId())); int errCode = SaveLocalWaterMark(curType, context, {0, 0, ackWaterMark, deletedWaterMark}); if (errCode != E_OK) { @@ -1324,7 +1327,8 @@ void SingleVerDataSync::SendResetWatchDogPacket(SingleVerSyncTaskContext *contex LOGE("[DataSync][ResetWatchDog] Send packet failed,errcode=%d,label=%s,dev=%s", errCode, label_.c_str(), STR_MASK(GetDeviceId())); } else { - LOGI("[DataSync][ResetWatchDog] data = %llu,label=%s,dev=%s", data, label_.c_str(), STR_MASK(GetDeviceId())); + LOGI("[DataSync][ResetWatchDog] data = %" PRIu64 ",label=%s,dev=%s", data, label_.c_str(), + STR_MASK(GetDeviceId())); } } @@ -1456,14 +1460,15 @@ bool SingleVerDataSync::WaterMarkErrHandle(SyncType syncType, SingleVerSyncTaskC GetPeerDeleteSyncWaterMark(context->GetDeleteSyncId(), deletedMark); } if (syncType != SyncType::QUERY_SYNC_TYPE && packetLocalMark > peerMark) { - LOGI("[DataSync][DataRequestRecv] packetLocalMark=%llu,current=%llu", packetLocalMark, peerMark); + LOGI("[DataSync][DataRequestRecv] packetLocalMark=%" PRIu64 ",current=%" PRIu64, packetLocalMark, peerMark); context->SetReceiveWaterMarkErr(true); SendDataAck(context, message, LOCAL_WATER_MARK_NOT_INIT, 0); return true; } if (syncType == SyncType::QUERY_SYNC_TYPE && (packetLocalMark > peerMark || packetDeletedMark > deletedMark)) { - LOGI("[DataSync][DataRequestRecv] packetDeletedMark=%llu,deletedMark=%llu,packetLocalMark=%llu,peerMark=%llu", - packetDeletedMark, deletedMark, packetLocalMark, peerMark); + LOGI("[DataSync][DataRequestRecv] packetDeletedMark=%" PRIu64 ",deletedMark=%" PRIu64 "," + "packetLocalMark=%" PRIu64 ",peerMark=%" PRIu64, packetDeletedMark, deletedMark, packetLocalMark, + peerMark); context->SetReceiveWaterMarkErr(true); SendDataAck(context, message, LOCAL_WATER_MARK_NOT_INIT, 0); return true; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp index 7e72e4aaa90b5f207eed4c1de05576715f2609c8..5647815de474e7ae6afa74e37e9adc6d2f3c53cc 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_sync_utils.cpp @@ -106,7 +106,7 @@ void SingleVerDataSyncUtils::TransDbDataItemToSendDataItem(const std::string &lo } outData[i]->SetOrigDevice(outData[i]->GetOrigDevice().empty() ? localHashName : outData[i]->GetOrigDevice()); if (i == 0 || i == (outData.size() - 1)) { - LOGD("[DataSync][TransToSendItem] printData packet=%d,timeStamp=%llu,flag=%llu", i, + LOGD("[DataSync][TransToSendItem] printData packet=%zu,timeStamp=%" PRIu64 ",flag=%" PRIu64, i, outData[i]->GetTimestamp(), outData[i]->GetFlag()); } } 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 de0c054678a79ec59f67b694d766239a47aa2f6e..d0e52aa8ba6896068a8fefdfe15991cdabf5e05f 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 @@ -149,7 +149,7 @@ void SingleVerKVSyncer::RemoteDataChanged(const std::string &device) LOGI("no need to trigger auto subscribe"); return; } - LOGI("[SingleVerKVSyncer] trigger local subscribe sync, queryNums=%d", syncQueries.size()); + LOGI("[SingleVerKVSyncer] trigger local subscribe sync, queryNums=%zu", syncQueries.size()); for (const auto &query : syncQueries) { TriggerSubscribe(device, query); } @@ -272,8 +272,8 @@ void SingleVerKVSyncer::TriggerSubQuerySync(const std::vector &devi if (lastTimestamp < queryWaterMark || lastTimestamp == 0) { continue; } - LOGD("[Syncer] lastTime=%llu vs WaterMark=%llu,trigger queryId=%s,dev=%s", lastTimestamp, queryWaterMark, - STR_MASK(queryId), STR_MASK(device)); + LOGD("[Syncer] lastTime=%" PRIu64 " vs WaterMark=%" PRIu64 ",trigger queryId=%s,dev=%s", lastTimestamp, + queryWaterMark, STR_MASK(queryId), STR_MASK(device)); InternalSyncParma param; std::vector targetDevices; targetDevices.push_back(device); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp index c5c6bf99311237edf455d4be54a0fff1a10cd4ef..a6fc97b09ebbd855ffd39613ea0d94c2df125a5c 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_serialize_manager.cpp @@ -453,7 +453,8 @@ int SingleVerSerializeManager::DataPacketSyncerPartDeSerialization(Parcel &parce } packLen = Parcel::GetEightByteAlign(packLen); if (parcel.IsError()) { - LOGE("[DataSync][DataPacketDeSerialization] deserialize failed! input len=%lu,packLen=%lu", length, packLen); + LOGE("[DataSync][DataPacketDeSerialization] deserialize failed! input len=%" PRIu32 ",packLen=%" PRIu32, + length, packLen); return -E_LENGTH_ERROR; } parcel.EightByteAlign(); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp index b961ddbaa74e93e0ef8dd2f01ddf1d38da64320d..3f85cb9edbbdca1ad7eeee131b960483d6013b98 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_engine.cpp @@ -75,7 +75,7 @@ int SingleVerSyncEngine::StartAutoSubscribeTimer() return errCode; } subscribeTimerId_ = timerId; - LOGI("[SingleSyncEngine] start auto subscribe timerId=%d finished", timerId); + LOGI("[SingleSyncEngine] start auto subscribe timerId=%" PRIu64 " finished", timerId); return errCode; } @@ -85,7 +85,7 @@ void SingleVerSyncEngine::StopAutoSubscribeTimer() if (subscribeTimerId_ == 0) { return; } - LOGI("[SingleSyncEngine] stop auto subscribe timerId=%d finished", subscribeTimerId_); + LOGI("[SingleSyncEngine] stop auto subscribe timerId=%" PRIu64 " finished", subscribeTimerId_); RuntimeContext::GetInstance()->RemoveTimer(subscribeTimerId_); subscribeTimerId_ = 0; } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp index 0e72373b7fccd7b8948b91540773de9e7a040f4e..c0bb1aa6d815314a6056a9eb2a1bebb4643b2a33 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp @@ -322,7 +322,7 @@ void SingleVerSyncStateMachine::InitStateSwitchTable(uint32_t version, table.version = version; for (const auto &stateSwitch : switchTable) { if (stateSwitch.size() <= OUTPUT_STATE_INDEX) { - LOGE("[StateMachine][InitSwitchTable] stateSwitch size err,size=%llu", stateSwitch.size()); + LOGE("[StateMachine][InitSwitchTable] stateSwitch size err,size=%zu", stateSwitch.size()); return; } if (table.switchTable.count(stateSwitch[CURRENT_STATE_INDEX]) == 0) { @@ -689,7 +689,7 @@ void SingleVerSyncStateMachine::NeedAbilitySyncHandle() // mean the version num has been reset when syncing data, // there should not clear the new version cache again. if (currentRemoteVersionId_ == context_->GetRemoteSoftwareVersionId()) { - LOGI("[StateMachine] set remote version 0, currentRemoteVersionId_ = %llu", currentRemoteVersionId_); + LOGI("[StateMachine] set remote version 0, currentRemoteVersionId_ = %" PRIu64, currentRemoteVersionId_); context_->SetRemoteSoftwareVersion(0); } else { currentRemoteVersionId_ = context_->GetRemoteSoftwareVersionId(); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp index 456a03d709fe54283713385e03d255555ac13f95..2f6a668624361ae7d54204f64d2db33a07bc5e7f 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp @@ -158,7 +158,7 @@ void SingleVerSyncTaskContext::ReleaseContinueToken() int SingleVerSyncTaskContext::PopResponseTarget(SingleVerSyncTarget &target) { std::lock_guard lock(targetQueueLock_); - LOGD("[SingleVerSyncTaskContext] GetFrontExtWaterMarak size = %d", responseTargetQueue_.size()); + LOGD("[SingleVerSyncTaskContext] GetFrontExtWaterMarak size = %zu", responseTargetQueue_.size()); if (!responseTargetQueue_.empty()) { ISyncTarget *tmpTarget = responseTargetQueue_.front(); responseTargetQueue_.pop_front(); @@ -240,7 +240,7 @@ void SingleVerSyncTaskContext::ClearAllSyncTask() std::list targetQueue; { std::lock_guard lock(targetQueueLock_); - LOGI("[SingleVerSyncTaskContext] request taskcount=%d,responsecount=%d", requestTargetQueue_.size(), + LOGI("[SingleVerSyncTaskContext] request taskcount=%zu, responsecount=%zu", requestTargetQueue_.size(), responseTargetQueue_.size()); while (!requestTargetQueue_.empty()) { ISyncTarget *tmpTarget = nullptr; @@ -513,7 +513,7 @@ bool SingleVerSyncTaskContext::IsCurrentSyncTaskCanBeSkipped() const return false; } if (localWaterMark > maxTimeStampInDb) { - LOGI("skip current push task, deviceId_ = %s, localWaterMark = %llu, maxTimeStampInDb = %llu", + LOGI("skip current push task, deviceId_ = %s, localWaterMark = %" PRIu64 ", maxTimeStampInDb = %" PRIu64, STR_MASK(deviceId_), localWaterMark, maxTimeStampInDb); return true; } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/subscribe_manager.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/subscribe_manager.cpp index ccff66498026e2c381100216ec9da985dfc974ec..572cd91544b37928bfd22a50e93468ab002ed154 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/subscribe_manager.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/subscribe_manager.cpp @@ -97,7 +97,7 @@ void SubscribeManager::DeleteRemoteSubscribeQuery(const std::string &device, con void SubscribeManager::PutLocalUnFiniedSubQueries(const std::string &device, std::vector &subscribeQueries) { - LOGI("[SubscribeManager] put local unfinished subscribe queries, nums=%d", subscribeQueries.size()); + LOGI("[SubscribeManager] put local unfinished subscribe queries, nums=%zu", subscribeQueries.size()); std::unique_lock lockGuard(localSubscribeMapLock_); if (subscribeQueries.size() == 0) { unFinishedLocalAutoSubMap_.erase(device); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/sync_engine.cpp index 8f5ac620a6e2802cb0545aaf3f53257a3d79f3d3..5a932f3b7044c95564b17d857031e6c7841e1ac5 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 @@ -249,7 +250,7 @@ int SyncEngine::InitComunicator(const ISyncInterface *syncInterface) false); if (isSyncDualTupleMode) { std::vector dualTuplelabel = syncInterface->GetDualTupleIdentifier(); - LOGI("[SyncEngine] dual tuple mode, original identifier=%0.6s, target identifier=%0.6s", VEC_TO_STR(label), + LOGI("[SyncEngine] dual tuple mode, original identifier=%.6s, target identifier=%.6s", VEC_TO_STR(label), VEC_TO_STR(dualTuplelabel)); communicator_ = communicatorAggregator->AllocCommunicator(dualTuplelabel, errCode); } else { @@ -520,7 +521,7 @@ void SyncEngine::PutMsgIntoQueue(const std::string &targetDev, Message *inMsg, i inMsg->SetTarget(targetDev); msgQueue_.push_back(inMsg); queueCacheSize_ += msgSize; - LOGE("[SyncEngine] The quantity of executing threads is beyond maximum. msgQueueSize = %d", msgQueue_.size()); + LOGE("[SyncEngine] The quantity of executing threads is beyond maximum. msgQueueSize = %zu", msgQueue_.size()); } int SyncEngine::GetMsgSize(const Message *inMsg) const diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/time_helper.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/time_helper.cpp index a0374f7be001036709cade2f205fdf924f2fb819..2e7727853b0a8eca88754b52afe0c1e0b50b946a 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/time_helper.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/time_helper.cpp @@ -75,7 +75,7 @@ int TimeHelper::Initialize(const ISyncInterface *inStorage, std::shared_ptr(maxItemTime - currentSysTime + MS_TO_100_NS); // 1ms int errCode = SaveLocalTimeOffset(localTimeOffset); if (errCode != E_OK) { - LOGE("[TimeHelper] save local time offset faield,err=%d", errCode); + LOGE("[TimeHelper] save local time offset failed,err=%d", errCode); return errCode; } } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.cpp index 92b7d16257b021b9bcdf28abec550e248591d23d..f0d8655275c16d8daf539232dcec09bc02f01524 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/time_sync.cpp @@ -197,7 +197,7 @@ int TimeSync::SyncStart(const CommErrHandler &handler, uint32_t sessionId) TimeStamp startTime = timeHelper_->GetTime(); packet.SetSourceTimeBegin(startTime); // send timeSync request - LOGD("[TimeSync] startTime = %llu, dev = %s{private}", startTime, deviceId_.c_str()); + LOGD("[TimeSync] startTime = %" PRIu64 ", dev = %s{private}", startTime, deviceId_.c_str()); Message *message = new (std::nothrow) Message(TIME_SYNC_MESSAGE); if (message == nullptr) { @@ -341,7 +341,8 @@ int TimeSync::AckRecv(const Message *message, uint32_t targetSessionId) } // calculate timeoffset of two devices TimeOffset offset = CalculateTimeOffset(packetData); - LOGD("TimeSync::AckRecv, dev = %s{private}, sEnd = %llu, tEnd = %llu, sBegin = %llu, tBegin = %llu, offset = %lld", + LOGD("TimeSync::AckRecv, dev = %s{private}, sEnd = %" PRIu64 ", tEnd = %" PRIu64 ", sBegin = %" PRIu64 + ", tBegin = %" PRIu64 ", offset = %" PRId64, deviceId_.c_str(), packetData.GetSourceTimeEnd(), packetData.GetTargetTimeEnd(), @@ -378,9 +379,9 @@ int TimeSync::RequestRecv(const Message *message) ackPacket.SetTargetTimeBegin(targetTimeBegin); TimeStamp targetTimeEnd = timeHelper_->GetTime(); ackPacket.SetTargetTimeEnd(targetTimeEnd); - LOGD("TimeSync::RequestRecv, dev = %s{private}, sTimeEnd = %llu, tTimeEnd = %llu, sbegin = %llu, tbegin = %llu", - deviceId_.c_str(), ackPacket.GetSourceTimeEnd(), ackPacket.GetTargetTimeEnd(), ackPacket.GetSourceTimeBegin(), - ackPacket.GetTargetTimeBegin()); + LOGD("TimeSync::RequestRecv, dev = %s{private}, sTimeEnd = %" PRIu64 ", tTimeEnd = %" PRIu64 ", sbegin = %" PRIu64 + ", tbegin = %" PRIu64, deviceId_.c_str(), ackPacket.GetSourceTimeEnd(), ackPacket.GetTargetTimeEnd(), + ackPacket.GetSourceTimeBegin(), ackPacket.GetTargetTimeBegin()); if (ackPacket.GetSourceTimeBegin() > TimeHelper::MAX_VALID_TIME) { LOGD("[TimeSync][RequestRecv] Time valid check failed."); return -E_INVALID_TIME; @@ -434,8 +435,8 @@ TimeOffset TimeSync::CalculateTimeOffset(const TimeSyncPacket &timeSyncInfo) TimeOffset offset2 = static_cast(timeSyncInfo.GetTargetTimeEnd() + (roundTrip / TRIP_DIV_HALF) - timeSyncInfo.GetSourceTimeEnd()); TimeOffset offset = (offset1 / TRIP_DIV_HALF) + (offset2 / TRIP_DIV_HALF); - LOGD("TimeSync::CalculateTimeOffset roundTrip= %lld, offset1 = %lld, offset2 = %lld, offset = %lld", - roundTrip, offset1, offset2, offset); + LOGD("TimeSync::CalculateTimeOffset roundTrip= %" PRId64 ", offset1 = %" PRId64 ", offset2 = %" PRId64 + ", offset = %" PRId64, roundTrip, offset1, offset2, offset); return offset; } @@ -499,7 +500,7 @@ int TimeSync::GetTimeOffset(TimeOffset &outOffset, uint32_t timeout, uint32_t se } CommErrHandler handler = std::bind(&TimeSync::CommErrHandlerFunc, std::placeholders::_1, this); int errCode = SyncStart(handler, sessionId); - LOGD("TimeSync::GetTimeOffset start, current time = %llu, errCode = %d,timeout = %u ms", + LOGD("TimeSync::GetTimeOffset start, current time = %" PRIu64 ", errCode = %d, timeout = %" PRIu32 " ms", TimeHelper::GetSysCurrentTime(), errCode, timeout); std::unique_lock lock(cvLock_); if (errCode != E_OK || !conditionVar_.wait_for(lock, std::chrono::milliseconds(timeout), diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/value_slice_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/value_slice_sync.cpp index 8946b09c7d70127eec78514223f0e77ebe3da931..6b19fa333dc4f18d8a635ed3dfe9786cee98a9a4 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/value_slice_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/value_slice_sync.cpp @@ -462,7 +462,8 @@ int ValueSliceSync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t len // valueSlice DeSerialization packLen += parcel.ReadVectorChar(valueSlice); if (packLen != length || parcel.IsError()) { - LOGE("ValueSliceSync::AckPacketSerialization data error, packLen = %lu, length = %lu", packLen, length); + LOGE("ValueSliceSync::AckPacketSerialization data error, packLen = %" PRIu32 ", length = %" PRIu32, + packLen, length); return -E_INVALID_ARGS; } ValueSlicePacket *packet = new (std::nothrow) ValueSlicePacket(); 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/communicator/distributeddb_communicator_common.h b/services/distributeddataservice/libs/distributeddb/test/unittest/common/communicator/distributeddb_communicator_common.h index 59e08f15eed8d41ff3159423921a7c53f66ff0ed..04f9c5d2d95ad10dace644123100cd50636957eb 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/communicator/distributeddb_communicator_common.h +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/communicator/distributeddb_communicator_common.h @@ -101,7 +101,10 @@ public: for (uint8_t i = 0; i < BUFF_LEN; i++) { info.userId[i] = localDbProperty_.userId[i]; } - memcpy_s(data, totalLen, &info, sizeof(ExtendHeadInfo)); + auto errCode = memcpy_s(data, totalLen, &info, sizeof(ExtendHeadInfo)); + if (errCode != EOK) { + return DistributedDB::DB_ERROR; + } return DistributedDB::OK; }; static constexpr int MAGIC_NUM = 0xF2; diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_database_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_database_test.cpp index bc2d8abbf29549d6dfa78225f6b85a382dfbddb0..95b076c2475786cd7ed93a0e9c0764075d60619f 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_database_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_database_test.cpp @@ -555,7 +555,6 @@ HWTEST_F(DistributedDBInterfacesDatabaseTest, GetKvStore003, TestSize.Level1) * @tc.expected: step1. Returns a null kvstore and error code is not OK. */ std::shared_ptr g_adapter = std::make_shared(); - EXPECT_TRUE(g_adapter != nullptr); RuntimeContext::GetInstance()->SetProcessSystemApiAdapter(g_adapter); KvStoreNbDelegate::Option option = {true, false, false}; int abnormalNum = -100; diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_index_unit_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_index_unit_test.cpp index 88935b39e64f8aaf7a5612d785d9a95ff608398e..895eb2f27652ec1d8fe988037ff480b41fc03c2c 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_index_unit_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_index_unit_test.cpp @@ -73,7 +73,7 @@ namespace { int CallbackReturnCount(void *data, int argc, char **argv, char **azColName) { if (argc == 1) { - int count = atoi(*(argv)); + int count = strtol(*(argv), nullptr, 10); // 10: decimal if (data != nullptr) { int *mid = static_cast(data); *mid = count; 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/storage/distributeddb_storage_single_ver_upgrade_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_upgrade_test.cpp index 55a31af7e92ac63725e91e7b9dd8c60dd0451984..5d4e4c8745610b4b57e7696ae00e38eed834342e 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_upgrade_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_upgrade_test.cpp @@ -287,7 +287,6 @@ void DistributedDBStorageSingleVerUpgradeTest::SetUpTestCase(void) int errCode = g_passwd.SetValue(passwdBuffer1.data(), passwdBuffer1.size()); ASSERT_EQ(errCode, CipherPassword::ErrorCode::OK); g_adapter = std::make_shared(); - EXPECT_TRUE(g_adapter != nullptr); RuntimeContext::GetInstance()->SetProcessSystemApiAdapter(g_adapter); g_maindbPath = g_testDir + "/" + identifier + "/" + DBConstant::SINGLE_SUB_DIR + "/" + DBConstant::MAINDB_DIR + "/" + DBConstant::SINGLE_VER_DATA_STORE + DBConstant::SQLITE_DB_EXTENSION; diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_subscribe_query_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_subscribe_query_test.cpp index c44b497b6cee385ed63e5bf7fedd7ed40c18f322..cb70d93b6b1346042dbe0dbd09b30c2420999e57 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_subscribe_query_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_subscribe_query_test.cpp @@ -144,7 +144,7 @@ std::string FbfFileToSchemaString(const std::string &fileName) } auto size = is.tellg(); - LOGE("file size %d", size); + LOGE("file size %u", static_cast(size)); std::string schema(size, '\0'); is.seekg(0); if (is.read(&schema[0], size)) { diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_transaction_data_test.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_transaction_data_test.cpp index f595b4d2f4621f408a42dd63054447aff1ef9d7b..4c19de1d0a92a4cbb2e50215ffd6d8d8c4bd96d0 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_transaction_data_test.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_transaction_data_test.cpp @@ -1336,7 +1336,7 @@ HWTEST_F(DistributedDBStorageTransactionDataTest, CommitTimestamp001, TestSize.L // Tobe compare the timestamp. CommitID commitId; TimeStamp commitTimestamp = GetCommitTimestamp(commitId); - LOGD("TimeRecord:%llu, TimeCommit:%llu", *(timeSet.begin()), commitTimestamp); + LOGD("TimeRecord:%" PRIu64 ", TimeCommit:%" PRIu64, *(timeSet.begin()), commitTimestamp); ASSERT_EQ(*(timeSet.begin()), commitTimestamp); ASSERT_NE(commitTimestamp, 0UL); @@ -1449,7 +1449,7 @@ HWTEST_F(DistributedDBStorageTransactionDataTest, CommitTimestamp002, TestSize.L */ TimeStamp stampSecond = GetCommitTimestamp(commitId); ASSERT_NE(stampSecond, 0UL); // non-zero - LOGD("TimeFirst:%llu, TimeSecond:%llu", stampFirst, stampSecond); + LOGD("TimeFirst:%" PRIu64 ", TimeSecond:%" PRIu64, stampFirst, stampSecond); ASSERT_GT(stampSecond, stampFirst); } static void ReleaseKvEntries(std::vector &entries) @@ -1502,7 +1502,7 @@ HWTEST_F(DistributedDBStorageTransactionDataTest, CommitTimestamp003, TestSize.L * @tc.steps: expected. the timestamp of the sync commit is equal to the timestamp of the data record. */ TimeStamp commitTimestamp = GetCommitTimestamp(commit.commitId); - LOGD("TimeRecord:%llu, TimeCommit:%llu", timestamp, commitTimestamp); + LOGD("TimeRecord:%" PRIu64 ", TimeCommit:%" PRIu64, timestamp, commitTimestamp); ASSERT_EQ(timestamp, commitTimestamp); ASSERT_NE(commitTimestamp, 0UL); } 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..199e275857a5a363ddb2e438a8666d9a2b31e019 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 @@ -92,7 +92,6 @@ void DistributedDBSingleVerP2PSyncCheckTest::SetUpTestCase(void) RuntimeContext::GetInstance()->SetCommunicatorAggregator(g_communicatorAggregator); std::shared_ptr g_adapter = std::make_shared(); - EXPECT_TRUE(g_adapter != nullptr); RuntimeContext::GetInstance()->SetProcessSystemApiAdapter(g_adapter); } @@ -526,7 +525,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 +1001,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/libs/distributeddb/test/unittest/common/syncer/kv_virtual_device.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/kv_virtual_device.cpp index 1c32515947a2a5c0d98c0093a0e88b966ba6907e..eef31ab39a9cbde527de9949f0715b6c8aac0a9a 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/kv_virtual_device.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/kv_virtual_device.cpp @@ -41,7 +41,7 @@ int KvVirtualDevice::GetData(const Key &key, Value &value) int KvVirtualDevice::PutData(const Key &key, const Value &value, const TimeStamp &time, int flag) { VirtualSingleVerSyncDBInterface *syncAble = static_cast(storage_); - LOGI("dev %s put data time %llu", deviceId_.c_str(), time); + LOGI("dev %s put data time %" PRIu64, deviceId_.c_str(), time); return syncAble->PutData(key, value, time, flag); } diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_relational_ver_sync_db_interface.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_relational_ver_sync_db_interface.cpp index cd9a0fa63b1f2bfeb03a0f17ce383e06545d68eb..db0cf78ed885e8a54abe78281974efda1b0e0759 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_relational_ver_sync_db_interface.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_relational_ver_sync_db_interface.cpp @@ -48,7 +48,7 @@ namespace { } entries.clear(); } - LOGD("[GetEntriesFromItems] size:%d", dataItems.size()); + LOGD("[GetEntriesFromItems] size:%zu", dataItems.size()); return errCode; } @@ -63,7 +63,7 @@ namespace { int VirtualRelationalVerSyncDBInterface::PutSyncDataWithQuery(const QueryObject &object, const std::vector &entries, const std::string &deviceName) { - LOGD("[PutSyncData] size %d", entries.size()); + LOGD("[PutSyncData] size %zu", entries.size()); std::vector dataItems; for (auto itemEntry : entries) { auto *entry = static_cast(itemEntry); @@ -95,7 +95,7 @@ int VirtualRelationalVerSyncDBInterface::PutSyncDataWithQuery(const QueryObject break; } DataValue dataValue = std::move(optItem); - LOGD("type:%d", optItem.GetType()); + LOGD("type:%d", static_cast(optItem.GetType())); virtualRowData.objectData.PutDataValue(localFieldInfo_[index].GetFieldName(), dataValue); index++; } @@ -223,7 +223,7 @@ void VirtualRelationalVerSyncDBInterface::GetMaxTimeStamp(TimeStamp &stamp) cons } } } - LOGD("VirtualSingleVerSyncDBInterface::GetMaxTimeStamp time = %llu", stamp); + LOGD("VirtualSingleVerSyncDBInterface::GetMaxTimeStamp time = %" PRIu64, stamp); } int VirtualRelationalVerSyncDBInterface::GetMetaData(const Key &key, Value &value) const @@ -269,7 +269,7 @@ int VirtualRelationalVerSyncDBInterface::GetAllMetaKeys(std::vector &keys) for (auto &iter : metadata_) { keys.push_back(iter.first); } - LOGD("GetAllMetaKeys size %d", keys.size()); + LOGD("GetAllMetaKeys size %zu", keys.size()); return E_OK; } diff --git a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_single_ver_sync_db_Interface.cpp b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_single_ver_sync_db_Interface.cpp index b3aded37097de1599f4d670253641491ece60981..9c7139d9da8a0c540c915d8c2242126cf5dd9b7a 100644 --- a/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_single_ver_sync_db_Interface.cpp +++ b/services/distributeddataservice/libs/distributeddb/test/unittest/common/syncer/virtual_single_ver_sync_db_Interface.cpp @@ -108,7 +108,7 @@ int VirtualSingleVerSyncDBInterface::GetAllMetaKeys(std::vector &keys) cons for (auto iter = metadata_.begin(); iter != metadata_.end(); ++iter) { keys.push_back(iter->first); } - LOGD("GetAllMetaKeys size %d", keys.size()); + LOGD("GetAllMetaKeys size %zu", keys.size()); return E_OK; } @@ -162,7 +162,7 @@ void VirtualSingleVerSyncDBInterface::GetMaxTimeStamp(TimeStamp& stamp) const stamp = iter->writeTimeStamp; } } - LOGD("VirtualSingleVerSyncDBInterface::GetMaxTimeStamp time = %llu", stamp); + LOGD("VirtualSingleVerSyncDBInterface::GetMaxTimeStamp time = %" PRIu64, stamp); } int VirtualSingleVerSyncDBInterface::RemoveDeviceData(const std::string &deviceName, bool isNeedNotify) @@ -219,7 +219,7 @@ int VirtualSingleVerSyncDBInterface::GetSyncData(TimeStamp begin, TimeStamp end, } } continueStmtToken = nullptr; - LOGD("dataItems size %d", dataItems.size()); + LOGD("dataItems size %zu", dataItems.size()); return E_OK; } @@ -246,7 +246,8 @@ int VirtualSingleVerSyncDBInterface::PutSyncData(std::vector& d [iter](VirtualDataItem item) { return item.key == iter->key; }); if ((dbDataIter != dbData_.end()) && (dbDataIter->writeTimeStamp < iter->writeTimeStamp)) { // if has conflict, compare writeTimeStamp - LOGI("conflict data time local %llu, remote %llu", dbDataIter->writeTimeStamp, iter->writeTimeStamp); + LOGI("conflict data time local %" PRIu64 ", remote %" PRIu64, dbDataIter->writeTimeStamp, + iter->writeTimeStamp); dbDataIter->key = iter->key; dbDataIter->value = iter->value; dbDataIter->timeStamp = iter->timeStamp; @@ -254,7 +255,7 @@ int VirtualSingleVerSyncDBInterface::PutSyncData(std::vector& d dbDataIter->flag = iter->flag; dbDataIter->isLocal = false; } else { - LOGI("PutSyncData, use remote data %llu", iter->timeStamp); + LOGI("PutSyncData, use remote data %" PRIu64, iter->timeStamp); VirtualDataItem dataItem; dataItem.key = iter->key; dataItem.value = iter->value; @@ -333,7 +334,7 @@ int VirtualSingleVerSyncDBInterface::GetSyncData(QueryObject &query, const SyncT } } - LOGD("dataItems size %d", dataItems.size()); + LOGD("dataItems size %zu", dataItems.size()); return GetEntriesFromItems(entries, dataItems); } 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..cf58ef226d3c2e428b8438b6cecf9a2ace5fbb18 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)); } @@ -1100,7 +1100,7 @@ void MoveCursor(KvStoreResultSet &resultSet, const vector &entriesBatch) { int currentPosition = CURSOR_POSITION_NEGATIVE1; Entry entry; - bool result; + bool result = false; for (int position = CURSOR_POSITION_NEGATIVE1; position < TEN_RECORDS; ++position) { result = resultSet.MoveToNext(); if (position < (TEN_RECORDS - CURSOR_POSITION_1)) {