Skip to content

Missing error check of function sensor_trigger_set() #30189

@Hxinrong

Description

@Hxinrong

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.

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,

rc = sensor_trigger_set(sensor, &trig, trigger_handler);
if (rc != 0) {
printf("Failed to set trigger: %d\n", rc);
return;
}

Metadata

Metadata

Labels

area: SamplesSamplesarea: SensorsSensorsbugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions