[PATCH 3/7] Fix bug in comparing gases.
Anton Lundin
glance at acc.umu.se
Sat Dec 7 07:25:40 UTC 2013
Dive plan contained o2 as 209, but cylinders defaulted to o2 0, so we
might have crashes here when there was no gasidx found.
Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
planner.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/planner.c b/planner.c
index 9e9ed47..863469b 100644
--- a/planner.c
+++ b/planner.c
@@ -4,6 +4,7 @@
*
* (c) Dirk Hohndel 2013
*/
+#include <assert.h>
#include <unistd.h>
#include <ctype.h>
#include <string.h>
@@ -404,14 +405,16 @@ static struct gaschanges *analyze_gaslist(struct diveplan *diveplan, struct dive
i++;
}
gaschanges[i].depth = dp->depth;
+ gaschanges[i].gasidx = -1;
do {
- if (dive->cylinder[j].gasmix.o2.permille == dp->o2 &&
- dive->cylinder[j].gasmix.he.permille == dp->he) {
+ if (get_o2(&dive->cylinder[j].gasmix) == dp->o2 &&
+ get_he(&dive->cylinder[j].gasmix) == dp->he) {
gaschanges[i].gasidx = j;
break;
}
j++;
} while (j < MAX_CYLINDERS);
+ assert(gaschanges[i].gasidx != -1);
}
dp = dp->next;
}
--
1.8.3.2
More information about the subsurface
mailing list