From b4985abf472e94d11a928f9b02fd74edc53adcb0 Mon Sep 17 00:00:00 2001 From: peilixia Date: Tue, 8 Nov 2022 20:51:43 +0800 Subject: [PATCH] clean warning Signed-off-by: peilixia --- base/include/ashmem.h | 4 ++-- base/include/common_timer_errors.h | 2 +- base/include/datetime_ex.h | 12 ++++++------ base/include/errors.h | 2 +- base/include/parcel.h | 6 +++--- base/include/refbase.h | 20 ++++++++++---------- base/include/rwlock.h | 6 +++--- base/include/safe_block_queue.h | 4 ++-- base/include/safe_queue.h | 12 ++++++------ base/include/semaphore_ex.h | 9 ++++----- base/include/thread_ex.h | 1 + base/include/thread_pool.h | 2 +- base/include/unique_fd.h | 24 ++++++++++++------------ base/src/refbase.cpp | 24 ++++++++++++------------ 14 files changed, 64 insertions(+), 64 deletions(-) diff --git a/base/include/ashmem.h b/base/include/ashmem.h index 50f9b1f..b0460ed 100644 --- a/base/include/ashmem.h +++ b/base/include/ashmem.h @@ -16,7 +16,7 @@ #ifndef UTILS_BASE_ASHMEM_H #define UTILS_BASE_ASHMEM_H -#include +#include #include #include "refbase.h" #include "parcel.h" @@ -40,7 +40,7 @@ public: bool WriteToAshmem(const void *data, int32_t size, int32_t offset); const void *ReadFromAshmem(int32_t size, int32_t offset); Ashmem(int fd, int32_t size); - ~Ashmem(); + ~Ashmem() override; int GetAshmemFd() const { return memoryFd_; diff --git a/base/include/common_timer_errors.h b/base/include/common_timer_errors.h index 8b15592..2d244af 100644 --- a/base/include/common_timer_errors.h +++ b/base/include/common_timer_errors.h @@ -16,7 +16,7 @@ #ifndef UTILS_COMMON_TIMER_ERRORS_H #define UTILS_COMMON_TIMER_ERRORS_H -#include +#include #include "errors.h" #include "common_errors.h" diff --git a/base/include/datetime_ex.h b/base/include/datetime_ex.h index 42baf6e..c1279c9 100644 --- a/base/include/datetime_ex.h +++ b/base/include/datetime_ex.h @@ -29,32 +29,32 @@ constexpr int64_t MICROSEC_TO_NANOSEC = 1000; constexpr int SECONDS_PER_HOUR = 3600; // 60 * 60 constexpr int SECONDS_PER_DAY = 86400; // 60 * 60 * 24 -static constexpr inline int64_t SecToNanosec(int64_t sec) +constexpr inline int64_t SecToNanosec(int64_t sec) { return sec * SEC_TO_NANOSEC; } -static constexpr inline int64_t MillisecToNanosec(int64_t millise) +constexpr inline int64_t MillisecToNanosec(int64_t millise) { return millise * MILLISEC_TO_NANOSEC; } -static constexpr inline int64_t MicrosecToNanosec(int64_t microsec) +constexpr inline int64_t MicrosecToNanosec(int64_t microsec) { return microsec * MICROSEC_TO_NANOSEC; } -static constexpr inline int64_t NanosecToSec(int64_t nanosec) +constexpr inline int64_t NanosecToSec(int64_t nanosec) { return nanosec / SEC_TO_NANOSEC; } -static constexpr inline int64_t NanosecToMillisec(int64_t nanosec) +constexpr inline int64_t NanosecToMillisec(int64_t nanosec) { return nanosec / MILLISEC_TO_NANOSEC; } -static constexpr inline int64_t NanosecToMicrosec(int64_t nanosec) +constexpr inline int64_t NanosecToMicrosec(int64_t nanosec) { return nanosec / MICROSEC_TO_NANOSEC; } diff --git a/base/include/errors.h b/base/include/errors.h index df5af52..9dadfa0 100644 --- a/base/include/errors.h +++ b/base/include/errors.h @@ -16,7 +16,7 @@ #ifndef UTILS_BASE_ERRORS_H #define UTILS_BASE_ERRORS_H -#include +#include namespace OHOS { diff --git a/base/include/parcel.h b/base/include/parcel.h index 78f9185..881b39e 100644 --- a/base/include/parcel.h +++ b/base/include/parcel.h @@ -78,11 +78,11 @@ public: class DefaultAllocator : public Allocator { public: - virtual void *Alloc(size_t size) override; + void *Alloc(size_t size) override; - virtual void Dealloc(void *data) override; + void Dealloc(void *data) override; private: - virtual void *Realloc(void *data, size_t newSize) override; + void *Realloc(void *data, size_t newSize) override; }; class Parcel { diff --git a/base/include/refbase.h b/base/include/refbase.h index 8122d81..aa3a9fd 100644 --- a/base/include/refbase.h +++ b/base/include/refbase.h @@ -95,7 +95,7 @@ private: #ifdef DEBUG_REFBASE RefTracker* refTracker = nullptr; std::mutex trackerMutex; // To ensure refTracker be thread-safe - void GetNewTrace(const void* object); + void GetNewTrace(const void* objectId); void PrintTracker(); #endif }; @@ -144,7 +144,7 @@ private: class WeakRefCounter { public: - WeakRefCounter(RefCounter *base, void *cookie); + WeakRefCounter(RefCounter *counter, void *cookie); virtual ~WeakRefCounter(); @@ -166,13 +166,13 @@ class RefBase { public: RefBase(); - RefBase(const RefBase &refbase); + RefBase(const RefBase &); - RefBase &operator=(const RefBase &refbase); + RefBase &operator=(const RefBase &); - RefBase(RefBase &&refbase) noexcept; + RefBase(RefBase &&other) noexcept; - RefBase &operator=(RefBase &&refbase) noexcept; + RefBase &operator=(RefBase &&other) noexcept; virtual ~RefBase(); @@ -205,13 +205,13 @@ public: bool IsExtendLifeTimeSet(); - virtual void OnFirstStrongRef(const void *objectId); + virtual void OnFirstStrongRef(const void *); - virtual void OnLastStrongRef(const void *objectId); + virtual void OnLastStrongRef(const void *); - virtual void OnLastWeakRef(const void *objectId); + virtual void OnLastWeakRef(const void *); - virtual bool OnAttemptPromoted(const void *objectId); + virtual bool OnAttemptPromoted(const void *); private: RefCounter *refs_ = nullptr; diff --git a/base/include/rwlock.h b/base/include/rwlock.h index b53b863..fde028d 100644 --- a/base/include/rwlock.h +++ b/base/include/rwlock.h @@ -33,7 +33,7 @@ public: RWLock() : RWLock(true) {} explicit RWLock(bool writeFirst); - virtual ~RWLock() {} + ~RWLock() override {} void LockRead(); void UnLockRead(); @@ -61,7 +61,7 @@ public: rwLockable_.LockWrite(); } - ~UniqueWriteGuard() + ~UniqueWriteGuard() override { rwLockable_.UnLockWrite(); } @@ -83,7 +83,7 @@ public: rwLockable_.LockRead(); } - ~UniqueReadGuard() + ~UniqueReadGuard() override { rwLockable_.UnLockRead(); } diff --git a/base/include/safe_block_queue.h b/base/include/safe_block_queue.h index 0196c92..146877f 100644 --- a/base/include/safe_block_queue.h +++ b/base/include/safe_block_queue.h @@ -27,7 +27,7 @@ namespace OHOS { template class SafeBlockQueue { public: - SafeBlockQueue(int capacity) : maxSize_(capacity) + explicit SafeBlockQueue(int capacity) : maxSize_(capacity) { } @@ -116,7 +116,7 @@ protected: template class SafeBlockQueueTracking : public SafeBlockQueue { public: - SafeBlockQueueTracking(int capacity) : SafeBlockQueue(capacity) + explicit SafeBlockQueueTracking(int capacity) : SafeBlockQueue(capacity) { unfinishedTaskCount_ = 0; } diff --git a/base/include/safe_queue.h b/base/include/safe_queue.h index d960041..60ce809 100644 --- a/base/include/safe_queue.h +++ b/base/include/safe_queue.h @@ -34,10 +34,10 @@ public: } } - void Erase(T& Object) + void Erase(T& object) { std::lock_guard lock(mutex_); - deque_.remove(Object); + deque_.remove(object); } bool Empty() @@ -89,12 +89,12 @@ protected: using SafeQueueInner::deque_; using SafeQueueInner::mutex_; - virtual void DoPush(const T& pt) override + void DoPush(const T& pt) override { deque_.push_back(pt); } - virtual bool DoPop(T& pt) override + bool DoPop(T& pt) override { if (deque_.size() > 0) { pt = deque_.front(); @@ -113,12 +113,12 @@ protected: using SafeQueueInner::deque_; using SafeQueueInner::mutex_; - virtual void DoPush(const T& pt) override + void DoPush(const T& pt) override { deque_.push_back(pt); } - virtual bool DoPop(T& pt) override + bool DoPop(T& pt) override { if (deque_.size() > 0) { pt = deque_.back(); diff --git a/base/include/semaphore_ex.h b/base/include/semaphore_ex.h index f44eabc..b8d2c58 100644 --- a/base/include/semaphore_ex.h +++ b/base/include/semaphore_ex.h @@ -22,7 +22,7 @@ #include #include #include -#include // timespec since c11 +#include // timespec since c11 namespace OHOS { @@ -30,9 +30,9 @@ const int INVALID_SEMA_VALUE = -1; class NamedSemaphore : public NoCopyable { public: - NamedSemaphore(size_t); + explicit NamedSemaphore(size_t); NamedSemaphore(const std::string&, size_t); - ~NamedSemaphore(); + ~NamedSemaphore() override; bool Create(); bool Unlink(); @@ -56,8 +56,7 @@ private: class Semaphore : public NoCopyable { public: - Semaphore(int value = 1) : count_(value) {} - ~Semaphore() = default; + explicit Semaphore(int value = 1) : count_(value) {} void Wait(); void Post(); diff --git a/base/include/thread_ex.h b/base/include/thread_ex.h index 5ee6aad..3ff915d 100644 --- a/base/include/thread_ex.h +++ b/base/include/thread_ex.h @@ -59,6 +59,7 @@ protected: virtual bool Run() = 0; // Derived class must implement Run() private: + Thread(const Thread&) = delete; Thread& operator=(const Thread&) = delete; static int ThreadStart(void* args); ThreadStatus Join(); // pthread created as detached diff --git a/base/include/thread_pool.h b/base/include/thread_pool.h index e2d1838..06bac4e 100644 --- a/base/include/thread_pool.h +++ b/base/include/thread_pool.h @@ -37,7 +37,7 @@ public: // is restricted to 16 characters, including the terminating null byte ('\0'). // Please pay attention to the length of name(args here). explicit ThreadPool(const std::string &name = std::string()); - ~ThreadPool(); + ~ThreadPool () override; uint32_t Start(int threadsNum); void Stop(); diff --git a/base/include/unique_fd.h b/base/include/unique_fd.h index 24a00de..2ba27bf 100644 --- a/base/include/unique_fd.h +++ b/base/include/unique_fd.h @@ -146,39 +146,39 @@ private: }; template -bool operator==(const int& lhs, const UniqueFdAddDeletor& uniqueFd) +bool operator==(const int& lhs, const UniqueFdAddDeletor& rhs) { - return lhs == uniqueFd.fd_; + return lhs == rhs.fd_; } template -bool operator!=(const int& lhs, const UniqueFdAddDeletor& uniqueFd) +bool operator!=(const int& lhs, const UniqueFdAddDeletor& rhs) { - return !(lhs == uniqueFd.fd_); + return !(lhs == rhs.fd_); } template -bool operator>=(const int& lhs, const UniqueFdAddDeletor& uniqueFd) +bool operator>=(const int& lhs, const UniqueFdAddDeletor& rhs) { - return lhs >= uniqueFd.fd_; + return lhs >= rhs.fd_; } template -bool operator>(const int& lhs, const UniqueFdAddDeletor& uniqueFd) +bool operator>(const int& lhs, const UniqueFdAddDeletor& rhs) { - return lhs > uniqueFd.fd_; + return lhs > rhs.fd_; } template -bool operator<=(const int& lhs, const UniqueFdAddDeletor& uniqueFd) +bool operator<=(const int& lhs, const UniqueFdAddDeletor& rhs) { - return lhs <= uniqueFd.fd_; + return lhs <= rhs.fd_; } template -bool operator<(const int& lhs, const UniqueFdAddDeletor& uniqueFd) +bool operator<(const int& lhs, const UniqueFdAddDeletor& rhs) { - return lhs < uniqueFd.fd_; + return lhs < rhs.fd_; } using UniqueFd = UniqueFdAddDeletor; diff --git a/base/src/refbase.cpp b/base/src/refbase.cpp index fb46127..d5f3a58 100644 --- a/base/src/refbase.cpp +++ b/base/src/refbase.cpp @@ -136,10 +136,10 @@ RefTracker* RefTracker::PopTrace(const void* root) return ref; } -void RefCounter::GetNewTrace(const void* object) +void RefCounter::GetNewTrace(const void* objectId) { std::lock_guard lock(trackerMutex); - RefTracker* newTracker = new RefTracker(refTracker, object, atomicStrong_.load(std::memory_order_relaxed), + RefTracker* newTracker = new RefTracker(refTracker, objectId, atomicStrong_.load(std::memory_order_relaxed), atomicWeak_.load(std::memory_order_relaxed), atomicRefCount_.load(std::memory_order_relaxed), getpid(), gettid()); refTracker = newTracker; @@ -200,10 +200,10 @@ RefCounter::~RefCounter() #endif } -int RefCounter::IncStrongRefCount(const void* object) +int RefCounter::IncStrongRefCount(const void* objectId) { #ifdef DEBUG_REFBASE - GetNewTrace(object); + GetNewTrace(objectId); #endif int curCount = atomicStrong_.load(std::memory_order_relaxed); if (curCount >= 0) { @@ -216,10 +216,10 @@ int RefCounter::IncStrongRefCount(const void* object) return curCount; } -int RefCounter::DecStrongRefCount(const void* object) +int RefCounter::DecStrongRefCount(const void* objectId) { #ifdef DEBUG_REFBASE - GetNewTrace(object); + GetNewTrace(objectId); #endif int curCount = GetStrongRefCount(); if (curCount == INITIAL_PRIMARY_VALUE) { @@ -238,18 +238,18 @@ int RefCounter::GetStrongRefCount() return atomicStrong_.load(std::memory_order_relaxed); } -int RefCounter::IncWeakRefCount(const void* object) +int RefCounter::IncWeakRefCount(const void* objectId) { #ifdef DEBUG_REFBASE - GetNewTrace(object); + GetNewTrace(objectId); #endif return atomicWeak_.fetch_add(1, std::memory_order_relaxed); } -int RefCounter::DecWeakRefCount(const void* object) +int RefCounter::DecWeakRefCount(const void* objectId) { #ifdef DEBUG_REFBASE - GetNewTrace(object); + GetNewTrace(objectId); #endif int curCount = GetWeakRefCount(); if (curCount > 0) { @@ -437,8 +437,8 @@ RefBase::~RefBase() { if (refs_ != nullptr) { refs_->RemoveCallback(); - if ((refs_->IsLifeTimeExtended() && refs_->GetWeakRefCount() == 0) - || refs_->GetStrongRefCount() == INITIAL_PRIMARY_VALUE) { + if ((refs_->IsLifeTimeExtended() && refs_->GetWeakRefCount() == 0) || + refs_->GetStrongRefCount() == INITIAL_PRIMARY_VALUE) { refs_->DecRefCount(); } refs_ = nullptr; -- Gitee