Skip to content
Permalink
Browse files

samples: LSM6DSL accel fix unchecked return value sensor_trigger_set()

Inside void main(void) result of function sensor_trigger_set() is not
checked which might result that function can't set sensor type
and that error can't be handled.

Coverity-CID: 186196
Signed-off-by: Maksim Masalski <maxxliferobot@gmail.com>
  • Loading branch information...
maxxlife authored and MaureenHelm committed Apr 29, 2019
1 parent 11295c1 commit 888f4dd0963ddbc38be8dbc14fd6090266cf2ae2
Showing with 5 additions and 1 deletion.
  1. +5 −1 samples/sensor/lsm6dsl/src/main.c
@@ -128,7 +128,11 @@ void main(void)

trig.type = SENSOR_TRIG_DATA_READY;
trig.chan = SENSOR_CHAN_ACCEL_XYZ;
sensor_trigger_set(lsm6dsl_dev, &trig, lsm6dsl_trigger_handler);

if (sensor_trigger_set(lsm6dsl_dev, &trig, lsm6dsl_trigger_handler) != 0) {
printk("Could not set sensor type and channel\n");
return;
}
#endif

if (sensor_sample_fetch(lsm6dsl_dev) < 0) {

0 comments on commit 888f4dd

Please sign in to comment.
You can’t perform that action at this time.