From 01e9c1549d14362822e8acf1c459618d535bb3d3 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Fri, 19 Sep 2014 18:01:50 +0200 Subject: [PATCH] Simplify error handling thanks to the last change in the `sds' library. --- lib/numberset.c | 8 +++----- lib/tadeltas.c | 11 +++-------- lib/tadump.c | 18 ------------------ 3 files changed, 6 insertions(+), 31 deletions(-) diff --git a/lib/numberset.c b/lib/numberset.c index c957d47..ae91c4a 100644 --- a/lib/numberset.c +++ b/lib/numberset.c @@ -360,8 +360,6 @@ number_set_show(number_range* number_set, } s = sdsempty(); - if (!s) - return NULL; while (nr) { @@ -384,14 +382,14 @@ number_set_show(number_range* number_set, else s = sdscatprintf(s, "%s%i-%i", comma, nr->start, nr->end); - if (!s) - return NULL; - Again: nr = nr->next; } Exit: + if (!s) + return NULL; + /* we return an empty string for an empty number set */ /* (this is, number_set == NULL or unsuitable `min' and `max' values) */ len = sdslen(s) + 1; diff --git a/lib/tadeltas.c b/lib/tadeltas.c index c5b92fb..df97c1b 100644 --- a/lib/tadeltas.c +++ b/lib/tadeltas.c @@ -124,8 +124,6 @@ deltas_show_line(FONT* font, s = sdsempty(); - if (!s) - return NULL; if (!deltas) goto Exit; @@ -182,8 +180,6 @@ TA_deltas_show(FONT* font) s = sdsempty(); - if (!s) - return NULL; while (deltas) { @@ -199,15 +195,14 @@ TA_deltas_show(FONT* font) } s = sdscatsds(s, d); sdsfree(d); - if (!s) - return NULL; s = sdscat(s, "\n"); - if (!s) - return NULL; deltas = deltas->next; } + if (!s) + return NULL; + /* we return an empty string if there is no data */ len = sdslen(s) + 1; res = (char*)malloc(len); diff --git a/lib/tadump.c b/lib/tadump.c index a64bead..bddfd9a 100644 --- a/lib/tadump.c +++ b/lib/tadump.c @@ -23,8 +23,6 @@ s = sdscatprintf(s, \ "%*s = %ld\n", \ width, (str), (FT_Long)(arg)); \ - if (!s) \ - goto Exit; \ } while (0) #define DUMPSTR(str, arg) \ do \ @@ -32,8 +30,6 @@ s = sdscatprintf(s, \ "%*s = %s%s", \ width, (str), (arg), eol); \ - if (!s) \ - goto Exit; \ } while (0) #define DUMPSTRX(arg) \ do \ @@ -41,8 +37,6 @@ s = sdscatprintf(s, \ "%s%*s %s%s", \ prev_eol, width, "", (arg), eol); \ - if (!s) \ - goto Exit; \ } while (0) @@ -66,17 +60,12 @@ TA_font_dump_parameters(FONT* font, s = sdsempty(); - if (!s) - return NULL; if (format) { s = sdscat(s, "TTF_autohint parameters\n" "=======================\n" "\n"); - if (!s) - goto Exit; - width = 33; } @@ -169,15 +158,8 @@ TA_font_dump_parameters(FONT* font, DUMPSTR("delta exceptions", ""); if (!format) - { s = sdscat(s, "\n"); - if (!s) - goto Exit; - } - s = sdscat(s, "\n"); - if (!s) - goto Exit; Exit: free(ns); -- 2.11.4.GIT