From c7e29063722a57211e00acc5ee98e05c37f89a99 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 31 Aug 2011 14:36:53 -0700 Subject: [PATCH] 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 --- parse.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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++; }