aboutsummaryrefslogtreecommitdiff
path: root/sensors.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2018-04-10 09:27:22 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2018-04-10 09:27:22 +0800
commitdd96de7379d68659eed8b4c795da1e4b57d3e734 (patch)
tree9a5cad0c413402bb2fdde627f9dc81f29ee1f371 /sensors.cpp
parent6bdb9028af9a5256fbb47b942843e49aef7e3aa1 (diff)
downloadlightsd-dd96de7379d68659eed8b4c795da1e4b57d3e734.tar.xz
Hopefully fixed some segmentation faults.
Added init script for OpenRC. Fixed compiler warnings.
Diffstat (limited to 'sensors.cpp')
-rw-r--r--sensors.cpp9
1 files changed, 7 insertions, 2 deletions
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()
{