From dd96de7379d68659eed8b4c795da1e4b57d3e734 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Tue, 10 Apr 2018 09:27:22 +0800 Subject: Hopefully fixed some segmentation faults. Added init script for OpenRC. Fixed compiler warnings. --- sensors.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'sensors.cpp') diff --git a/sensors.cpp b/sensors.cpp index 8817528..3b6b1e0 100644 --- a/sensors.cpp +++ b/sensors.cpp @@ -103,7 +103,7 @@ void SensorBase::enable_scan_element(std::string elem) ),std::make_tuple(idx,elem_base,st) ); } -void SensorBase::init(int id,std::string _sensor_basename) +bool SensorBase::init(int id,std::string _sensor_basename) { sysfspath=IIODEV_SYSFS_PATH_BASE+std::to_string(id); devbufpath=DEV_PATH+std::to_string(id); @@ -123,7 +123,12 @@ void SensorBase::init(int id,std::string _sensor_basename) update_values(); enable_buffer(); devfd=open(devbufpath.c_str(),O_RDONLY); - if(!~devfd)LOG('E',"failed to open the iio buffer device: %s",devbufpath.c_str()); + if(!~devfd) + { + LOG('E',"failed to open the iio buffer device: %s",devbufpath.c_str()); + return 1; + } + return 0; } void SensorBase::deinit() { -- cgit v1.2.3