diff --git a/base/include/parcel.h b/base/include/parcel.h index 881b39e0dcbf8883451ae4b714d5e4088ca08e31..93de8257fe22a1b787fa7feb1d3adb9ea2505d16 100644 --- a/base/include/parcel.h +++ b/base/include/parcel.h @@ -52,7 +52,7 @@ public: inline void ClearBehavior(BehaviorFlag b) const { - behavior_ &= ~(static_cast(b)); + behavior_ &= static_cast(~b); } inline bool TestBehavior(BehaviorFlag b) const @@ -320,7 +320,7 @@ private: inline size_t GetPadSize(size_t size) { - const int SIZE_OFFSET = 3; + const size_t SIZE_OFFSET = 3; return (((size + SIZE_OFFSET) & (~SIZE_OFFSET)) - size); } diff --git a/base/include/thread_pool.h b/base/include/thread_pool.h index 66c7907e022bacb4b2defd8a3fe4851df726cc3a..9cb536a54bb1aa310d78e3e8ed5a294dbde072cd 100644 --- a/base/include/thread_pool.h +++ b/base/include/thread_pool.h @@ -42,7 +42,7 @@ public: uint32_t Start(int threadsNum); void Stop(); void AddTask(const Task& f); - void SetMaxTaskNum(int maxSize) { maxTaskNum_ = maxSize; } + void SetMaxTaskNum(size_t maxSize) { maxTaskNum_ = maxSize; } // for testability size_t GetMaxTaskNum() const { return maxTaskNum_; } diff --git a/base/src/event_demultiplexer.cpp b/base/src/event_demultiplexer.cpp index fb8542a03962ee312ad34b03f6bbdd715994ffc3..fef76d7bfee08014ad1fcd521cfeb5c85b313e43 100644 --- a/base/src/event_demultiplexer.cpp +++ b/base/src/event_demultiplexer.cpp @@ -133,7 +133,7 @@ void EventDemultiplexer::Polling(int timeout /* ms */) } for (int idx = 0; idx < nfds; ++idx) { - int events = epollEvents[idx].events; + uint32_t events = epollEvents[idx].events; void* ptr = epollEvents[idx].data.ptr; auto handler = reinterpret_cast(ptr); if (handler != nullptr) { diff --git a/base/src/parcel.cpp b/base/src/parcel.cpp index 441a4df2f304048f8265591a94393eefcd345c67..65b15f4ea1ed3e4b463f01753583a98ce433eeb6 100644 --- a/base/src/parcel.cpp +++ b/base/src/parcel.cpp @@ -1239,7 +1239,7 @@ bool Parcel::ReadVector(std::vector *val, bool (Parcel::*Read)(T &)) return false; } - size_t readAbleSize = this->GetReadableBytes(); + size_t readAbleSize = this->GetReadableBytes() / sizeof(T); size_t size = static_cast(len); if ((size > readAbleSize) || (size > val->max_size())) { UTILS_LOGE("Failed to read vector, size = %{public}zu, readAbleSize = %{public}zu", size, readAbleSize); diff --git a/base/src/refbase.cpp b/base/src/refbase.cpp index 89a2c70249500867ad09d1ad660e3f0c2973e9c5..9c41cee30047cd63f7eb23a189f39f2c83b92f16 100644 --- a/base/src/refbase.cpp +++ b/base/src/refbase.cpp @@ -456,8 +456,8 @@ void RefBase::IncStrongRef(const void *objectId) return; } - const int curCount = refs_->IncStrongRefCount(objectId); IncWeakRef(objectId); + const int curCount = refs_->IncStrongRefCount(objectId); if (curCount == INITIAL_PRIMARY_VALUE) { OnFirstStrongRef(objectId); } diff --git a/base/src/unicode_ex.cpp b/base/src/unicode_ex.cpp index 93d35532eb319b7faba5ba5c8f1c3f54cddd6e59..bb737360820aa4c6d37ec0be907fd8137ba40124 100644 --- a/base/src/unicode_ex.cpp +++ b/base/src/unicode_ex.cpp @@ -248,7 +248,7 @@ int Utf8ToUtf16Length(const char* str8, size_t str8Len) int utf16len = 0; while (str8 < str8end) { utf16len++; - int u8charlen = Utf8CodePointLen(*str8); + size_t u8charlen = Utf8CodePointLen(*str8); if (str8 + u8charlen - 1 >= str8end) { UTILS_LOGE("Get str16 length failed because str8 unicode is illegal!"); return -1;