Fix variable shadowing 66/252566/6
authorSangyoon Jang <jeremy.jang@samsung.com>
Fri, 29 Jan 2021 09:22:48 +0000 (18:22 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Wed, 26 May 2021 04:13:59 +0000 (04:13 +0000)
Fix build warnings of -Wshadow

Change-Id: I225a062ed264ff8475230e42321fdbbf048d4f4f
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
CMakeLists.txt
src/common/plugins/category_plugin.cc
src/common/shared_dirs.cc
src/common/step/backup/step_copy_backup.cc
src/common/step/filesystem/step_change_ownership_and_permission.cc
src/common/step/filesystem/step_copy.cc
src/common/step/filesystem/step_delta_patch.cc
src/common/step/filesystem/step_recover_change_owner.cc
src/common/step/security/step_signature.cc
src/common/utils/paths.cc
src/pkgdir_tool/pkgdir_tool.cc

index 011eeda..7bb5529 100644 (file)
@@ -11,7 +11,7 @@ IF(NOT CMAKE_BUILD_TYPE)
 ENDIF(NOT CMAKE_BUILD_TYPE)
 
 # Compiler flags
-SET(EXTRA_FLAGS "-Wall -Wextra -Werror -Wnon-virtual-dtor")
+SET(EXTRA_FLAGS "-Wall -Wextra -Werror -Wnon-virtual-dtor -Wshadow")
 SET(EXTRA_OPTIMIZATION_FLAGS "-Wl,--gc-sections -flto -fmerge-all-constants")
 
 SET(CMAKE_C_FLAGS_PROFILING    "-O2 ${EXTRA_FLAGS}")
index 10b9834..737982a 100644 (file)
@@ -88,9 +88,9 @@ bool CategoryPlugin::Run(xmlDocPtr /*doc_ptr*/, manifest_x* manifest,
         plugin_info_.name().c_str(),
         [](const char*, const char* appid, const char*,
             const char*, void* user_data) -> int {
-          auto* appid_list =
+          auto* list =
               static_cast<std::vector<std::string>*>(user_data);
-          appid_list->emplace_back(std::string(appid));
+          list->emplace_back(std::string(appid));
           return PMINFO_R_OK;
         },
         &appid_list) != PMINFO_R_OK) {
index b1fda3d..8e83748 100644 (file)
@@ -456,14 +456,14 @@ bool PerformExternalDirectoryCreationForAllPkgs() {
 
     ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(filter_handle,
         [](const pkgmgrinfo_pkginfo_h handle, void* user_data) -> int {
-          uid_t uid =
+          uid_t u =
               static_cast<uid_t>(reinterpret_cast<uintptr_t>(user_data));
           char* pkgid = nullptr;
 
-          int ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
-          if (ret != PMINFO_R_OK)
+          int r = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+          if (r != PMINFO_R_OK)
             return -1;
-          if (!PerformExternalDirectoryCreationForUser(uid, pkgid))
+          if (!PerformExternalDirectoryCreationForUser(u, pkgid))
             return -1;
 
           return 0;
@@ -818,7 +818,6 @@ bool CreatePerUserSharedDataDir(const std::string& pkgid) {
         return false;
     }
 
-    std::string error_message;
     if (!ci::RegisterSecurityContextForPath(pkgid, apps_rw / pkgid, uid,
         false, &error_message)) {
       LOG(ERROR) << "Failed to register security context for path: "
index 7f83059..8a7c11d 100644 (file)
@@ -191,7 +191,6 @@ bool StepCopyBackup::MoveMountPointContent(const boost::filesystem::path& from,
         return false;
       }
     } else if (bf::is_symlink(symlink_status(iter->path()))) {
-      bs::error_code error;
       bf::copy_symlink(iter->path(), to / iter->path().filename(), error);
       if (error) {
         LOG(ERROR) << "Failed to backup package symlink: " << iter->path();
index 772b078..48be8b6 100644 (file)
@@ -109,14 +109,14 @@ bool GrantDefaultPermissions(bf::path pkg_path, bool skip_symlink) {
     if (bf::is_directory(path) && path.filename() == "bin") {
       if (!GrantPermission755(path))
         return false;
-      for (auto& entry :
+      for (auto& bin_entry :
           boost::make_iterator_range(bf::directory_iterator(path), {})) {
-        auto path = entry.path();
-        if (bf::is_symlink(symlink_status(path)))
+        auto bin_path = bin_entry.path();
+        if (bf::is_symlink(symlink_status(bin_path)))
           continue;
 
-        if (bf::is_regular_file(path)) {
-          if (!GrantPermission755(path))
+        if (bf::is_regular_file(bin_path)) {
+          if (!GrantPermission755(bin_path))
             return false;
         }
       }
@@ -126,14 +126,14 @@ bool GrantDefaultPermissions(bf::path pkg_path, bool skip_symlink) {
     if (bf::is_directory(path) && path.filename() == "lib") {
       if (!GrantPermission755(path))
         return false;
-      for (auto& entry :
+      for (auto& lib_entry :
           boost::make_iterator_range(bf::directory_iterator(path), {})) {
-        auto path = entry.path();
-        if (bf::is_symlink(symlink_status(path)))
+        auto lib_path = lib_entry.path();
+        if (bf::is_symlink(symlink_status(lib_path)))
           continue;
 
-        if (bf::is_regular_file(path)) {
-          if (!GrantPermission644(path))
+        if (bf::is_regular_file(lib_path)) {
+          if (!GrantPermission644(lib_path))
             return false;
         }
       }
index d8b47b6..b90c6c0 100644 (file)
@@ -83,7 +83,6 @@ Step::Status StepCopy::process() {
             << " to: " << install_path << " directory";
 
   if (context_->storage.get() == Storage::EXTENDED) {
-    bs::error_code error;
     bf::create_symlink(install_path, context_->GetPkgPath(), error);
     if (error) {
       LOG(ERROR) << "Failed to create symlink for extended path: "
index 1c1fb46..5e65e5f 100644 (file)
@@ -211,7 +211,6 @@ bool CopySkipMount(const bf::path& from, const bf::path& to) {
         return false;
       }
     } else {
-      bs::error_code error;
       bf::copy(iter->path(), to / iter->path().filename(), error);
       if (error) {
         LOG(ERROR) << "Failed to create copy of: " << iter->path();
index 854888a..6a153a5 100644 (file)
@@ -84,15 +84,15 @@ Step::Status StepRecoverChangeOwner::RecoveryUpdate() {
 
     ci::UserList list = ci::GetUserList();
     for (auto l : list) {
-      uid_t uid = std::get<0>(l);
-      gid_t gid = std::get<1>(l);
-      bf::path apps_rw = ci::GetRootAppPath(false, uid);
+      uid_t lu = std::get<0>(l);
+      gid_t lg = std::get<1>(l);
+      bf::path apps_rw = ci::GetRootAppPath(false, lu);
       bf::path pkg_root = apps_rw / context_->pkgid.get();
-      if (!ci::SetPackageDirectoryOwnerAndPermissions(pkg_root, uid))
+      if (!ci::SetPackageDirectoryOwnerAndPermissions(pkg_root, lu))
         return Step::Status::ERROR;
 
       if (!SetSharedDirOwnershipAndPermissions(apps_rw, context_->pkgid.get(),
-              uid, gid))
+              lu, lg))
         return Step::Status::ERROR;
     }
   } else {
@@ -143,4 +143,3 @@ Step::Status StepRecoverChangeOwner::ChangeOwnershipIconsAndManifest(
 
 }  // namespace filesystem
 }  // namespace common_installer
-
index 39553e4..6c7abdd 100644 (file)
@@ -100,8 +100,7 @@ Step::Status StepSignature::process() {
   }
 
   if (level == PrivilegeLevel::UNTRUSTED) {
-    std::string error_message =
-        "Unsigned applications can not be installed";
+    error_message = "Unsigned applications can not be installed";
     on_error(Status::SIGNATURE_ERROR, error_message);
     return Status::SIGNATURE_ERROR;
   }
index 54f8706..01b8949 100644 (file)
@@ -134,9 +134,9 @@ bool IsExtendedStorageAvailable() {
           return true;
         if (state != STORAGE_STATE_MOUNTED)
           return true;
-        bool* is_available = static_cast<bool*>(user_data);
+        bool* available = static_cast<bool*>(user_data);
         if (bf::exists(path))
-          *is_available = true;
+          *available = true;
         // Stop iteration
         return false;
       },
index e5925db..0a2db04 100644 (file)
@@ -137,13 +137,13 @@ void PkgdirToolService::OnBusAcquired(
   UNUSED(user_data);
   GError* err = nullptr;
   GDBusInterfaceVTable vtable = {
-    [](GDBusConnection* connection, const gchar* sender,
+    [](GDBusConnection* conn, const gchar* sender,
         const gchar* object_path, const gchar* interface_name,
         const gchar* method_name, GVariant* parameters,
-        GDBusMethodInvocation* invocation, gpointer user_data) {
-      reinterpret_cast<PkgdirToolService*>(user_data)->HandleMethodCall(
-          connection, sender, object_path, interface_name, method_name,
-          parameters, invocation, user_data);
+        GDBusMethodInvocation* invocation, gpointer data) {
+      reinterpret_cast<PkgdirToolService*>(data)->HandleMethodCall(
+          conn, sender, object_path, interface_name, method_name,
+          parameters, invocation, data);
     },
     nullptr, nullptr, {0, }
   };