From: Linus Torvalds Date: Wed, 31 Aug 2011 21:36:53 +0000 (-0700) Subject: dive parsing: enforce maxdepth and dive duration X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=c7e29063722a57211e00acc5ee98e05c37f89a99;p=ext%2Fsubsurface.git 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 --- diff --git a/parse.c b/parse.c index 58476ef..58d446d 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++; }