acpitool/var-line.patch
Al Stone 8cd89eeab0 Did a lot of cleanup and bug fixing, trying to make this viable
Signed-off-by: Al Stone <ahs3@redhat.com>
2018-10-26 15:11:23 -06:00

48 lines
1.5 KiB
Diff

From 2f16822b9487a951ac898fd6703a7f8c7cd4ce06 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Sat, 15 Nov 2014 11:59:37 +0100
Subject: [PATCH] Do not assume fixed line lengths for /proc/acpi/wakeup file
The lines in that file might be equal or longer than 40 characters, which
means that the getline() call will truncate them, possibly at the wrong
place, and then be unable to proceed, as subsequent calls will get stuck
waiting for input that is not coming.
---
src/acpitool.cpp | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/acpitool.cpp b/src/acpitool.cpp
index f3beeca..e85a7c1 100644
--- a/src/acpitool.cpp
+++ b/src/acpitool.cpp
@@ -416,7 +416,8 @@ int Do_Fan_Info(int verbose)
int Show_WakeUp_Devices(int verbose)
{
ifstream file_in;
- char *filename, str[40];
+ char *filename;
+ string str;
filename = "/proc/acpi/wakeup";
@@ -437,14 +438,14 @@ int Show_WakeUp_Devices(int verbose)
}
else
{
- file_in.getline(str, 40); // first line are just headers //
+ getline(file_in, str); // first line are just headers //
cout<<" "<<str<<endl;
cout<<" ---------------------------------------"<<endl;
int t = 1;
while(!file_in.eof())
{
- file_in.getline(str, 40);
- if (strlen(str)!=0) // avoid printing last empty line //
+ getline(file_in, str);
+ if (str.length()!=0) // avoid printing last empty line //
{
cout<<" "<<t<<". "<<str<<endl;
t++;
--
2.1.3