[PATCH 1/5] Fix dive trip selection for merging
Linus Torvalds
torvalds at linux-foundation.org
Sun Nov 25 20:25:11 PST 2012
From: Linus Torvalds <torvalds at linux-foundation.org>
Date: Sun, 25 Nov 2012 16:51:55 -0800
Subject: [PATCH 1/5] Fix dive trip selection for merging
When picking the "better" trip, we stupidly looked not at the trip
location, but at the _dive_ location.
Which obviously didn't actually pick the "better" trip information at
all, since it never actually looked at the trip itself.
Oops.
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
---
I'm back to looking at the dive trip management code. Here are five
patches that work on making it more robust.
dive.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/dive.c b/dive.c
index 72794f9600be..af14f0fb8189 100644
--- a/dive.c
+++ b/dive.c
@@ -847,6 +847,8 @@ static void pick_trip(struct dive *res, struct dive *pick)
*/
static void merge_trip(struct dive *res, struct dive *a, struct dive *b)
{
+ dive_trip_t *atrip, *btrip;
+
/*
* The larger tripflag is more relevant: we prefer
* take manually assigned trips over auto-generated
@@ -858,17 +860,20 @@ static void merge_trip(struct dive *res, struct dive *a, struct dive *b)
if (a->tripflag < b->tripflag)
goto pick_b;
- /*
- * Ok, so the divetrips are equally "important".
- * Pick the one with the better description.
- */
- if (!a->location)
+ /* Otherwise, look at the trip data and pick the "better" one */
+ atrip = a->divetrip;
+ btrip = b->divetrip;
+ if (!atrip)
+ goto pick_b;
+ if (!btrip)
+ goto pick_a;
+ if (!atrip->location)
goto pick_b;
- if (!b->location)
+ if (!btrip->location)
goto pick_a;
- if (!a->notes)
+ if (!atrip->notes)
goto pick_b;
- if (!b->notes)
+ if (!btrip->notes)
goto pick_a;
/*
--
1.8.0.dirty
More information about the subsurface
mailing list