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

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