diff options
author | Stefan Fuchs <sfuchs@gmx.de> | 2017-03-18 20:36:46 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-03-19 17:11:52 -0700 |
commit | ce420d7720213aa0f255f07ee04e243f4c1c1242 (patch) | |
tree | 779b3bd1af0ac5338f5c6103d0c1d002972aae09 /core/planner.c | |
parent | 220d25588f6e7c17131dba1c07ad4b4b8ec7f559 (diff) | |
download | subsurface-ce420d7720213aa0f255f07ee04e243f4c1c1242.tar.gz |
Prevent overflow in minimum gas calculation
For the "crazy" long and deep dives in "TestPlan" an overflow happened here.
Rearranged the calculation to have more margin.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Diffstat (limited to 'core/planner.c')
-rw-r--r-- | core/planner.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/planner.c b/core/planner.c index 1564643d9..aa77f11e8 100644 --- a/core/planner.c +++ b/core/planner.c @@ -899,9 +899,9 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool && dive->dc.divemode == OC && decoMode() != RECREATIONAL) { /* Calculate minimum gas volume. */ volume_t mingasv; - mingasv.mliter = lrint(prefs.problemsolvingtime * prefs.bottomsac * prefs.sacfactor / 100.0 + mingasv.mliter = lrint(prefs.sacfactor / 100.0 * prefs.problemsolvingtime * prefs.bottomsac * depth_to_bar(lastbottomdp->depth.mm, dive) - + cyl->deco_gas_used.mliter * prefs.sacfactor / 100.0); + + prefs.sacfactor / 100.0 * cyl->deco_gas_used.mliter); /* Calculate minimum gas pressure for cyclinder. */ pressure_t mingasp; mingasp.mbar = lrint(isothermal_pressure(&cyl->gasmix, 1.0, |