-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Labels
area: SamplesSamplesSamplesarea: SensorsSensorsSensorsbugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bugLow impact/importance bug
Description
Hi,
As described in the project API documentation, function sensor_trigger_set() is used to activate a sensor's trigger and set the trigger handler. It returns 0 if successful, negative errno code if failure. But as shown in the following codes, the return value is not error checked before it is assigned by another function.
zephyr/samples/sensor/sht3xd/src/main.c
Lines 51 to 61 in 0a0404d
| if (rc == 0) { | |
| rc = sensor_trigger_set(dev, &trig, trigger_handler); | |
| } | |
| printf("Alert outside %d..%d %%RH got %d\n", lo_thr.val1, | |
| hi_thr.val1, rc); | |
| #endif | |
| while (true) { | |
| struct sensor_value temp, hum; | |
| rc = sensor_sample_fetch(dev); |
But, the return values of the function from other call sites are all checked. See the following code,
zephyr/samples/sensor/sm351lt/src/main.c
Lines 72 to 76 in 0a0404d
| rc = sensor_trigger_set(sensor, &trig, trigger_handler); | |
| if (rc != 0) { | |
| printf("Failed to set trigger: %d\n", rc); | |
| return; | |
| } |
Metadata
Metadata
Assignees
Labels
area: SamplesSamplesSamplesarea: SensorsSensorsSensorsbugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bugLow impact/importance bug