Start pressure missing
torvalds at linux-foundation.org
Thu Jan 24 17:55:48 PST 2013
From: Linus Torvalds <torvalds at linux-foundation.org>
Subject: Fix overly complicated and fragile "same_cylinder" logic
The plot-info per-event 'same_cylinder' logic was fragile, and caused
us to not print the beginning pressure of the first cylinder.
In particular, there was a nasty interaction with not all plot entries
having pressures, and the whole logic that avoid some of the early
plot entries because they are fake entries that are just there to make
sure that we don't step off the edge of the world. When we then only
do certain things on the particular entries that don't have the same
cylinder as the last plot entry, things don't always happen like they
Fix this by:
- get rid of the computed "same_cylinder" state entirely. All the
cases where we use it, we might as well just look at what the last
cylinder we used was, and thus "same_cylinder" is just about testing
the current cylinder index against that last index.
- get rid of some of the edge conditions by just writing the loops
more clearly, so that they simply don't have special cases. For
example, instead of setting some "last_pressure" for a cylinder at
cylinder changes, just set the damn thing on every single sample. The
last pressure will automatically be the pressure we set last! The code
is simpler and more straightforward.
So this simplifies the code and just makes it less fragile - it
doesn't matter if the cylinder change happens to happen at a sample
that doesn't have a pressure reading, for example, because we no
longer care so deeply about exactly which sample the cylinder change
happens at. As a result, the bug Mika noticed just goes away.
Reported-by: Miika Turkia <miika.turkia at gmail.com>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
On Thu, Jan 24, 2013 at 3:11 PM, Miika Turkia <miika.turkia at gmail.com> wrote:
> The cylinder's starting pressure is not printed on the dive profile
> anymore for the firstly used cylinder.
This should fix it. Does for me, and removes more lines than it adds.
You might want to double-check the logic.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 4772 bytes
Desc: not available
More information about the subsurface