From 4ac2db963d9ad5241728a5950a04a5a6ca2eb88c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= Date: Wed, 13 May 2020 22:05:04 +0200 Subject: [PATCH] Fixed two new issues found by coverity --- powertop-2.12-coverity-fixes.patch | 37 ++++++++++++++++++++++++++++++ powertop.spec | 8 ++++++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 powertop-2.12-coverity-fixes.patch diff --git a/powertop-2.12-coverity-fixes.patch b/powertop-2.12-coverity-fixes.patch new file mode 100644 index 0000000..66d3371 --- /dev/null +++ b/powertop-2.12-coverity-fixes.patch @@ -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) { diff --git a/powertop.spec b/powertop.spec index b5a7d1f..a8a45db 100644 --- a/powertop.spec +++ b/powertop.spec @@ -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 - 2.12-2 +- Fixed two new issues found by coverity + * Wed Apr 22 2020 Jaroslav Škarvada - 2.12-1 - New version Resolves: rhbz#1820409