summaryrefslogtreecommitdiff
path: root/src/devreader-linux.cpp
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2014-06-18 16:09:09 +0200
committerOlivier Gayot <duskcoder@gmail.com>2014-06-18 16:48:12 +0200
commitf3c4b3ef578830679e312ce2efb706499db0b1c3 (patch)
tree581eb014e11fc3b1f02b6e4afd3a8333e29c113b /src/devreader-linux.cpp
parent0e03940802cebefdf6b0597a154bd9395e1af4d2 (diff)
prevent a crash when sysfs and proc are not readableHEADmaster
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 <duskcoder@gmail.com>
Diffstat (limited to 'src/devreader-linux.cpp')
-rw-r--r--src/devreader-linux.cpp4
1 files changed, 3 insertions, 1 deletions
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 <string>
#include <list>
+#include <stdexcept>
+
using namespace std;
bool DevReaderLinux::isAvailable()
@@ -28,6 +30,6 @@ list<string> DevReaderLinux::findAllDevices()
else if(DevReaderLinuxProc::isAvailable())
return DevReaderLinuxProc::findAllDevices();
else
- return list<string>();
+ throw std::runtime_error("neither sysfs nor proc is available");
}