[Subsurface-divelog/subsurface] Don't show cylinder pressure graph for wrong dc for merged dives (#815)
Linus Torvalds
torvalds at linux-foundation.org
Thu Nov 16 18:05:09 PST 2017
On Thu, Nov 16, 2017 at 7:25 AM, Stefan Fuchs <sfuchs at gmx.de> wrote:
>
> Hi Linus, hi everybody,
Hmm.
That code is a bit too confusing, and I think the proposed change
isn't wrong, but it makes that "too confusing" part worse.
For example, you do this:
if (!has_gaschange_event(dive, dc, i) && cyl_used_somewhere)
 continue;

and that's pretty pointless, because we already have that
"has_gaschange_event()" knowledge: it's that "seen[]" array.
So honestly, my reaction to this is that first we should de-confuse
that function, and then instead work on exactly that "seen[]" array.
Basically, right now, "seen[]" has two values: 0 or 1 depending on
whether this cylinder has been used by this particular dive computer.
But let's just extend on that existing knowledge instead, and make it
be "-1" if a cylinder is explicitly not interesting.
And I think it merits some cleanup first.
Something like the attached three patches?
NOTE! Untested. And it's not smaller than your patch. I just think
it's a bit more explicit about what it does, and thus maybe clearer.
But I don't _hate_ your patch either.
Linus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Clean-up-confusing-code-in-setup_gas_sensor_pressure.patch
Type: text/x-patch
Size: 1223 bytes
Desc: not available
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20171116/b0b46710/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Properly-declare-has_gaschange_event-function.patch
Type: text/x-patch
Size: 2138 bytes
Desc: not available
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20171116/b0b46710/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Don-t-show-cylinder-pressures-for-other-dive-compute.patch
Type: text/x-patch
Size: 3433 bytes
Desc: not available
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20171116/b0b46710/attachment-0002.bin>
More information about the subsurface
mailing list