Profile: fix SAC calculation for air dives

Commit f5b11daffd changed gasmix
arguments and return values to be passed by value instead of
using pointers.

Notably, get_gasmix() is fed a default-value and returns a
new value. In the old code, NULL was passed in in a first
loop iteration and non-NULL was always returned in the first
iteration. Thus, an equality comparison of passed-in an
returned gasmix would always fail in the first loop iteration.

The new code passed in air as default. Now if air was also
returned, then the matching gases were not calculated in
calculate_sac(). To revert to the old behavior, pass in
an invalid gasmix.

Moreover, give names to the invalid and air gasmixes.

Reported-by: tormento <turment@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-09-10 20:40:25 +02:00 committed by Dirk Hohndel
parent c75f53a7a8
commit 6e4a253896
6 changed files with 18 additions and 7 deletions

View file

@ -34,10 +34,14 @@ extern const char *cylinderuse_text[];
extern const char *divemode_text_ui[];
extern const char *divemode_text[];
// o2 == 0 && he == 0 -> air
// o2 < 0 -> invalid
struct gasmix {
fraction_t o2;
fraction_t he;
};
static const struct gasmix gasmix_invalid = { { -1 }, { -1 } };
static const struct gasmix gasmix_air = { { 0 }, { 0 } };
typedef struct
{