[v2,3/6] app/testpmd: fix error message for invalid option
Checks
Commit Message
"""
The variable optind is the index of the next element to be processed in
argv. The system initializes this value to 1. The caller can reset it
to 1 to restart scanning of the same argv, or when scanning a new
argument vector.
"""
Hence, if an invalid option is passed through testpmd cmdline, getopt
returns '?' and increments optind to the next index in argv for a
subsequent call.
The message should log the previous index.
Fixes: 8fad2e5ab2c5 ("app/testpmd: report invalid command line parameter")
Cc: stable@dpdk.org
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
app/test-pmd/parameters.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 3/14/2024 9:17 AM, David Marchand wrote:
> """
> The variable optind is the index of the next element to be processed in
> argv. The system initializes this value to 1. The caller can reset it
> to 1 to restart scanning of the same argv, or when scanning a new
> argument vector.
> """
>
> Hence, if an invalid option is passed through testpmd cmdline, getopt
> returns '?' and increments optind to the next index in argv for a
> subsequent call.
> The message should log the previous index.
>
> Fixes: 8fad2e5ab2c5 ("app/testpmd: report invalid command line parameter")
> Cc: stable@dpdk.org
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
@@ -1497,7 +1497,7 @@ launch_args_parse(int argc, char** argv)
break;
default:
usage(argv[0]);
- fprintf(stderr, "Invalid option: %s\n", argv[optind]);
+ fprintf(stderr, "Invalid option: %s\n", argv[optind - 1]);
rte_exit(EXIT_FAILURE,
"Command line is incomplete or incorrect\n");
break;