[PATCH] Survive CCR dive logs w/o marked DILUENT/OXYGEN cylinders

Dirk Hohndel dirk at hohndel.org
Sat Nov 22 16:22:48 PST 2014


On Sat, Nov 22, 2014 at 09:15:04PM +0100, Robert C. Helling wrote:
> 
> I doubt that this is the correct approach (designate roles to random cylinders). Is is almost always not the correct thing to do.
> 
> Better do propper error checking and e.g. simply don’t attempt to plot
> an o2 pressure line if we don’t have an o2 cylinder. Here is a patch
> that adds error checking for get_cylinder_idx_by_use() in all places
> where it is used.

Sadly Apple Mail.Crap turns the attachment into a binary type and so I
can't easily quote it in my email...

diff --git a/dive.c b/dive.c
index 5a8da0119a83..45b8f96ae077 100644
--- a/dive.c
+++ b/dive.c
@@ -723,6 +723,8 @@ void per_cylinder_mean_depth(struct dive *dive, struct
divecomputer *dc, int *me
                        // Do the same for the  O2 cylinder
                        int o2_cyl = get_cylinder_idx_by_use(dive, OXYGEN);
                        mean[o2_cyl] = dc->meandepth.mm;
+                       if (o2_cyl < 0)
+                               return;
                        duration[o2_cyl] = dc->duration.seconds;

Look at the line RIGHT before the first inserted line... I'll move your
code one line higher :-)

Regarding your question if we can simply return from
fill_missing_tank_pressures() if there is no O2 cylinder... I think we
should. I actually wonder if we shouldn't have a test way higher up in the
stack that says something like "if this is a CCR dive and we don't have a
diluent cylinder and an O2 cylinder, something is seriously messed up...

/D


More information about the subsurface mailing list