diff --git a/base/include/parcel.h b/base/include/parcel.h index 5ea29b2feadedaffc0dc5f95fa96121af3d0d5ae..3f752d548a218818fa2c5787562bc6b541cb54be 100755 --- a/base/include/parcel.h +++ b/base/include/parcel.h @@ -292,7 +292,6 @@ public: bool WriteUint8Unaligned(uint8_t value); bool WriteUint16Unaligned(uint16_t value); - bool ReadBoolUnaligned(); bool ReadInt8Unaligned(int8_t &value); bool ReadInt16Unaligned(int16_t &value); diff --git a/base/include/safe_block_queue.h b/base/include/safe_block_queue.h index f85317d6582f27219c9c8a7c2bff1dc74e848aa6..f026169fc192c999a03c1dc54012db8c2f868ca0 100755 --- a/base/include/safe_block_queue.h +++ b/base/include/safe_block_queue.h @@ -121,7 +121,7 @@ public: unfinishedTaskCount_ = 0; } - virtual ~SafeBlockQueueTracking(){}; + virtual ~SafeBlockQueueTracking() {}; virtual void Push(T const& elem) { diff --git a/base/include/sorted_vector.h b/base/include/sorted_vector.h index 065dda754554092f8f759e1cd5a1528f3d1887a9..2877445bd0ffb5a18bab33fe199e7fd8278596af 100755 --- a/base/include/sorted_vector.h +++ b/base/include/sorted_vector.h @@ -43,7 +43,7 @@ public: SortedVector(const std::vector& orivect); - virtual ~SortedVector(){}; + virtual ~SortedVector() {}; // copy operator SortedVector& operator=(const SortedVector& rhs); SortedVector& operator=(const SortedVector& rhs); diff --git a/base/include/timer.h b/base/include/timer.h index b362175c7dd4d1fc6295d86bb18dc4ce605b5bf5..8b09ee4c151a733105c9aaf1cd4bcb30ae2d7e73 100755 --- a/base/include/timer.h +++ b/base/include/timer.h @@ -46,7 +46,7 @@ public: * others: wait(until event-trigger) */ explicit Timer(const std::string& name, int timeoutMs = 1000); - virtual ~Timer(){} + virtual ~Timer() {} virtual uint32_t Setup(); diff --git a/base/src/directory_ex.cpp b/base/src/directory_ex.cpp index e3c9d2abf62a240156aa7e6f7171e13379040d81..80e89292cf6d76c94f85c5f7dbfdad4cb1fc8965 100755 --- a/base/src/directory_ex.cpp +++ b/base/src/directory_ex.cpp @@ -14,10 +14,10 @@ */ #include "directory_ex.h" -#include "securec.h" -#include "unistd.h" #include #include +#include "securec.h" +#include "unistd.h" #include "utils_log.h" using namespace std; diff --git a/base/src/event_handler.h b/base/src/event_handler.h index 779563037699193cf551958efb985b5f605cb6db..c2434779b8abcbef921f70899ee4b3841c9087a0 100755 --- a/base/src/event_handler.h +++ b/base/src/event_handler.h @@ -34,7 +34,7 @@ public: EventHandler(const EventHandler&) = delete; EventHandler& operator=(const EventHandler&&) = delete; EventHandler(const EventHandler&&) = delete; - ~EventHandler(){}; + ~EventHandler() {}; int GetHandle() const { return (fd_); } uint32_t Events() const { return (events_); } diff --git a/base/src/file_ex.cpp b/base/src/file_ex.cpp index cd79a5f59a1b3dfda7c2c499eeeb0a12459387c8..d52f1b4de40f502bc2b1eae026725ad23761b819 100755 --- a/base/src/file_ex.cpp +++ b/base/src/file_ex.cpp @@ -14,7 +14,6 @@ */ #include "file_ex.h" -#include "directory_ex.h" #include #include #include @@ -25,6 +24,7 @@ #include #include #include +#include "directory_ex.h" #include "utils_log.h" using namespace std; diff --git a/base/src/parcel.cpp b/base/src/parcel.cpp index 35b483283c3af8ef1c11dde77193804a087a7370..855f7cfe48fa18772d56a8e001f055bfb7f1ffc5 100755 --- a/base/src/parcel.cpp +++ b/base/src/parcel.cpp @@ -696,7 +696,7 @@ bool Parcel::Read(T &value) template T Parcel::Read() { - T lvalue{}; + T lvalue {}; return Read(lvalue) ? lvalue : 0; } diff --git a/base/src/refbase.cpp b/base/src/refbase.cpp index ab936534ea41bedeba5ce44c9b615d7ac4330510..fd15b8206ffc2ed0e992b70e75e480170600a4a9 100755 --- a/base/src/refbase.cpp +++ b/base/src/refbase.cpp @@ -34,7 +34,7 @@ WeakRefCounter::~WeakRefCounter() void* WeakRefCounter::GetRefPtr() { - if ((cookie_ != nullptr) && (!refCounter_->IsRefPtrValid())){ + if ((cookie_ != nullptr) && (!refCounter_->IsRefPtrValid())) { cookie_ = nullptr; } return cookie_; @@ -103,7 +103,7 @@ RefCounter::~RefCounter() { } -int RefCounter::IncStrongRefCount(const void* /*objectId*/) +int RefCounter::IncStrongRefCount(const void* /* objectId */) { int curCount = atomicStrong_.load(std::memory_order_relaxed); @@ -117,7 +117,7 @@ int RefCounter::IncStrongRefCount(const void* /*objectId*/) return curCount; } -int RefCounter::DecStrongRefCount(const void* /*objectId*/) +int RefCounter::DecStrongRefCount(const void* /* objectId */) { int curCount = GetStrongRefCount(); if (curCount == INITIAL_PRIMARY_VALUE) { @@ -136,12 +136,12 @@ int RefCounter::GetStrongRefCount() return atomicStrong_.load(std::memory_order_relaxed); } -int RefCounter::IncWeakRefCount(const void* /*objectId*/) +int RefCounter::IncWeakRefCount(const void* /* objectId */) { return atomicWeak_.fetch_add(1, std::memory_order_relaxed); } -int RefCounter::DecWeakRefCount(const void* /*objectId*/) +int RefCounter::DecWeakRefCount(const void* /* objectId */) { int curCount = GetWeakRefCount(); if (curCount > 0) { @@ -237,7 +237,7 @@ RefBase::RefBase() : refs_(new RefCounter()) refs_->SetCallback(std::bind(&RefBase::RefPtrCallback, this)); } -RefBase::RefBase(const RefBase &/*other*/) +RefBase::RefBase(const RefBase & /* other */) { refs_ = new RefCounter(); if (refs_ != nullptr) { @@ -257,7 +257,7 @@ void RefBase::RefPtrCallback() * RISK: If there is a reference count on the left of the equal sign, * it may cause a reference count exception */ -RefBase &RefBase::operator=(const RefBase &/*other*/) +RefBase &RefBase::operator=(const RefBase & /* other */) { if (refs_ != nullptr) { refs_->RemoveCallback(); @@ -426,16 +426,16 @@ bool RefBase::IsExtendLifeTimeSet() return refs_->IsLifeTimeExtended(); } -void RefBase::OnFirstStrongRef(const void* /*objectId*/) +void RefBase::OnFirstStrongRef(const void* /* objectId */) {} -void RefBase::OnLastStrongRef(const void* /*objectId*/) +void RefBase::OnLastStrongRef(const void* /* objectId */) {} -void RefBase::OnLastWeakRef(const void* /*objectId*/) +void RefBase::OnLastWeakRef(const void* /* objectId */) {} -bool RefBase::OnAttemptPromoted(const void* /*objectId*/) +bool RefBase::OnAttemptPromoted(const void* /* objectId */) { return true; } diff --git a/base/test/unittest/common/utils_refbase_test.cpp b/base/test/unittest/common/utils_refbase_test.cpp index 257419dcce26186697aba69450a888e78b1d1731..ebd7f64449db7054d6b4a06c6700cbfab39d4e4e 100755 --- a/base/test/unittest/common/utils_refbase_test.cpp +++ b/base/test/unittest/common/utils_refbase_test.cpp @@ -82,7 +82,7 @@ class IRemoteObject : public virtual RefBase { public: IRemoteObject() { ExtendObjectLifetime(); }; virtual bool IsProxyObject() = 0; - ~IRemoteObject(){}; + ~IRemoteObject() {}; }; class RefBaseTestTracker : public RefBase { @@ -205,7 +205,7 @@ public: tracker->TrackObject(this); tracker->TrackNewObject(this); }; - ~IPCObjectProxy(){}; + ~IPCObjectProxy() {}; void RefPtrCallback() override; void OnLastStrongRef(const void *objectId) override; void OnFirstStrongRef(const void *objectId) override; diff --git a/base/test/unittest/common/utils_singleton_test.cpp b/base/test/unittest/common/utils_singleton_test.cpp index bfe9a63b4f0d07edea85836401dff6793b627d19..ded12b66803c8b0a3968a808592ff1c69c774aab 100644 --- a/base/test/unittest/common/utils_singleton_test.cpp +++ b/base/test/unittest/common/utils_singleton_test.cpp @@ -28,8 +28,8 @@ public: void* GetObjAddr() { return (void*)this; } }; -DelayedSingletonDeclearTest::~DelayedSingletonDeclearTest(){}; -DelayedSingletonDeclearTest::DelayedSingletonDeclearTest(){}; +DelayedSingletonDeclearTest::~DelayedSingletonDeclearTest() {}; +DelayedSingletonDeclearTest::DelayedSingletonDeclearTest() {}; class SingletonDeclearTest { DECLARE_SINGLETON(SingletonDeclearTest); @@ -37,8 +37,8 @@ public: void* GetObjAddr() { return (void*)this; } }; -SingletonDeclearTest::~SingletonDeclearTest(){}; -SingletonDeclearTest::SingletonDeclearTest(){}; +SingletonDeclearTest::~SingletonDeclearTest() {}; +SingletonDeclearTest::SingletonDeclearTest() {}; class SingletonTest: public Singleton { public: @@ -57,8 +57,8 @@ public: void* GetObjAddr() { return (void*)this; } }; -DelayedRefSingletonDeclearTest::DelayedRefSingletonDeclearTest(){}; -DelayedRefSingletonDeclearTest::~DelayedRefSingletonDeclearTest(){}; +DelayedRefSingletonDeclearTest::DelayedRefSingletonDeclearTest() {}; +DelayedRefSingletonDeclearTest::~DelayedRefSingletonDeclearTest() {}; class DelayedRefSingletonTest: public DelayedRefSingleton { public: diff --git a/base/test/unittest/common/utils_thread_pool_test.cpp b/base/test/unittest/common/utils_thread_pool_test.cpp index dea8df9210153316d5bfeac553c5a884191d6c81..6a0cd20497b897b499c6e9b37f2e7bc106372e5a 100755 --- a/base/test/unittest/common/utils_thread_pool_test.cpp +++ b/base/test/unittest/common/utils_thread_pool_test.cpp @@ -120,13 +120,13 @@ HWTEST_F(UtilsThreadPoolTest, test_05, TestSize.Level0) EXPECT_EQ((int)pool.GetThreadsNum(), 5); EXPECT_EQ((int)pool.GetCurTaskNum(), 0); - for ( int i = 0; i < 3; ++i ) + for (int i = 0; i < 3; ++i) { auto task = std::bind(TestFuncAddOneTime, i); pool.AddTask(task); } - for ( int i = 0; i < 2; ++i ) + for (int i = 0; i < 2; ++i) { auto task = std::bind(TestFuncSubOneTime, i); pool.AddTask(task); @@ -150,13 +150,13 @@ HWTEST_F(UtilsThreadPoolTest, test_06, TestSize.Level0) pool.SetMaxTaskNum(10); - for ( int i = 0; i < 8; ++i ) + for (int i = 0; i < 8; ++i) { auto task = std::bind(TestFuncAddOneTime, i); pool.AddTask(task); } - for ( int i = 0; i < 7; ++i ) + for (int i = 0; i < 7; ++i) { auto task = std::bind(TestFuncSubOneTime, i); pool.AddTask(task); @@ -175,7 +175,7 @@ void TestFuncAddWait(int& i) ++g_times; printf("after func:%s0%d called, :%d\n", __func__, i, g_times); std::unique_lock lk(g_mutex); - g_cv.wait(lk, []{return g_ready;}); + g_cv.wait(lk, [] {return g_ready;}); printf("func:%s0%d received ready signal!\n", __func__, i); } @@ -184,7 +184,7 @@ void TestFuncSubWait(int& i) --g_times; printf("after func:%s0%d called, :%d\n", __func__, i, g_times); std::unique_lock lk(g_mutex); - g_cv.wait(lk, []{return g_ready;}); + g_cv.wait(lk, [] {return g_ready;}); printf("func:%s0%d received ready signal!\n", __func__, i); } @@ -198,13 +198,13 @@ HWTEST_F(UtilsThreadPoolTest, test_07, TestSize.Level0) EXPECT_EQ((int)pool.GetThreadsNum(), 5); EXPECT_EQ((int)pool.GetCurTaskNum(), 0); - for ( int i = 0; i < 3; ++i ) + for (int i = 0; i < 3; ++i) { auto task = std::bind(TestFuncAddWait, i); pool.AddTask(task); } - for ( int i = 0; i < 2; ++i ) + for (int i = 0; i < 2; ++i) { auto task = std::bind(TestFuncSubWait, i); pool.AddTask(task); @@ -236,13 +236,13 @@ HWTEST_F(UtilsThreadPoolTest, test_08, TestSize.Level0) pool.SetMaxTaskNum(10); // ADD 15 tasks - for ( int i = 0; i < 8; ++i ) + for (int i = 0; i < 8; ++i) { auto task = std::bind(TestFuncAddWait, i); pool.AddTask(task); } - for ( int i = 0; i < 7; ++i ) + for (int i = 0; i < 7; ++i) { auto task = std::bind(TestFuncSubWait, i); pool.AddTask(task); diff --git a/base/test/unittest/common/utils_thread_test.cpp b/base/test/unittest/common/utils_thread_test.cpp index 7147b6b023e1bc0fb53a42af9acaf0eb798240ba..1cc7fca76cd60e3a55fefdef28a0bce38203b86a 100755 --- a/base/test/unittest/common/utils_thread_test.cpp +++ b/base/test/unittest/common/utils_thread_test.cpp @@ -25,9 +25,8 @@ using namespace std; static int times = 0; using ThreadRunFunc = bool (*)(int& data); -class UtilsThreadTest : public testing::Test -{ -public : +class UtilsThreadTest : public testing::Test { +public: static void SetUpTestCase(void); static void TearDownTestCase(void); void SetUp(); @@ -66,7 +65,7 @@ int GetThreadPriority(const pthread_t& thread) // scheduling parameters of target thread ret = pthread_getschedparam (thread, &policy, ¶m); - if (ret != 0){ + if (ret != 0) { printf("pthread_getschedparam failed! thread:%lu, ret:%d\n", thread, ret); return -1; } @@ -103,14 +102,14 @@ bool TestRun03(int& data) constexpr int DEFAULT_PRIO = 0; const std::string& DEFAULT_THREAD_NAME = "default"; -class TestThread : public OHOS::Thread{ +class TestThread : public OHOS::Thread { public: TestThread(const int data, const bool readyToWork, ThreadRunFunc runFunc) : data_(data), priority_(DEFAULT_PRIO), name_(DEFAULT_THREAD_NAME), readyToWork_(readyToWork), runFunc_(runFunc) {}; TestThread() = delete; - ~TestThread(){}; + ~TestThread() {}; bool ReadyToWork() override; @@ -158,7 +157,7 @@ HWTEST_F(UtilsThreadTest, testThread001, TestSize.Level0) pthread_t thread = test->GetThread(); // pthread_equal return non-zero if equal - EXPECT_EQ(pthread_equal(thread ,-1) != 0, (test->IsRunning() ? false : true)); + EXPECT_EQ(pthread_equal(thread, -1) != 0, (test->IsRunning() ? false : true)); // ReadyToWork return false, RUN will not be called! EXPECT_EQ(test->priority_, DEFAULT_PRIO); @@ -170,7 +169,7 @@ HWTEST_F(UtilsThreadTest, testThread001, TestSize.Level0) EXPECT_EQ(times, 0); test->NotifyExitSync(); sleep(1); - EXPECT_EQ(pthread_equal(test->GetThread() ,-1) != 0, (test->IsRunning() ? false : true)); + EXPECT_EQ(pthread_equal(test->GetThread(), -1) != 0, (test->IsRunning() ? false : true)); } /* @@ -188,7 +187,7 @@ HWTEST_F(UtilsThreadTest, testThread002, TestSize.Level0) sleep(1); // let the new thread has chance to run // pthread_equal return non-zero if equal, RUN return false,may exit already - EXPECT_EQ(pthread_equal(test->GetThread() ,-1) != 0, (test->IsRunning() ? false : true)); + EXPECT_EQ(pthread_equal(test->GetThread(), -1) != 0, (test->IsRunning() ? false : true)); // ReadyToWork return true, RUN will be called! EXPECT_EQ(test->priority_, THREAD_PROI_LOW); @@ -198,7 +197,7 @@ HWTEST_F(UtilsThreadTest, testThread002, TestSize.Level0) EXPECT_EQ(times, 0); test->NotifyExitSync(); sleep(1); - EXPECT_EQ(pthread_equal(test->GetThread() ,-1) != 0, (test->IsRunning() ? false : true)); + EXPECT_EQ(pthread_equal(test->GetThread(), -1) != 0, (test->IsRunning() ? false : true)); } /* @@ -225,7 +224,7 @@ HWTEST_F(UtilsThreadTest, testThread003, TestSize.Level0) EXPECT_EQ(times, 0); test->NotifyExitSync(); sleep(1); - EXPECT_EQ(pthread_equal(test->GetThread() ,-1) != 0, (test->IsRunning() ? false : true)); + EXPECT_EQ(pthread_equal(test->GetThread(), -1) != 0, (test->IsRunning() ? false : true)); } /* @@ -243,7 +242,7 @@ HWTEST_F(UtilsThreadTest, testThread004, TestSize.Level0) sleep(1); // let the new thread has chance to run // pthread_equal return non-zero if equal, RUN return false,may exit already - EXPECT_EQ(pthread_equal(test->GetThread() ,-1) != 0, (test->IsRunning() ? false : true)); + EXPECT_EQ(pthread_equal(test->GetThread(), -1) != 0, (test->IsRunning() ? false : true)); // ReadyToWork return true, RUN will be called! EXPECT_EQ(test->priority_, THREAD_PROI_LOW); @@ -253,7 +252,7 @@ HWTEST_F(UtilsThreadTest, testThread004, TestSize.Level0) EXPECT_EQ(times, 0); test->NotifyExitSync(); sleep(1); - EXPECT_EQ(pthread_equal(test->GetThread() ,-1) != 0, (test->IsRunning() ? false : true)); + EXPECT_EQ(pthread_equal(test->GetThread(), -1) != 0, (test->IsRunning() ? false : true)); } /* @@ -280,7 +279,7 @@ HWTEST_F(UtilsThreadTest, testThread005, TestSize.Level0) EXPECT_EQ(times, 0); test->NotifyExitSync(); sleep(1); - EXPECT_EQ(pthread_equal(test->GetThread() ,-1) != 0, (test->IsRunning() ? false : true)); + EXPECT_EQ(pthread_equal(test->GetThread(), -1) != 0, (test->IsRunning() ? false : true)); } /* @@ -298,7 +297,7 @@ HWTEST_F(UtilsThreadTest, testThread006, TestSize.Level0) sleep(1); // let the new thread has chance to run // pthread_equal return non-zero if equal, RUN return false,may exit already - EXPECT_EQ(pthread_equal(test->GetThread() ,-1) != 0, (test->IsRunning() ? false : true)); + EXPECT_EQ(pthread_equal(test->GetThread(), -1) != 0, (test->IsRunning() ? false : true)); // ReadyToWork return true, RUN will be called! EXPECT_EQ(test->priority_, THREAD_PROI_LOW); @@ -308,11 +307,11 @@ HWTEST_F(UtilsThreadTest, testThread006, TestSize.Level0) EXPECT_EQ(times, 0); times = 100; - EXPECT_GT(test->data_, 10); + EXPECT_GT(test->data_, 10); sleep(1); // let the new thread has chance to run // times > 10, TestRun03 return false, thread exit - EXPECT_EQ(pthread_equal(test->GetThread() ,-1) != 0, (test->IsRunning() ? false : true)); + EXPECT_EQ(pthread_equal(test->GetThread(), -1) != 0, (test->IsRunning() ? false : true)); } diff --git a/base/test/unittest/common/utils_timer_test.cpp b/base/test/unittest/common/utils_timer_test.cpp index 9f3c3a0c8343b42ae94ad7460bae85b0eb6a5d7c..392cc74801c16fb590c3adc87914c1931f6fa44b 100755 --- a/base/test/unittest/common/utils_timer_test.cpp +++ b/base/test/unittest/common/utils_timer_test.cpp @@ -145,7 +145,7 @@ HWTEST_F(UtilsTimerTest, testTimer004, TestSize.Level0) class A { public: - explicit A(int data) : data_(data), timer_("ATimer"){} + explicit A(int data) : data_(data), timer_("ATimer") {} ~A() = default; bool Init(); bool StartTimer(int milliseconds, bool once);