diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-03-03 21:53:26 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-03-03 21:54:52 -0800 |
commit | 396106e307eacc4b4fbd79a995a0fafdc7f91e6b (patch) | |
tree | 9aa1a13583a99ccd2d83349f4f12e76ab6886705 /planner.c | |
parent | d24d2288f30e8666667c5437802d22533a94e1ec (diff) | |
download | subsurface-396106e307eacc4b4fbd79a995a0fafdc7f91e6b.tar.gz |
Don't use negative gas index
This shouldn't happen, but in case we run out of gases we shouldn't use
the negative gas index (which is the error return of get_gas_idx()) for
the array. Let's fall back to the (incorrect) first gas.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'planner.c')
-rw-r--r-- | planner.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -161,6 +161,10 @@ static int time_at_last_depth(struct dive *dive, int o2, int he, unsigned int ne sample = &dive->dc.sample[dive->dc.samples - 1]; depth = sample->depth.mm; gasidx = get_gasidx(dive, o2, he); + if (gasidx == -1) { + fprintf(stderr, "cannot find gas (%d/%d), using first gas\n", o2, he); + gasidx = 0; + } while (deco_allowed_depth(tissue_tolerance, surface_pressure, dive, 1) > next_stop) { wait++; tissue_tolerance = add_segment(depth_to_mbar(depth, dive) / 1000.0, |