[v2] app/flow-perf: add missing default option

Message ID 20211116141228.14755-1-rasland@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] app/flow-perf: add missing default option |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-testing warning apply patch failure
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed

Commit Message

Raslan Darawsheh Nov. 16, 2021, 2:12 p.m. UTC
  Currently, if an invalid parameter is passed to the application
it will cause a crash due to missing default in options.

For example:
        ./dpdk-test-flow-perf -a 01:00.0 -- --invalid

This adds missing default for options, and prints the
invalid option.

Fixes: 3344cf2e3001 ("app/flow-perf: add flow performance skeleton")
Cc: wisamm@nvidia.com
Cc: stable@dpdk.org

Signed-off-by: Raslan Darawsheh <rasland@nvidia.com>
---
 app/test-flow-perf/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Wisam Monther Nov. 16, 2021, 2:18 p.m. UTC | #1
Hi,

> -----Original Message-----
> From: Raslan Darawsheh <rasland@nvidia.com>
> Sent: Tuesday, November 16, 2021 4:12 PM
> To: dev@dpdk.org
> Cc: Wisam Monther <wisamm@nvidia.com>; stable@dpdk.org
> Subject: [PATCH v2] app/flow-perf: add missing default option
> 
> Currently, if an invalid parameter is passed to the application it will cause a
> crash due to missing default in options.
> 
> For example:
>         ./dpdk-test-flow-perf -a 01:00.0 -- --invalid
> 
> This adds missing default for options, and prints the invalid option.
> 
> Fixes: 3344cf2e3001 ("app/flow-perf: add flow performance skeleton")
> Cc: wisamm@nvidia.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Raslan Darawsheh <rasland@nvidia.com>
Acked-by: Wisam Jaddo <wisamm@nvidia.com>


BRs,
Wisam Jaddo
  
Thomas Monjalon Nov. 17, 2021, 9:49 a.m. UTC | #2
> > Currently, if an invalid parameter is passed to the application it will cause a
> > crash due to missing default in options.
> > 
> > For example:
> >         ./dpdk-test-flow-perf -a 01:00.0 -- --invalid
> > 
> > This adds missing default for options, and prints the invalid option.
> > 
> > Fixes: 3344cf2e3001 ("app/flow-perf: add flow performance skeleton")
> > Cc: wisamm@nvidia.com
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Raslan Darawsheh <rasland@nvidia.com>
> Acked-by: Wisam Jaddo <wisamm@nvidia.com>

Applied with title "fix parsing of invalid option", thanks.
  

Patch

diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c
index 2b612aa32c..11f1ee0e1e 100644
--- a/app/test-flow-perf/main.c
+++ b/app/test-flow-perf/main.c
@@ -715,6 +715,7 @@  args_parse(int argc, char **argv)
 		{ "policy-mtr",                 1, 0, 0 },
 		{ "meter-profile",              1, 0, 0 },
 		{ "packet-mode",                0, 0, 0 },
+		{ 0, 0, 0, 0 },
 	};
 
 	RTE_ETH_FOREACH_DEV(i)
@@ -951,7 +952,7 @@  args_parse(int argc, char **argv)
 		default:
 			usage(argv[0]);
 			rte_exit(EXIT_FAILURE, "Invalid option: %s\n",
-					argv[optind]);
+					argv[optind - 1]);
 			break;
 		}
 	}