diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-01-03 13:01:49 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-01-03 21:43:34 -0800 |
commit | e5e2fb2038321a645be58497fdbccb30e321264c (patch) | |
tree | 1e99ed46b2818fa2b97defd274bd5f2d2814006e /print.c | |
parent | 3c5ebfe03664ea9a719c9a5071caee63c3d813c2 (diff) | |
download | subsurface-e5e2fb2038321a645be58497fdbccb30e321264c.tar.gz |
Fix cylinder printout information
If we print out the pressure difference (because we do not have a cylinder
size), we didn't initialize the precision. We should print out pressures
without decimals.
The attached patch fixes that, and also avoids a NULL pointer printout
(which on Linux will just print out "(null)") if there is no cylinder
type descriptor string. It also cleans things up a bit and uses the
"cyl" pointer instead of repeating the "dive->cylinder[n]" thing.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'print.c')
-rw-r--r-- | print.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -229,7 +229,7 @@ static void print_tanks (struct dive *dive, cairo_t *cr, int maxwidth, int maxhe counter = 0; while ( n < tank_count && n < first_tank + 4) { int decimals; - const char *unit; + const char *unit, *desc; double gas_usage; cylinder_t *cyl = dive->cylinder + n; @@ -242,23 +242,25 @@ static void print_tanks (struct dive *dive, cairo_t *cr, int maxwidth, int maxhe /* Can we turn it into a volume? */ if (cyl->type.size.mliter) { gas_usage = bar_to_atm(gas_usage / 1000); - gas_usage *= dive->cylinder[n].type.size.mliter; + 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; } curwidth = 0; cairo_move_to (cr, curwidth / (double) PANGO_SCALE, 0); - snprintf(buffer, sizeof(buffer), "%s", dive->cylinder[n].type.description); + desc = cyl->type.description ? : ""; + snprintf(buffer, sizeof(buffer), "%s", desc); pango_layout_set_text(layout, buffer, -1); pango_cairo_show_layout(cr, layout); curwidth += (maxwidth/ 3); cairo_move_to(cr, curwidth / (double) PANGO_SCALE, 0); print_ean_trimix (cr, layout, - dive->cylinder[n].gasmix.o2.permille/10, - dive->cylinder[n].gasmix.he.permille/10); + cyl->gasmix.o2.permille/10, + cyl->gasmix.he.permille/10); curwidth += (maxwidth/ 3); cairo_move_to(cr, curwidth / (double) PANGO_SCALE, 0); |