* [dpdk-stable] [PATCH 20.11] app: fix exit messages
@ 2021-05-28 9:21 Thomas Monjalon
2021-05-31 11:32 ` Xueming(Steven) Li
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Monjalon @ 2021-05-28 9:21 UTC (permalink / raw)
To: stable
Cc: xuemingl, Wisam Jaddo, Ori Kam, Bruce Richardson,
Andrew Rybchenko, David Marchand
[ upstream commit 487cfc24370fdb7ea843aa510d6e6d2a7212dd23 ]
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 <thomas@monjalon.net>
Acked-by: Wisam Jaddo <wisamm@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: David Marchand <david.marchand@redhat.com>
---
.../comp_perf_options_parse.c | 2 +-
app/test-crypto-perf/cperf_options_parsing.c | 2 +-
app/test-flow-perf/main.c | 45 +++++++++----------
app/test-pmd/parameters.c | 4 +-
app/test-regex/main.c | 3 +-
5 files changed, 26 insertions(+), 30 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 e2fc5b7f65..64d722baa7 100644
--- a/app/test-flow-perf/main.c
+++ b/app/test-flow-perf/main.c
@@ -606,7 +606,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) {
@@ -614,7 +614,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);
}
@@ -634,7 +634,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++] =
@@ -647,7 +647,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++] =
@@ -671,11 +671,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, ",");
}
@@ -697,11 +695,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, ",");
}
@@ -714,9 +710,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,
@@ -725,7 +721,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);
}
}
@@ -752,9 +749,9 @@ args_parse(int argc, char **argv)
}
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;
}
}
@@ -853,7 +850,7 @@ destroy_flows(int port_id, struct rte_flow **flow_list)
memset(&error, 0x33, sizeof(error));
if (rte_flow_destroy(port_id, flow_list[i], &error)) {
print_flow_error(error);
- rte_exit(EXIT_FAILURE, "Error in deleting flow");
+ rte_exit(EXIT_FAILURE, "Error in deleting flow\n");
}
if (i && !((i + 1) % rules_batch)) {
@@ -924,7 +921,7 @@ flows_handler(void)
flow_list = rte_zmalloc("flow_list",
(sizeof(struct rte_flow *) * rules_count) + 1, 0);
if (flow_list == NULL)
- rte_exit(EXIT_FAILURE, "No Memory available!");
+ rte_exit(EXIT_FAILURE, "No Memory available!\n");
for (port_id = 0; port_id < nr_ports; port_id++) {
/* If port outside portmask */
@@ -947,7 +944,7 @@ flows_handler(void)
if (flow == NULL) {
print_flow_error(error);
- rte_exit(EXIT_FAILURE, "error in creating flow");
+ rte_exit(EXIT_FAILURE, "Error in creating flow\n");
}
flow_list[flow_index++] = flow;
}
@@ -968,7 +965,7 @@ flows_handler(void)
if (!flow) {
print_flow_error(error);
- rte_exit(EXIT_FAILURE, "error in creating flow");
+ rte_exit(EXIT_FAILURE, "Error in creating flow\n");
}
flow_list[flow_index++] = flow;
@@ -1087,7 +1084,7 @@ packet_per_second_stats(void)
old = rte_zmalloc("old",
sizeof(struct lcore_info) * MAX_LCORES, 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) * MAX_LCORES);
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index df5eb10d84..195a6ae9d8 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -630,7 +630,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")) {
@@ -1359,7 +1359,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 ac6152dea7..507b9cf912 100644
--- a/app/test-regex/main.c
+++ b/app/test-regex/main.c
@@ -108,9 +108,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.31.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-stable] [PATCH 20.11] app: fix exit messages
2021-05-28 9:21 [dpdk-stable] [PATCH 20.11] app: fix exit messages Thomas Monjalon
@ 2021-05-31 11:32 ` Xueming(Steven) Li
0 siblings, 0 replies; 2+ messages in thread
From: Xueming(Steven) Li @ 2021-05-31 11:32 UTC (permalink / raw)
To: NBU-Contact-Thomas Monjalon, stable
Cc: Wisam Monther, Ori Kam, Bruce Richardson, Andrew Rybchenko,
David Marchand
Thanks, applied
> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Friday, May 28, 2021 5:22 PM
> To: stable@dpdk.org
> Cc: Xueming(Steven) Li <xuemingl@nvidia.com>; Wisam Monther <wisamm@nvidia.com>; Ori Kam <orika@nvidia.com>; Bruce
> Richardson <bruce.richardson@intel.com>; Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>; David Marchand
> <david.marchand@redhat.com>
> Subject: [PATCH 20.11] app: fix exit messages
>
> [ upstream commit 487cfc24370fdb7ea843aa510d6e6d2a7212dd23 ]
>
> 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 <thomas@monjalon.net>
> Acked-by: Wisam Jaddo <wisamm@nvidia.com>
> Acked-by: Ori Kam <orika@nvidia.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Acked-by: David Marchand <david.marchand@redhat.com>
> ---
> .../comp_perf_options_parse.c | 2 +-
> app/test-crypto-perf/cperf_options_parsing.c | 2 +-
> app/test-flow-perf/main.c | 45 +++++++++----------
> app/test-pmd/parameters.c | 4 +-
> app/test-regex/main.c | 3 +-
> 5 files changed, 26 insertions(+), 30 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 e2fc5b7f65..64d722baa7 100644
> --- a/app/test-flow-perf/main.c
> +++ b/app/test-flow-perf/main.c
> @@ -606,7 +606,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) { @@ -614,7 +614,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);
> }
> @@ -634,7 +634,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++] =
> @@ -647,7 +647,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++] =
> @@ -671,11 +671,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, ",");
> }
> @@ -697,11 +695,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, ",");
> }
> @@ -714,9 +710,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,
> @@ -725,7 +721,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);
> }
> }
> @@ -752,9 +749,9 @@ args_parse(int argc, char **argv)
> }
> 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;
> }
> }
> @@ -853,7 +850,7 @@ destroy_flows(int port_id, struct rte_flow **flow_list)
> memset(&error, 0x33, sizeof(error));
> if (rte_flow_destroy(port_id, flow_list[i], &error)) {
> print_flow_error(error);
> - rte_exit(EXIT_FAILURE, "Error in deleting flow");
> + rte_exit(EXIT_FAILURE, "Error in deleting flow\n");
> }
>
> if (i && !((i + 1) % rules_batch)) {
> @@ -924,7 +921,7 @@ flows_handler(void)
> flow_list = rte_zmalloc("flow_list",
> (sizeof(struct rte_flow *) * rules_count) + 1, 0);
> if (flow_list == NULL)
> - rte_exit(EXIT_FAILURE, "No Memory available!");
> + rte_exit(EXIT_FAILURE, "No Memory available!\n");
>
> for (port_id = 0; port_id < nr_ports; port_id++) {
> /* If port outside portmask */
> @@ -947,7 +944,7 @@ flows_handler(void)
>
> if (flow == NULL) {
> print_flow_error(error);
> - rte_exit(EXIT_FAILURE, "error in creating flow");
> + rte_exit(EXIT_FAILURE, "Error in creating flow\n");
> }
> flow_list[flow_index++] = flow;
> }
> @@ -968,7 +965,7 @@ flows_handler(void)
>
> if (!flow) {
> print_flow_error(error);
> - rte_exit(EXIT_FAILURE, "error in creating flow");
> + rte_exit(EXIT_FAILURE, "Error in creating flow\n");
> }
>
> flow_list[flow_index++] = flow;
> @@ -1087,7 +1084,7 @@ packet_per_second_stats(void)
> old = rte_zmalloc("old",
> sizeof(struct lcore_info) * MAX_LCORES, 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) * MAX_LCORES); diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index
> df5eb10d84..195a6ae9d8 100644
> --- a/app/test-pmd/parameters.c
> +++ b/app/test-pmd/parameters.c
> @@ -630,7 +630,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")) { @@ -1359,7 +1359,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 ac6152dea7..507b9cf912 100644
> --- a/app/test-regex/main.c
> +++ b/app/test-regex/main.c
> @@ -108,9 +108,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.31.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-05-31 11:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-28 9:21 [dpdk-stable] [PATCH 20.11] app: fix exit messages Thomas Monjalon
2021-05-31 11:32 ` Xueming(Steven) Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).