core: fix detection of used cylinders

The cylinder_with_sensor_sample() function only tests "do we have a mapping to
this cylinder for this sample". It also needs to test if there are any tank
pressure readings for that cylinder.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Linus Torvalds 2022-04-28 12:30:10 -07:00 committed by Dirk Hohndel
parent 51590853eb
commit bdeeba4a67

View file

@ -3495,8 +3495,11 @@ extern bool cylinder_with_sensor_sample(const struct dive *dive, int cylinder_id
{
for (const struct divecomputer *dc = &dive->dc; dc; dc = dc->next) {
for (int i = 0; i < dc->samples; ++i) {
struct sample *sample = dc->sample + i;
for (int j = 0; j < MAX_SENSORS; ++j) {
if (dc->sample[i].sensor[j] == cylinder_id)
if (!sample->pressure[j].mbar)
continue;
if (sample->sensor[j] == cylinder_id)
return true;
}
}