-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Closed
Copy link
Labels
StalebugThe 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 API documentation, function sensor_sample_fetch() fetches a sample from the sensor and stores it in an internal driver buffer, returns 0 if successful, and returns negative errno code if failure. And the return value of function sensor_channel_get() has the same format. However, as shown in the following code, two missing error checks take place, sensor_sample_fetch() and sensor_channel_get().
zephyr/samples/sensor/mcp9808/src/main.c
Lines 89 to 91 in 21cac03
| sensor_sample_fetch(dev); | |
| sensor_channel_get(dev, SENSOR_CHAN_AMBIENT_TEMP, &temp); | |
And, I see, in the same file, the return values of the two functions are checked. See the following code, for example.
zephyr/samples/sensor/mcp9808/src/main.c
Lines 127 to 137 in 21cac03
| rc = sensor_sample_fetch(dev); | |
| if (rc != 0) { | |
| printf("sensor_sample_fetch error: %d\n", rc); | |
| break; | |
| } | |
| rc = sensor_channel_get(dev, SENSOR_CHAN_AMBIENT_TEMP, &temp); | |
| if (rc != 0) { | |
| printf("sensor_channel_get error: %d\n", rc); | |
| break; | |
| } |
Metadata
Metadata
Assignees
Labels
StalebugThe 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