From: SF Markus Elfring <elfring@users.sourceforge.net>
To: kernel-janitors@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 3/4] ASN.1: Improve exiting from build_type_list()
Date: Fri, 10 Nov 2017 13:49:13 +0100 [thread overview]
Message-ID: <3a3b73b2-0164-5de8-5540-9d1d25af7018@users.sourceforge.net> (raw)
In-Reply-To: <960a8501-03b0-95d9-c2bf-4633e48e73a6@users.sourceforge.net>
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
next prev parent reply other threads:[~2017-11-10 12:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-10 12:45 [PATCH 0/4] ASN.1: Fine-tuning for three function implementations SF Markus Elfring
2017-11-10 12:46 ` [PATCH 1/4] ASN.1: Adjust two function calls together with a variable assignment SF Markus Elfring
2017-11-10 12:48 ` [PATCH 2/4] ASN.1: Improve exiting from parse_type() SF Markus Elfring
2017-11-10 12:49 ` SF Markus Elfring [this message]
2017-11-10 12:50 ` [PATCH 4/4] ASN.1: Use common error handling code in main() SF Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3a3b73b2-0164-5de8-5540-9d1d25af7018@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=akpm@linux-foundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome