summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-02 20:39:19 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-02 20:39:19 -0800
commitd1af75357de293a629b9834661575c80b09facce (patch)
tree309f039950e205306ab561e934890ed3c46a7161 /dive.c
parentcef150d7dcd75a76ac810b9cf33e90e845561129 (diff)
downloadsubsurface-d1af75357de293a629b9834661575c80b09facce.tar.gz
Partial revert of commit 6cf3787a0ed1
Commit 6cf3787a0ed1 ("Remove code that zeroes out duplicate oxygen sensor and temperature values") incorrectly removes the code that zeroes out the temperatures. Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/dive.c b/dive.c
index adc8d0d18..32ac25e2a 100644
--- a/dive.c
+++ b/dive.c
@@ -1183,6 +1183,7 @@ static void fixup_dive_dc(struct dive *dive, struct divecomputer *dc)
int maxdepth = dc->maxdepth.mm;
int mintemp = 0;
int lastdepth = 0;
+ int lasttemp = 0;
int lastpressure = 0, lasto2pressure = 0;
int pressure_delta[MAX_CYLINDERS] = { INT_MAX, };
int first_cylinder;
@@ -1247,6 +1248,16 @@ static void fixup_dive_dc(struct dive *dive, struct divecomputer *dc)
fixup_pressure(dive, sample, OXYGEN);
if (temp) {
+ /*
+ * If we have consecutive identical
+ * temperature readings, throw away
+ * the redundant ones.
+ */
+ if (lasttemp == temp)
+ sample->temperature.mkelvin = 0;
+ else
+ lasttemp = temp;
+
if (!mintemp || temp < mintemp)
mintemp = temp;
}