Should we be merging dives with zero depth? I do not see any real reason to have the check in place, but it would not be the first time I am missing something. Of course, it does not really make sense to have dives with zero depth, but as the bug report is from importing, it really makes even less sense to have a 0 depth dive multiple times in the log.
0001 is the actual change, indentation fix is postponed to 0002 to show the change clearly. miika
From 4d875192b865d9abc3c99bce1884aec58d5e1510 Mon Sep 17 00:00:00 2001 From: Miika Turkia <[email protected]> Date: Thu, 4 Feb 2016 19:44:31 +0200 Subject: [PATCH 2/2] Fix indentation Signed-off-by: Miika Turkia <[email protected]> --- subsurface-core/dive.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/subsurface-core/dive.c b/subsurface-core/dive.c index 9cc3707..102fef9 100644 --- a/subsurface-core/dive.c +++ b/subsurface-core/dive.c @@ -2162,22 +2162,22 @@ static int find_sample_offset(struct divecomputer *a, struct divecomputer *b) */ static int similar(unsigned long a, unsigned long b, unsigned long expected) { - unsigned long min, max, diff; + unsigned long min, max, diff; - min = a; - max = b; - if (a > b) { - min = b; - max = a; - } - diff = max - min; - - /* Smaller than expected difference? */ - if (diff < expected) - return 1; - /* Error less than 10% or the maximum */ - if (diff * 10 < max) - return 1; + min = a; + max = b; + if (a > b) { + min = b; + max = a; + } + diff = max - min; + + /* Smaller than expected difference? */ + if (diff < expected) + return 1; + /* Error less than 10% or the maximum */ + if (diff * 10 < max) + return 1; return 0; } -- 2.5.0
From 2e4553d922bf0c88859968ec3b6021fe4dbec452 Mon Sep 17 00:00:00 2001 From: Miika Turkia <[email protected]> Date: Thu, 4 Feb 2016 19:42:15 +0200 Subject: [PATCH 1/2] Allow merging of dives with zero depth Fixes #1003 Signed-off-by: Miika Turkia <[email protected]> --- subsurface-core/dive.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/subsurface-core/dive.c b/subsurface-core/dive.c index 9af6379..9cc3707 100644 --- a/subsurface-core/dive.c +++ b/subsurface-core/dive.c @@ -2162,7 +2162,6 @@ static int find_sample_offset(struct divecomputer *a, struct divecomputer *b) */ static int similar(unsigned long a, unsigned long b, unsigned long expected) { - if (a && b) { unsigned long min, max, diff; min = a; @@ -2179,7 +2178,6 @@ static int similar(unsigned long a, unsigned long b, unsigned long expected) /* Error less than 10% or the maximum */ if (diff * 10 < max) return 1; - } return 0; } -- 2.5.0
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
