From: Linus Torvalds <[email protected]> Date: Tue, 5 Apr 2016 15:20:01 -0700 Subject: [PATCH 1/2] Remove unused and buggy get_cylinder_used_gas_string() function
It's good that this is unused, because it does the calculations wrong. Due to the gas compressibility the gas use calculations should subtract the gas_volume() values at the differing pressures, not the pressures themselves. Signed-off-by: Linus Torvalds <[email protected]> --- This just removes dead and broken code. It's entirely incidental, and just came about from me looking at the gas use code. I started off fixing the broken function, and then noticed it wasn't actually used. Get rid of the cruddy broken thing. core/helpers.h | 1 - core/qthelper.cpp | 31 ------------------------------- 2 files changed, 32 deletions(-) diff --git a/core/helpers.h b/core/helpers.h index f88da015cf48..b9f7f50ca2e9 100644 --- a/core/helpers.h +++ b/core/helpers.h @@ -16,7 +16,6 @@ QString get_depth_string(int mm, bool showunit = false, bool showdecimal = true) QString get_depth_unit(); QString get_weight_string(weight_t weight, bool showunit = false); QString get_weight_unit(); -QString get_cylinder_used_gas_string(cylinder_t *cyl, bool showunit = false); QString get_temperature_string(temperature_t temp, bool showunit = false); QString get_temp_unit(); QString get_volume_string(volume_t volume, bool showunit = false); diff --git a/core/qthelper.cpp b/core/qthelper.cpp index 1d39510880ac..a261cca388bf 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -626,37 +626,6 @@ QString get_weight_unit() return QString("%1").arg(translate("gettextFromC", "lbs")); } -/* these methods retrieve used gas per cylinder */ -static unsigned start_pressure(cylinder_t *cyl) -{ - return cyl->start.mbar ?: cyl->sample_start.mbar; -} - -static unsigned end_pressure(cylinder_t *cyl) -{ - return cyl->end.mbar ?: cyl->sample_end.mbar; -} - -QString get_cylinder_used_gas_string(cylinder_t *cyl, bool showunit) -{ - int decimals; - const char *unit; - double gas_usage; - /* Get the cylinder gas use in mbar */ - gas_usage = start_pressure(cyl) - end_pressure(cyl); - /* Can we turn it into a volume? */ - if (cyl->type.size.mliter) { - gas_usage = bar_to_atm(gas_usage / 1000); - gas_usage *= cyl->type.size.mliter; - gas_usage = get_volume_units(gas_usage, &decimals, &unit); - } else { - gas_usage = get_pressure_units(gas_usage, &unit); - decimals = 0; - } - // translate("gettextFromC","%.*f %s" - return QString("%1 %2").arg(gas_usage, 0, 'f', decimals).arg(showunit ? unit : ""); -} - QString get_temperature_string(temperature_t temp, bool showunit) { if (temp.mkelvin == 0) { -- 2.8.0.rc4.303.g3931579 _______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
