void-packages/srcpkgs/powertop/patches/powertop-2.2-fix-crash-on-r...

42 lines
1.3 KiB
Diff

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
--- src/report/report.cpp
+++ 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