Fixed crash when writing report on readonly filesystem

(fix-crash-on-readonly-fs patch)
This commit is contained in:
Jaroslav Škarvada 2012-11-28 16:50:19 +01:00
parent 49b6109c4f
commit 7705d9698c
2 changed files with 49 additions and 1 deletions

View File

@ -0,0 +1,41 @@
From bd72b4433fec358801afebf3f02ab899b1745c5f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= <jskarvad@redhat.com>
Date: Wed, 28 Nov 2012 16:31:38 +0100
Subject: [PATCH] report: fixed crash when writing report to RO filesystem
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
---
src/report/report.cpp | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/report/report.cpp b/src/report/report.cpp
index 51bc6a7..c018bb1 100644
--- a/src/report/report.cpp
+++ b/src/report/report.cpp
@@ -183,13 +183,16 @@ void init_report_output(char *filename_str, int iterations)
void finish_report_output(void)
{
- fprintf(stderr, _("PowerTOP outputing using base filename %s\n"), reportout.filename);
if (reporttype == REPORT_OFF)
return;
report.finish_report();
- fputs(report.get_result(), reportout.report_file);
- fdatasync(fileno(reportout.report_file));
- fclose(reportout.report_file);
+ if (reportout.report_file)
+ {
+ fprintf(stderr, _("PowerTOP outputing using base filename %s\n"), reportout.filename);
+ fputs(report.get_result(), reportout.report_file);
+ fdatasync(fileno(reportout.report_file));
+ fclose(reportout.report_file);
+ }
report.clear_result();
}
--
1.7.11.7

View File

@ -1,6 +1,6 @@
Name: powertop
Version: 2.2
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Power consumption monitor
Group: Applications/System
@ -10,6 +10,8 @@ Source0: http://01.org/powertop/sites/default/files/downloads/%{name}-%{ve
# Sent upstream
Patch0: powertop-2.0-always-create-params.patch
# Sent upstream
Patch1: powertop-2.2-fix-crash-on-readonly-fs.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: gettext, ncurses-devel, pciutils-devel, zlib-devel, libnl3-devel
@ -20,6 +22,7 @@ computer use more power than necessary while it is idle.
%prep
%setup -q
%patch0 -p1 -b .always-create-params
%patch1 -p1 -b .fix-crash-on-readonly-fs
# remove left over object files
find . -name "*.o" -exec rm {} \;
@ -52,6 +55,10 @@ rm -rf %{buildroot}
%{_mandir}/man8/powertop.8*
%changelog
* Wed Nov 28 2012 Jaroslav Škarvada <jskarvad@redhat.com> - 2.2-2
- Fixed crash when writing report on readonly filesystem
(fix-crash-on-readonly-fs patch)
* Fri Nov 23 2012 Jaroslav Škarvada <jskarvad@redhat.com> - 2.2-1
- New version
Resolves: rhbz#877373