app/pdump: close program if --pdump argument is missing

Message ID 20220302092023.4847-1-usman.tanveer@emumba.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series app/pdump: close program if --pdump argument is missing |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Usman Tanveer March 2, 2022, 9:20 a.m. UTC
  --pdump is a mandatory argument in pdump application.
It should print usage and exit if --pdump argument
is missing. The application is not closing and geting
stuck. Made the change to print usage and exit when
this argument is missing.

Signed-off-by: usman.tanveer <usman.tanveer@emumba.com>
---
 app/pdump/main.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
  

Patch

diff --git a/app/pdump/main.c b/app/pdump/main.c
index 04a38e8911..59a6846c65 100644
--- a/app/pdump/main.c
+++ b/app/pdump/main.c
@@ -383,14 +383,17 @@  launch_args_parse(int argc, char **argv, char *prgname)
 {
 	int opt, ret;
 	int option_index;
+	bool pdump_flag = false;
 	static struct option long_option[] = {
 		{CMD_LINE_OPT_PDUMP, 1, 0, CMD_LINE_OPT_PDUMP_NUM},
 		{CMD_LINE_OPT_MULTI, 0, 0, CMD_LINE_OPT_MULTI_NUM},
 		{NULL, 0, 0, 0}
 	};
 
-	if (argc == 1)
+	if (argc == 1) {
 		pdump_usage(prgname);
+		return -1;
+	}
 
 	/* Parse command line */
 	while ((opt = getopt_long(argc, argv, " ",
@@ -402,6 +405,7 @@  launch_args_parse(int argc, char **argv, char *prgname)
 				pdump_usage(prgname);
 				return -1;
 			}
+			pdump_flag = true;
 			break;
 		case CMD_LINE_OPT_MULTI_NUM:
 			multiple_core_capture = 1;
@@ -412,6 +416,11 @@  launch_args_parse(int argc, char **argv, char *prgname)
 		}
 	}
 
+	if (pdump_flag == false) {
+		pdump_usage(prgname);
+		return -1;
+	}
+
 	return 0;
 }
 
@@ -991,11 +1000,9 @@  main(int argc, char **argv)
 	argv += (diag - 2);
 
 	/* parse app arguments */
-	if (argc > 1) {
-		ret = launch_args_parse(argc, argv, argp[0]);
-		if (ret < 0)
-			rte_exit(EXIT_FAILURE, "Invalid argument\n");
-	}
+	ret = launch_args_parse(argc, argv, argp[0]);
+	if (ret < 0)
+		rte_exit(EXIT_FAILURE, "Invalid argument\n");
 
 	/* create mempool, ring and vdevs info */
 	create_mp_ring_vdev();