[PATCH 1/2] Get rid of dive->{start,end}

Linus Torvalds torvalds at linux-foundation.org
Sun Feb 3 21:34:03 PST 2013


From: Linus Torvalds <torvalds at linux-foundation.org>
Date: Mon, 4 Feb 2013 16:21:33 +1100
Subject: [PATCH 1/2] Get rid of dive->{start,end}

We had this special logic to not show the end of a dive when a dive
computer shows a series of very shallow samples (basically snorkeling
back to shore after the dive ended).  However, that logic ended up being
global per dive, which is very annoying when you have two or more dive
computers, and it decides to cut off the second one because the first
one surfaces.

So get rid of this per-dive state, and just use the plot-info 'maxtime'
field for this (we never used the 'start' case anyway).  That way we
will properly cut off boring surface entries only when they are past the
end of the interesting entries of *all* dive computers, and we won't be
cutting things short.

Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
---

This is the patch that makes all 98 minutes of your dive show up, even if 
the first dive computer think it was only 90 minutes.

 dive.c    | 3 +--
 dive.h    | 1 -
 profile.c | 7 +++----
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/dive.c b/dive.c
index a0cb60ba6b3e..e054be557217 100644
--- a/dive.c
+++ b/dive.c
@@ -498,8 +498,7 @@ struct dive *fixup_dive(struct dive *dive)
 		if (sample->cns > dive->maxcns)
 			dive->maxcns = sample->cns;
 	}
-	dive->start = start;
-	dive->end = end;
+
 	/* if all the samples for a cylinder have pressure data that
 	 * is basically equidistant throw out the sample cylinder pressure
 	 * information but make sure we still have a valid start and end
diff --git a/dive.h b/dive.h
index 50a404a57f06..af1d3942bc62 100644
--- a/dive.h
+++ b/dive.h
@@ -303,7 +303,6 @@ struct dive {
 	struct dive *next, **pprev;
 	int selected;
 	gboolean downloaded;
-	int start, end;
 	timestamp_t when;
 	char *location;
 	char *notes;
diff --git a/profile.c b/profile.c
index 123f25479db7..f81d4aba3c0f 100644
--- a/profile.c
+++ b/profile.c
@@ -1577,7 +1577,8 @@ static void calculate_max_limits(struct dive *dive, struct divecomputer *dc, str
 
 			if (depth > maxdepth)
 				maxdepth = s->depth.mm;
-			if ((depth || lastdepth) && s->time.seconds > maxtime)
+			if ((depth > SURFACE_THRESHOLD || lastdepth > SURFACE_THRESHOLD) &&
+			    s->time.seconds > maxtime)
 				maxtime = s->time.seconds;
 			lastdepth = depth;
 			s++;
@@ -1601,9 +1602,7 @@ static struct plot_data *populate_plot_entries(struct dive *dive, struct divecom
 	int lastdepth, lasttime;
 	struct plot_data *plot_data;
 
-	maxtime = get_maxtime(pi);
-	if (dive->end > 0)
-		maxtime = dive->end;
+	maxtime = pi->maxtime;
 
 	/*
 	 * We want to have a plot_info event at least every 10s (so "maxtime/10+1"),
-- 
1.8.1.2.422.g08c0e7f



More information about the subsurface mailing list