Fixed two new issues found by coverity

This commit is contained in:
Jaroslav Škarvada 2020-05-13 22:05:04 +02:00
parent 0f4ad95568
commit 4ac2db963d
2 changed files with 44 additions and 1 deletions

View File

@ -0,0 +1,37 @@
diff --git a/src/cpu/intel_cpus.cpp b/src/cpu/intel_cpus.cpp
index 370b762..8af033b 100644
--- a/src/cpu/intel_cpus.cpp
+++ b/src/cpu/intel_cpus.cpp
@@ -155,8 +155,10 @@ void intel_util::byt_has_ahci()
if (!dir)
byt_ahci_support=0;
else
+ {
byt_ahci_support=1;
- closedir(dir);
+ closedir(dir);
+ }
}
int intel_util::get_byt_ahci_support()
diff --git a/src/devices/devfreq.cpp b/src/devices/devfreq.cpp
index c958865..0509d0f 100644
--- a/src/devices/devfreq.cpp
+++ b/src/devices/devfreq.cpp
@@ -229,7 +229,6 @@ static void devfreq_dev_callback(const char *d_name)
void create_all_devfreq_devices(void)
{
- struct dirent *entry;
int num = 0;
std::string p = "/sys/class/devfreq/";
@@ -240,7 +239,7 @@ void create_all_devfreq_devices(void)
return;
}
- while((entry = readdir(dir)) != NULL)
+ while(readdir(dir) != NULL)
num++;
if (num == 2) {

View File

@ -1,6 +1,6 @@
Name: powertop
Version: 2.12
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Power consumption monitor
License: GPLv2
@ -10,6 +10,8 @@ Source1: powertop.service
# Sent upstream
Patch0: powertop-2.7-always-create-params.patch
# https://github.com/fenrus75/powertop/pull/46
Patch1: powertop-2.12-coverity-fixes.patch
BuildRequires: gettext-devel, ncurses-devel, pciutils-devel, zlib-devel, libnl3-devel
BuildRequires: automake, libtool, systemd, autoconf-archive
BuildRequires: gcc, gcc-c++
@ -25,6 +27,7 @@ computer use more power than necessary while it is idle.
%prep
%setup -q
%patch0 -p1 -b .always-create-params
%patch1 -p1 -b .coverity-fixes
echo "v%{version}" > version-long
echo '"v%{version}"' > version-short
@ -67,6 +70,9 @@ touch %{_localstatedir}/cache/powertop/{saved_parameters.powertop,saved_results.
%{_datadir}/bash-completion/completions/powertop
%changelog
* Wed May 13 2020 Jaroslav Škarvada <jskarvad@redhat.com> - 2.12-2
- Fixed two new issues found by coverity
* Wed Apr 22 2020 Jaroslav Škarvada <jskarvad@redhat.com> - 2.12-1
- New version
Resolves: rhbz#1820409