From c612641517e2187ae81febdefe11f60d701e3bda Mon Sep 17 00:00:00 2001 From: Micha WERLE Date: Mon, 20 Nov 2023 12:22:58 +0900 Subject: [PATCH] fix: actually default bottom gas to air If there are no gas mixes returned by libdivecomputer, we need to default to air. The previous commit would have defaulted to pure oxygen. Signed-off-by: Micha WERLE --- core/libdivecomputer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c index 2173c3007..501d9709f 100644 --- a/core/libdivecomputer.c +++ b/core/libdivecomputer.c @@ -123,7 +123,7 @@ static struct gasmix get_deeper_gasmix(struct gasmix a, struct gasmix b) if (get_o2(a) < get_o2(b)) { return a; } - if (get_o2(a) > get_o2(b)) + if (get_o2(a) > get_o2(b)) { return b; } return get_he(a) < get_he(b) ? b : a; @@ -161,7 +161,10 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t } } bool no_volume = true; - struct gasmix bottom_gas = { {1000}, {0} }; /* Default to pure O2 */ + struct gasmix bottom_gas = { {1000}, {0} }; /* Default to pure O2, or air if there are no mixes defined */ + if (ngases == 0) { + bottom_gas = gasmix_air; + } clear_cylinder_table(&dive->cylinders); for (i = 0; i < MAX(ngases, ntanks); i++) {