[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3a3b73b2-0164-5de8-5540-9d1d25af7018@users.sourceforge.net>
Date: Fri, 10 Nov 2017 13:49:13 +0100
From: SF Markus Elfring <elfring@...rs.sourceforge.net>
To: kernel-janitors@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH 3/4] ASN.1: Improve exiting from build_type_list()
From: Markus Elfring <elfring@...rs.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@...rs.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
Powered by blists - more mailing lists