[PATCH] Cleans null pointer printout in weightsystem description
Dirk Hohndel
dirk at hohndel.org
Tue Jan 15 11:57:18 PST 2013
I think elsewhere we use "unknown"
uemis-downloader.c: weight->description = strdup("unknown");
I think that's a better choice... (and I think I should localize this in
the uemis downloader...)
Can you modify your patch to do that?
/D
Salvador Cuñat <salvador.cunat at gmail.com> writes:
> If there's no weightsystem description, as in most imported
> dives, print a literal "Not defined" instead of null pointer
> or blank.
>
> Signed-off-by: Salvador Cuñat <salvador.cunat at gmail.com>
> ---
> print.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/print.c b/print.c
> index ac32ba6..a3ee3ab 100644
> --- a/print.c
> +++ b/print.c
> @@ -286,7 +286,7 @@ static void print_weight_data (struct dive *dive, cairo_t *cr, int maxwidth, int
> {
> int decimals,i;
> double totalweight, systemweight, weightsystemcounter;
> - const char *unit_weight;
> + const char *unit_weight, *desc;
> char buffer[80];
> PangoLayout *layout;
>
> @@ -310,7 +310,8 @@ static void print_weight_data (struct dive *dive, cairo_t *cr, int maxwidth, int
> systemweight = get_weight_units(dive->weightsystem[i].weight.grams, &decimals, &unit_weight);
> if (systemweight != 0){
> cairo_move_to(cr, 0, 0);
> - snprintf(buffer, sizeof(buffer), _("%s"),dive->weightsystem[i].description);
> + desc = dive->weightsystem[i].description ? : _("Not defined");
> + snprintf(buffer, sizeof(buffer), _("%s"), desc);
> pango_layout_set_text(layout, buffer, -1);
> pango_cairo_show_layout(cr, layout);
> cairo_move_to(cr,(2 * maxwidth) / (3 * (double) PANGO_SCALE), 0);
> --
> 1.7.10.4
> _______________________________________________
> subsurface mailing list
> subsurface at hohndel.org
> http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
More information about the subsurface
mailing list