Messages in this thread Patch in this message | | | Subject | [PATCH 3/4] ASN.1: Improve exiting from build_type_list() | From | SF Markus Elfring <> | Date | Fri, 10 Nov 2017 13:49:13 +0100 |
| |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Fri, 10 Nov 2017 12:56:33 +0100
* Add jump targets so that a call of the function "perror" and "exit" is stored only once in an if branch of this function.
* Replace two calls by goto statements.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- scripts/asn1_compiler.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/scripts/asn1_compiler.c b/scripts/asn1_compiler.c index 0eea270fcaef..06dc5397d8c8 100644 --- a/scripts/asn1_compiler.c +++ b/scripts/asn1_compiler.c @@ -762,18 +762,19 @@ static void build_type_list(void) if (nr == 0) { fprintf(stderr, "%s: No defined types\n", filename); - exit(1); + goto exit; } nr_types = nr; types = type_list = calloc(nr + 1, sizeof(type_list[0])); - if (!type_list) { - perror(NULL); - exit(1); - } + if (!type_list) + goto report_failure; + type_index = calloc(nr, sizeof(type_index[0])); if (!type_index) { +report_failure: perror(NULL); +exit: exit(1); } -- 2.15.0
| |