[PATCH 3/4] ASN.1: Improve exiting from build_type_list()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux