summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-08-31 14:36:53 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-08-31 14:36:53 -0700
commitc7e29063722a57211e00acc5ee98e05c37f89a99 (patch)
treec3675c9b9ca204ebb8fd22291d2890f1aaa6648e
parentee56021dfbc3bcc12f5917cdf481cc96c51a2b89 (diff)
downloadsubsurface-c7e29063722a57211e00acc5ee98e05c37f89a99.tar.gz
dive parsing: enforce maxdepth and dive duration
If we see samples from past the dive duration, update the dive duration. Likewise with maxdepth. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--parse.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/parse.c b/parse.c
index 58476ef15..58d446db0 100644
--- a/parse.c
+++ b/parse.c
@@ -444,9 +444,18 @@ static void sample_start(void)
static void sample_end(void)
{
- sample = NULL;
if (!dive)
return;
+
+ if (sample->time.seconds > dive->duration.seconds) {
+ if (sample->depth.mm)
+ dive->duration = sample->time;
+ }
+
+ if (sample->depth.mm > dive->maxdepth.mm)
+ dive->maxdepth.mm = sample->depth.mm;
+
+ sample = NULL;
dive->samples++;
}