Blame SOURCES/0021-covscan-remove-unused-vars-mark-private-func-static-return-values.patch

379fd8
From 07416268889f95e1495fb3d7b856de1c502870ba Mon Sep 17 00:00:00 2001
379fd8
From: Jaroslav Rohel <jrohel@redhat.com>
379fd8
Date: Wed, 21 Jul 2021 11:15:50 +0200
379fd8
Subject: [PATCH] covscan: remove unused vars, mark private func static, return values
379fd8
379fd8
The `begin` and `end` variables were not used
379fd8
in `ModulePackageContainer::updateFailSafeData`. Removed.
379fd8
379fd8
The `checksum` in "utils.cpp" is a private (static) function.
379fd8
379fd8
Added check of return value of `dnf_copy_recursive` function in unit test.
379fd8
379fd8
In the `install` in the "goal-py.cpp" file:
379fd8
Explicitly ignores the return values of `hy_goal_install` and
379fd8
`hy_goal_install_optional`. The functions always return zero.
379fd8
Explicitly ignores the return values of `hy_goal_install_selector` and
379fd8
`hy_goal_install_selector_optional`. The `error` argument is used instead.
379fd8
---
379fd8
 libdnf/module/ModulePackageContainer.cpp           | 2 --
379fd8
 libdnf/utils/utils.cpp                             | 2 +-
379fd8
 python/hawkey/goal-py.cpp                          | 8 ++++----
379fd8
 tests/libdnf/module/ModulePackageContainerTest.cpp | 3 ++-
379fd8
 4 files changed, 7 insertions(+), 8 deletions(-)
379fd8
379fd8
diff --git a/libdnf/module/ModulePackageContainer.cpp b/libdnf/module/ModulePackageContainer.cpp
379fd8
index c0ad126..efab497 100644
379fd8
--- a/libdnf/module/ModulePackageContainer.cpp
379fd8
+++ b/libdnf/module/ModulePackageContainer.cpp
379fd8
@@ -1656,8 +1656,6 @@ void ModulePackageContainer::updateFailSafeData()
379fd8
     if (pImpl->activatedModules) {
379fd8
         std::vector<ModulePackage *> latest = pImpl->getLatestActiveEnabledModules();
379fd8
 
379fd8
-        auto begin = fileNames.begin();
379fd8
-        auto end = fileNames.end();
379fd8
         if (g_mkdir_with_parents(pImpl->persistDir.c_str(), 0755) == -1) {
379fd8
             const char * errTxt = strerror(errno);
379fd8
             auto logger(Log::getLogger());
379fd8
diff --git a/libdnf/utils/utils.cpp b/libdnf/utils/utils.cpp
379fd8
index 450718d..15f5275 100644
379fd8
--- a/libdnf/utils/utils.cpp
379fd8
+++ b/libdnf/utils/utils.cpp
379fd8
@@ -301,7 +301,7 @@ void decompress(const char * inPath, const char * outPath, mode_t outMode, const
379fd8
     fclose(inFile);
379fd8
 }
379fd8
 
379fd8
-void checksum(const char * type, const char * inPath, const char * checksum_valid, bool * valid_out, gchar ** calculated_out)
379fd8
+static void checksum(const char * type, const char * inPath, const char * checksum_valid, bool * valid_out, gchar ** calculated_out)
379fd8
 {
379fd8
     GError * errP{nullptr};
379fd8
     gboolean valid;
379fd8
diff --git a/python/hawkey/goal-py.cpp b/python/hawkey/goal-py.cpp
379fd8
index 2641a1d..5bbb959 100644
379fd8
--- a/python/hawkey/goal-py.cpp
379fd8
+++ b/python/hawkey/goal-py.cpp
379fd8
@@ -281,15 +281,15 @@ install(_GoalObject *self, PyObject *args, PyObject *kwds) try
379fd8
 
379fd8
     if (flags & HY_WEAK_SOLV) {
379fd8
         if (pkg) {
379fd8
-            hy_goal_install_optional(self->goal, pkg);
379fd8
+            (void)hy_goal_install_optional(self->goal, pkg);
379fd8
         } else {
379fd8
-            hy_goal_install_selector_optional(self->goal, sltr, &error);
379fd8
+            (void)hy_goal_install_selector_optional(self->goal, sltr, &error);
379fd8
         }
379fd8
     } else {
379fd8
         if (pkg) {
379fd8
-            hy_goal_install(self->goal, pkg);
379fd8
+            (void)hy_goal_install(self->goal, pkg);
379fd8
         } else {
379fd8
-            hy_goal_install_selector(self->goal, sltr, &error);
379fd8
+            (void)hy_goal_install_selector(self->goal, sltr, &error);
379fd8
         }
379fd8
     }
379fd8
     return op_error2exc(error);
379fd8
diff --git a/tests/libdnf/module/ModulePackageContainerTest.cpp b/tests/libdnf/module/ModulePackageContainerTest.cpp
379fd8
index b2cf170..6360a0c 100644
379fd8
--- a/tests/libdnf/module/ModulePackageContainerTest.cpp
379fd8
+++ b/tests/libdnf/module/ModulePackageContainerTest.cpp
379fd8
@@ -17,7 +17,8 @@ void ModulePackageContainerTest::setUp()
379fd8
     char *retptr = mkdtemp(tmpdir);
379fd8
     CPPUNIT_ASSERT(retptr);
379fd8
     char * etc_target = g_strjoin(NULL, tmpdir, "/etc", NULL);
379fd8
-    dnf_copy_recursive(TESTDATADIR "/modules/etc", etc_target, &error);
379fd8
+    auto ret = dnf_copy_recursive(TESTDATADIR "/modules/etc", etc_target, &error);
379fd8
+    g_assert_true(ret);
379fd8
     g_assert_no_error(error);
379fd8
     g_free(etc_target);
379fd8
 
379fd8
--
379fd8
libgit2 1.0.1
379fd8