From: Linus Torvalds <[email protected]> Date: Fri, 28 Jul 2017 11:49:03 -0700 Subject: [PATCH 4/4] Fix manual pressures for cylinders with no gas switches
"If it hasn't been tested, it doesn't work". All my testing of the multiple sensor pressures have been with some reasonably "interesting" dives: they actually *have* sensor pressures. But that test coverage means that I missed the truly trivial case of just having manual pressures for a single cylinder. Because there's only a single cylinder, it doesn't have any cylinder changes, and because there were no cylinder changes, it never filled in the use range for that cylinder. So then it never showed the pressure profile at all. Duh. Signed-off-by: Linus Torvalds <[email protected]> --- This is the brown-paper-bag case for the simple dives that no longer showed pressures because nothing mentioned a gas switch. core/profile.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/core/profile.c b/core/profile.c index cb11251c..e9a625d3 100644 --- a/core/profile.c +++ b/core/profile.c @@ -822,6 +822,10 @@ static void setup_gas_sensor_pressure(struct dive *dive, struct divecomputer *dc unsigned int first[MAX_CYLINDERS] = { 0, }; unsigned int last[MAX_CYLINDERS] = { 0, }; struct divecomputer *secondary; + int endtime = dc->samples ? dc->sample[dc->samples-1].time.seconds : dive->duration.seconds; + + for (i = 0; i < MAX_CYLINDERS; i++) + last[i] = endtime; for (ev = get_next_event(dc->events, "gaschange"); ev != NULL; ev = get_next_event(ev->next, "gaschange")) { int cyl = ev->gas.index; @@ -836,27 +840,22 @@ static void setup_gas_sensor_pressure(struct dive *dive, struct divecomputer *dc last[cyl] = sec; if (!seen[cyl]) { - int endtime = sec; - if (dc->samples) - endtime = dc->sample[dc->samples-1].time.seconds; - // The end time may be updated by a subsequent cylinder change first[cyl] = sec; - last[cyl] = endtime; seen[cyl] = 1; } } + if (prev >= 0) + last[prev] = endtime; for (i = 0; i < MAX_CYLINDERS; i++) { - if (seen[i]) { - cylinder_t *cyl = dive->cylinder + i; - int start = cyl->start.mbar; - int end = cyl->end.mbar; - - if (start) - add_plot_pressure(pi, first[i], i, start); - if (end) - add_plot_pressure(pi, last[i], i, end); + cylinder_t *cyl = dive->cylinder + i; + int start = cyl->start.mbar; + int end = cyl->end.mbar; + + if (start && end) { + add_plot_pressure(pi, first[i], i, start); + add_plot_pressure(pi, last[i], i, end); } } -- 2.13.1.518.g0d864c4df _______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
