diff --git a/frameworks/resmgr_lite/include/lock.h b/frameworks/resmgr_lite/include/lock.h index d200f07e7d19e267f67bf24dffadb822e43a97e7..39e5f5817a335a86a34cb4a72d12561f635a6246 100644 --- a/frameworks/resmgr_lite/include/lock.h +++ b/frameworks/resmgr_lite/include/lock.h @@ -31,8 +31,10 @@ public: private: std::mutex* mtx_; + + Lock(const Lock &src) = delete; }; } // namespace Resource } // namespace Global } // namespace OHOS -#endif \ No newline at end of file +#endif diff --git a/frameworks/resmgr_lite/src/res_locale.cpp b/frameworks/resmgr_lite/src/res_locale.cpp index 62ad69c81eeb696d7260900b396993e7376fdc6b..378262e785ee3b4f5c249ebed4f6f3bbf2dcbfe7 100644 --- a/frameworks/resmgr_lite/src/res_locale.cpp +++ b/frameworks/resmgr_lite/src/res_locale.cpp @@ -32,7 +32,7 @@ namespace OHOS { namespace Global { namespace Resource { LocaleInfo *ResLocale::defaultLocale_ = nullptr; -Lock ResLocale::lock_ = Lock(); +Lock ResLocale::lock_; ResLocale::ResLocale() : language_(nullptr), region_(nullptr), script_(nullptr) { @@ -426,7 +426,7 @@ void FindAndSort(std::string localeStr, std::vector &candidateLocal ResLocale *currentLocale = ResLocale::BuildFromString(localeStr.c_str(), DASH_SEP, state); LocaleMatcher::Normalize(currentLocale); std::vector::const_iterator iter; - for (iter = candidateLocale.cbegin(); iter != candidateLocale.cend(); iter++) { + for (iter = candidateLocale.cbegin(); iter != candidateLocale.cend(); ++iter) { ResLocale *resLocale = ResLocale::BuildFromString(iter->c_str(), DASH_SEP, state); if (state == SUCCESS) { LocaleMatcher::Normalize(resLocale); @@ -467,4 +467,4 @@ void FindAndSort(std::string localeStr, std::vector &candidateLocal } } // namespace Resource } // namespace Global -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.cpp b/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.cpp index 08cfbcaa4f30a176c4e449ff44234b913691e14c..5ad5ed50499784cc74d1e07d35b4057a64fe4733 100644 --- a/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.cpp +++ b/frameworks/resmgr_lite/test/unittest/lite/common/string_utils_test.cpp @@ -100,7 +100,7 @@ HWTEST_F(StringUtilsTest, LockFuncTest001, TestSize.Level1) int num = 0; int threadNum = 3; int result = num + threadNum; - Lock lock = Lock(); + Lock lock; TestThread(&num, threadNum, &lock); EXPECT_EQ(result, num); -} \ No newline at end of file +}