From a2acaa4338ae6a2184903d34a2028e61c75424cb Mon Sep 17 00:00:00 2001 From: leihonglin Date: Tue, 1 Nov 2022 11:33:35 +0800 Subject: [PATCH] fixed e4e761f from https://gitee.com/leihonglin/applications_sample_camera/pulls/127 optimize cppcheck warning. Signed-off-by: leihonglin --- launcher/launcher/src/main/cpp/app_manage.h | 2 +- launcher/launcher/src/main/cpp/event_listener.h | 5 +---- launcher/launcher/src/main/cpp/long_press_view.cpp | 2 -- launcher/launcher/src/main/cpp/swipe_view.h | 2 +- launcher/launcher/src/main/cpp/time_weather_view.h | 2 +- launcher/launcher/src/main/cpp/view_group_page.h | 4 ++-- setting/setting/src/main/cpp/app_ability_slice.cpp | 3 --- setting/setting/src/main/cpp/app_info_ability_slice.h | 2 +- setting/setting/src/main/cpp/event_listener.h | 5 +---- setting/setting/src/main/cpp/wpa_work.c | 3 +-- 10 files changed, 9 insertions(+), 21 deletions(-) diff --git a/launcher/launcher/src/main/cpp/app_manage.h b/launcher/launcher/src/main/cpp/app_manage.h index ae8c4a8..bd4da44 100755 --- a/launcher/launcher/src/main/cpp/app_manage.h +++ b/launcher/launcher/src/main/cpp/app_manage.h @@ -38,7 +38,7 @@ public: bool InstallApp(AppInfo* app); bool UnInstallApp(AppInfo* app); bool StartApp(AppInfo* app); - static void SetViewGroup(funcClick click, funcLongPress press, ViewGroupPage* arrPage[MAX_VIEWGROUP], int size); + static void SetViewGroup(funcClick click, funcLongPress press, ViewGroupPage* viewPage[MAX_VIEWGROUP], int size); private: static void MyBundleStateCallback(const uint8_t installType, const uint8_t resultCode, const void* resultMessage, diff --git a/launcher/launcher/src/main/cpp/event_listener.h b/launcher/launcher/src/main/cpp/event_listener.h index 144610a..1a7910f 100755 --- a/launcher/launcher/src/main/cpp/event_listener.h +++ b/launcher/launcher/src/main/cpp/event_listener.h @@ -29,10 +29,7 @@ public: ~EventListener() override = default; EventListener(OnEventFunc onClick, OnEventFunc onLongPress) - { - onClick_ = std::move(onClick); - onLongPress_ = std::move(onLongPress); - } + : onClick_(std::move(onClick)), onLongPress_(std::move(onLongPress)) {} bool OnClick(UIView& view, const ClickEvent& event) override { diff --git a/launcher/launcher/src/main/cpp/long_press_view.cpp b/launcher/launcher/src/main/cpp/long_press_view.cpp index 89720f9..77116d7 100755 --- a/launcher/launcher/src/main/cpp/long_press_view.cpp +++ b/launcher/launcher/src/main/cpp/long_press_view.cpp @@ -92,8 +92,6 @@ bool LongPressView::OnClick(UIView& view, const ClickEvent& event) if (currentView == nullptr) { return false; } - UILabelButton* lbutt = nullptr; - lbutt = static_cast(currentView); RemoveLview(); if (currentView == buttUninstall_) { uninstall_(app_); diff --git a/launcher/launcher/src/main/cpp/swipe_view.h b/launcher/launcher/src/main/cpp/swipe_view.h index 6034ae8..03147d2 100755 --- a/launcher/launcher/src/main/cpp/swipe_view.h +++ b/launcher/launcher/src/main/cpp/swipe_view.h @@ -81,10 +81,10 @@ public: void InstallApp(AppInfo* app); void Callback() override { - char tmp[TMP_BUF_SIZE] = { 0 }; time_t t = time(nullptr); struct tm* st = localtime(&t); if (st != nullptr) { + char tmp[TMP_BUF_SIZE] = {0}; int ret = sprintf_s(tmp, sizeof(tmp), "%02d : %02d", st->tm_hour, st->tm_min); if (ret != LAUNCHER_PARAMERROR) { lableTitle_->SetText(tmp); diff --git a/launcher/launcher/src/main/cpp/time_weather_view.h b/launcher/launcher/src/main/cpp/time_weather_view.h index 3259e66..1aeb488 100755 --- a/launcher/launcher/src/main/cpp/time_weather_view.h +++ b/launcher/launcher/src/main/cpp/time_weather_view.h @@ -43,7 +43,7 @@ public: explicit TimeWeatherView(UIViewGroup* viewGroup); virtual ~TimeWeatherView(); void SetStyle(Style sty); - void SetPosion(int16_t width, int16_t height, int16_t x, int16_t y); + void SetPosion(int16_t x, int16_t y, int16_t height, int16_t width); void SetUpView(); void SetUpTimeView(); diff --git a/launcher/launcher/src/main/cpp/view_group_page.h b/launcher/launcher/src/main/cpp/view_group_page.h index b4d29d5..3f02979 100755 --- a/launcher/launcher/src/main/cpp/view_group_page.h +++ b/launcher/launcher/src/main/cpp/view_group_page.h @@ -33,8 +33,8 @@ public: virtual ~ViewGroupPage(); void SetMatrix(int16_t rows, int16_t cols); bool AddApp(AppInfo* pAppInfo); - bool RemoveApp(const char* appName); - bool FindApp(AppInfo* pAppInfo); + bool RemoveApp(const char* pAppName); + bool FindApp(AppInfo* pApp); void SetScale(double scale); protected: diff --git a/setting/setting/src/main/cpp/app_ability_slice.cpp b/setting/setting/src/main/cpp/app_ability_slice.cpp index da1c662..c15a14e 100755 --- a/setting/setting/src/main/cpp/app_ability_slice.cpp +++ b/setting/setting/src/main/cpp/app_ability_slice.cpp @@ -117,9 +117,6 @@ void AppAbilitySlice::SetAnAppInfo(const int count, BundleInfo& pBundleInfo) printf("[ERROR]strcpy_s pBundleInfo.bundleName failed, err = %d\n", err); return; } - for (size_t i = 0; i < strlen(pBundleInfo.bundleName); i++) { - buff[i] = pBundleInfo.bundleName[i]; - } SetAppButtonListener(pBundleInfo.bundleName); itemView->SetOnClickListener(buttonAppInfoListener_); scrollView_->Add(itemView); diff --git a/setting/setting/src/main/cpp/app_info_ability_slice.h b/setting/setting/src/main/cpp/app_info_ability_slice.h index b1a6e80..4520ad6 100755 --- a/setting/setting/src/main/cpp/app_info_ability_slice.h +++ b/setting/setting/src/main/cpp/app_info_ability_slice.h @@ -123,7 +123,7 @@ private: void PermissionInfoList(); void SetAppPermissionInfo(int index, PermissionSaved& permissions); - char bundleName_[128]; + char bundleName_[128] = {0}; }; } // namespace OHOS diff --git a/setting/setting/src/main/cpp/event_listener.h b/setting/setting/src/main/cpp/event_listener.h index 980df14..51f181e 100755 --- a/setting/setting/src/main/cpp/event_listener.h +++ b/setting/setting/src/main/cpp/event_listener.h @@ -30,10 +30,7 @@ public: ~EventListener() override = default; EventListener(OnEventFunc onClick, OnEventFunc onLongPress) - { - onClick_ = std::move(onClick); - onLongPress_ = std::move(onLongPress); - } + : onClick_(std::move(onClick)), onLongPress_(std::move(onLongPress)) {} bool OnClick(UIView& view, const ClickEvent &event) override { diff --git a/setting/setting/src/main/cpp/wpa_work.c b/setting/setting/src/main/cpp/wpa_work.c index a3170e8..ac64010 100755 --- a/setting/setting/src/main/cpp/wpa_work.c +++ b/setting/setting/src/main/cpp/wpa_work.c @@ -464,10 +464,9 @@ int InitControlInterface() void* WpaScanThread(void *args) { int mySleep = 2; - int ret = 0; sleep(mySleep); if (g_monitorConn == NULL) { - ret = InitControlInterface(); + int ret = InitControlInterface(); printf("%s:%d [INFO] InitControlInterface return %d.\n", __FUNCTION__, __LINE__, ret); if (ret == -1) { return NULL; -- Gitee