From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9958DA034F; Sun, 21 Mar 2021 23:32:55 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F3A89140E6B; Sun, 21 Mar 2021 23:32:14 +0100 (CET) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by mails.dpdk.org (Postfix) with ESMTP id 4E2BE140E09 for ; Sun, 21 Mar 2021 23:32:05 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id E7DE65C00C2; Sun, 21 Mar 2021 18:32:04 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 21 Mar 2021 18:32:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=1XNn53/xNaZtB 0owFgCq6fnIUdxvNg2I/Wi8MAQgu7o=; b=gk6GtwqlAvwOyLLObxoPhtHjjdzJD 84X+Xr0o31ttzSjLJnren86JQ2TyF3STXFrv1v5oE2Ym6qh8OSYo/p9yQEZIg3Jk USpYqGAq8Q3enRPuruYKgxkZFqvscCq6ODOVB44DMfOZY9vbQY9T3FnQobAtXkga /7WMagmlNPXvn7Z1tyc4UvijZPb+vZfHW/COgFZVZN0TLKQe9wHl2Mm2TcEjhbq2 mVnc7wV3IfdeYS4dRQjWnQK83C1AUCNFryx/Zf70km8zm0R0tLDtgi8jldbFp7wI vfNbH4Qv6jkendps09JlEcWh7ttA+yYxeIcpzCHTy6CYa1Ql+dzF1H3XQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=1XNn53/xNaZtB0owFgCq6fnIUdxvNg2I/Wi8MAQgu7o=; b=mTsxbz4J Tq9sjItLGIrNQa07c3GB3preDtLS4dxLUfoCSrUjrIBlEvrIgU4wSHcvikk2LZzN ThMFV53Hh6lHVqLd/4lEm+REqFUvR4cgLS4oqL6vpQp3EZ4XMAjKQiQ+uvdysKU1 YSH2YrqPNVuQi1PAYF37LQmncIgb2CdYXgWSWF6kw5RbR6GplXQb4xYjPjTXdq7/ wbUBk6P5XHK55MJIuPz1qDHRMoQdD0codaoXczH35Jau3zWB00tdtbQVPOi/QqBC 91kAGqvwXE1/gI+3v5xJ3RN/ChODAVPNaM3md5fhcf6uTfkXhnvDNOwR8rw867mq gL/IJHWUFA31Bg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudegvddgudeivdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedt gfeutdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrh fuihiivgepkeenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr lhhonhdrnhgvth X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id B5FAE240356; Sun, 21 Mar 2021 18:32:03 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Wisam Jaddo , Ori Kam , Bruce Richardson , Andrew Rybchenko , Declan Doherty , Ciara Power , Xiaoyun Li Date: Sun, 21 Mar 2021 23:31:12 +0100 Message-Id: <20210321223116.1340974-9-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210321223116.1340974-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> <20210321223116.1340974-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 08/11] app: fix exit messages X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Some applications were printing useless messages with rte_exit() after showing the help. Using exit() is enough in this case. Some applications were using a redundant printf or fprintf() before calling rte_exit(). The messages are unified in a single rte_exit(). Some rte_exit() calls were missing a line feed or returning a wrong code. Signed-off-by: Thomas Monjalon Acked-by: Wisam Jaddo Acked-by: Ori Kam Acked-by: Bruce Richardson Acked-by: Andrew Rybchenko --- .../comp_perf_options_parse.c | 2 +- app/test-crypto-perf/cperf_options_parsing.c | 2 +- app/test-flow-perf/main.c | 59 +++++++++---------- app/test-pmd/parameters.c | 4 +- app/test-regex/main.c | 3 +- 5 files changed, 33 insertions(+), 37 deletions(-) diff --git a/app/test-compress-perf/comp_perf_options_parse.c b/app/test-compress-perf/comp_perf_options_parse.c index 04a8d2fbee..019eddb7bd 100644 --- a/app/test-compress-perf/comp_perf_options_parse.c +++ b/app/test-compress-perf/comp_perf_options_parse.c @@ -620,7 +620,7 @@ comp_perf_options_parse(struct comp_test_data *test_data, int argc, char **argv) switch (opt) { case 'h': usage(argv[0]); - rte_exit(EXIT_SUCCESS, "Displayed help\n"); + exit(EXIT_SUCCESS); break; /* long options */ case 0: diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c index 0466f7baf8..40b6dfb648 100644 --- a/app/test-crypto-perf/cperf_options_parsing.c +++ b/app/test-crypto-perf/cperf_options_parsing.c @@ -983,7 +983,7 @@ cperf_options_parse(struct cperf_options *options, int argc, char **argv) switch (opt) { case 'h': usage(argv[0]); - rte_exit(EXIT_SUCCESS, "Displayed help\n"); + exit(EXIT_SUCCESS); break; /* long options */ case 0: diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c index 99d0463456..0aef767350 100644 --- a/app/test-flow-perf/main.c +++ b/app/test-flow-perf/main.c @@ -639,7 +639,7 @@ args_parse(int argc, char **argv) case 0: if (strcmp(lgopts[opt_idx].name, "help") == 0) { usage(argv[0]); - rte_exit(EXIT_SUCCESS, "Displayed help\n"); + exit(EXIT_SUCCESS); } if (strcmp(lgopts[opt_idx].name, "group") == 0) { @@ -647,7 +647,7 @@ args_parse(int argc, char **argv) if (n >= 0) flow_group = n; else - rte_exit(EXIT_SUCCESS, + rte_exit(EXIT_FAILURE, "flow group should be >= 0\n"); printf("group %d / ", flow_group); } @@ -667,7 +667,7 @@ args_parse(int argc, char **argv) if (n > 0) hairpin_queues_num = n; else - rte_exit(EXIT_SUCCESS, + rte_exit(EXIT_FAILURE, "Hairpin queues should be > 0\n"); flow_actions[actions_idx++] = @@ -680,7 +680,7 @@ args_parse(int argc, char **argv) if (n > 0) hairpin_queues_num = n; else - rte_exit(EXIT_SUCCESS, + rte_exit(EXIT_FAILURE, "Hairpin queues should be > 0\n"); flow_actions[actions_idx++] = @@ -704,11 +704,9 @@ args_parse(int argc, char **argv) break; } /* Reached last item with no match */ - if (i == (RTE_DIM(flow_options) - 1)) { - fprintf(stderr, "Invalid encap item: %s\n", token); - usage(argv[0]); - rte_exit(EXIT_SUCCESS, "Invalid encap item\n"); - } + if (i == (RTE_DIM(flow_options) - 1)) + rte_exit(EXIT_FAILURE, + "Invalid encap item: %s\n", token); } token = strtok(NULL, ","); } @@ -730,11 +728,9 @@ args_parse(int argc, char **argv) break; } /* Reached last item with no match */ - if (i == (RTE_DIM(flow_options) - 1)) { - fprintf(stderr, "Invalid decap item: %s\n", token); - usage(argv[0]); - rte_exit(EXIT_SUCCESS, "Invalid decap item\n"); - } + if (i == (RTE_DIM(flow_options) - 1)) + rte_exit(EXIT_FAILURE, + "Invalid decap item %s\n", token); } token = strtok(NULL, ","); } @@ -747,9 +743,9 @@ args_parse(int argc, char **argv) if (n >= DEFAULT_RULES_BATCH) rules_batch = n; else { - printf("\n\nrules_batch should be >= %d\n", + rte_exit(EXIT_FAILURE, + "rules_batch should be >= %d\n", DEFAULT_RULES_BATCH); - rte_exit(EXIT_SUCCESS, " "); } } if (strcmp(lgopts[opt_idx].name, @@ -758,7 +754,8 @@ args_parse(int argc, char **argv) if (n >= (int) rules_batch) rules_count = n; else { - printf("\n\nrules_count should be >= %d\n", + rte_exit(EXIT_FAILURE, + "rules_count should be >= %d\n", rules_batch); } } @@ -786,23 +783,23 @@ args_parse(int argc, char **argv) if (strcmp(lgopts[opt_idx].name, "cores") == 0) { n = atoi(optarg); if ((int) rte_lcore_count() <= n) { - printf("\nError: you need %d cores to run on multi-cores\n" + rte_exit(EXIT_FAILURE, + "Error: you need %d cores to run on multi-cores\n" "Existing cores are: %d\n", n, rte_lcore_count()); - rte_exit(EXIT_FAILURE, " "); } if (n <= RTE_MAX_LCORE && n > 0) mc_pool.cores_count = n; else { - printf("Error: cores count must be > 0 " - " and < %d\n", RTE_MAX_LCORE); - rte_exit(EXIT_FAILURE, " "); + rte_exit(EXIT_FAILURE, + "Error: cores count must be > 0 and < %d\n", + RTE_MAX_LCORE); } } break; default: - fprintf(stderr, "Invalid option: %s\n", argv[optind]); usage(argv[0]); - rte_exit(EXIT_SUCCESS, "Invalid option\n"); + rte_exit(EXIT_FAILURE, "Invalid option: %s\n", + argv[optind]); break; } } @@ -936,7 +933,7 @@ create_meter_rule(int port_id, uint32_t counter) printf("Port %u create meter idx(%d) error(%d) message: %s\n", port_id, counter, error.type, error.message ? error.message : "(no stated reason)"); - rte_exit(EXIT_FAILURE, "error in creating meter"); + rte_exit(EXIT_FAILURE, "Error in creating meter\n"); } } @@ -949,7 +946,7 @@ destroy_meter_rule(int port_id, uint32_t counter) printf("Port %u destroy meter(%d) error(%d) message: %s\n", port_id, counter, error.type, error.message ? error.message : "(no stated reason)"); - rte_exit(EXIT_FAILURE, "Error in deleting meter rule"); + rte_exit(EXIT_FAILURE, "Error in deleting meter rule\n"); } } @@ -1097,7 +1094,7 @@ destroy_flows(int port_id, uint8_t core_id, struct rte_flow **flows_list) memset(&error, 0x33, sizeof(error)); if (rte_flow_destroy(port_id, flows_list[i], &error)) { print_flow_error(error); - rte_exit(EXIT_FAILURE, "Error in deleting flow"); + rte_exit(EXIT_FAILURE, "Error in deleting flow\n"); } /* @@ -1160,7 +1157,7 @@ insert_flows(int port_id, uint8_t core_id) flows_list = rte_zmalloc("flows_list", (sizeof(struct rte_flow *) * rules_count_per_core) + 1, 0); if (flows_list == NULL) - rte_exit(EXIT_FAILURE, "No Memory available!"); + rte_exit(EXIT_FAILURE, "No Memory available!\n"); cpu_time_used = 0; flow_index = 0; @@ -1180,7 +1177,7 @@ insert_flows(int port_id, uint8_t core_id) if (flow == NULL) { print_flow_error(error); - rte_exit(EXIT_FAILURE, "error in creating flow"); + rte_exit(EXIT_FAILURE, "Error in creating flow\n"); } flows_list[flow_index++] = flow; } @@ -1199,7 +1196,7 @@ insert_flows(int port_id, uint8_t core_id) if (!flow) { print_flow_error(error); - rte_exit(EXIT_FAILURE, "error in creating flow"); + rte_exit(EXIT_FAILURE, "Error in creating flow\n"); } flows_list[flow_index++] = flow; @@ -1517,7 +1514,7 @@ packet_per_second_stats(void) old = rte_zmalloc("old", sizeof(struct lcore_info) * RTE_MAX_LCORE, 0); if (old == NULL) - rte_exit(EXIT_FAILURE, "No Memory available!"); + rte_exit(EXIT_FAILURE, "No Memory available!\n"); memcpy(old, lcore_infos, sizeof(struct lcore_info) * RTE_MAX_LCORE); diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index a326c8ce4f..b7d4ef76b0 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -671,7 +671,7 @@ launch_args_parse(int argc, char** argv) case 0: /*long options */ if (!strcmp(lgopts[opt_idx].name, "help")) { usage(argv[0]); - rte_exit(EXIT_SUCCESS, "Displayed help\n"); + exit(EXIT_SUCCESS); } #ifdef RTE_LIB_CMDLINE if (!strcmp(lgopts[opt_idx].name, "interactive")) { @@ -1413,7 +1413,7 @@ launch_args_parse(int argc, char** argv) break; case 'h': usage(argv[0]); - rte_exit(EXIT_SUCCESS, "Displayed help\n"); + exit(EXIT_SUCCESS); break; default: usage(argv[0]); diff --git a/app/test-regex/main.c b/app/test-regex/main.c index aea4fa6b88..7bb87bb1b8 100644 --- a/app/test-regex/main.c +++ b/app/test-regex/main.c @@ -154,9 +154,8 @@ args_parse(int argc, char **argv, char *rules_file, char *data_file, usage("RegEx test app"); break; default: - fprintf(stderr, "Invalid option: %s\n", argv[optind]); usage("RegEx test app"); - rte_exit(EXIT_FAILURE, "Invalid option\n"); + rte_exit(EXIT_FAILURE, "Invalid option: %s\n", argv[optind]); break; } } -- 2.30.1