From f3c4b3ef578830679e312ce2efb706499db0b1c3 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Wed, 18 Jun 2014 16:09:09 +0200 Subject: prevent a crash when sysfs and proc are not readable The program used to return an empty list of devices. Nevertheless, the method printTraffic of TrafficWindow does not handle empty lists. Fixed by throwing an exception whenever proc and sysfs are both unaccessible. Signed-off-by: Olivier Gayot --- src/devreader-linux.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/devreader-linux.cpp') diff --git a/src/devreader-linux.cpp b/src/devreader-linux.cpp index 5b6e9eb..85824cd 100644 --- a/src/devreader-linux.cpp +++ b/src/devreader-linux.cpp @@ -14,6 +14,8 @@ #include #include +#include + using namespace std; bool DevReaderLinux::isAvailable() @@ -28,6 +30,6 @@ list DevReaderLinux::findAllDevices() else if(DevReaderLinuxProc::isAvailable()) return DevReaderLinuxProc::findAllDevices(); else - return list(); + throw std::runtime_error("neither sysfs nor proc is available"); } -- cgit v1.2.3