[PATCH] Sort "loose" dives properly in-between trips

Dirk Hohndel dirk at hohndel.org
Mon Jan 7 11:41:30 PST 2013


Linus Torvalds <torvalds at linux-foundation.org> writes:

> On Mon, Jan 7, 2013 at 10:57 AM, Dirk Hohndel <dirk at hohndel.org> wrote:
>>
>> With all that said - should I apply the patch and we test it in tree, or
>> should I wait for Miika to come back and say "yes, this is good"?
>
> I think the patch we should apply is the attached one instead.
>
> HOWEVER, I can't test it with your and my dives, because the deco
> calculations get unhappy and get stuck in some infinite loop (I think
> this may be related to the other report about test-dives). Just try it
> (with or without this patch) by doing a simple
>
>     subsurface linus.xml DirkDives.xml
>
> to show how it hangs.

Yes. Known bug :-(
Actually, two known bugs. For one thing, the deco algorithm can get
stuck in this stupid loop (the one that Robert wants to do away with,
anyway). Additionally it also ends up looking at the wrong dives:

Since we do dives at the same time (duh - we are dive buddies) the logic
that tries to find the previous dives that affect the current dive
(i.e., calculate the N2/He loading we had from repetitive diving) is
completely broken.

Here is what I /think/ it should be doing.

if the dive is not in a trip, walk backwards in the dive_table until it
finds a 48h gap or a dive that is out of chronological order (i.e., it's
fine to consider dives from a trip that this dive maybe just hasn't been
added to, yet, but if there is a dive with a smaller index but a later
time, that implies that this is an overlapping trip and this dive
shouldn't be considered

if the dive is in a trip, walk backwards but just within the trip.


It's the second part I'm unsure about. I am trying to convince myself
that the first case covers all possible issues, but then I look at
something like this:

my dives:
Trip m2:
  Jan 7
  Jan 6
Trip m1:
  Jan 2
  Jan 1


your dives:
Trip y1:
  Jan 5
  Jan 4
  Jan 3

When merged this would be ordered as 

Trip m2:
  Jan 7
  Jan 6
Trip y1:
  Jan 5
  Jan 4
  Jan 3
Trip m1:
  Jan 2
  Jan 1

and without the second clause all of these dives would be considered,
even though that's clearly bogus...

/D


More information about the subsurface mailing list