[v6,2/6] eal: turn off getopt_long error message during eal_log_level
Checks
Commit Message
If DPDK application is given a bogus option, the error message
would get printed twice. Once during scan for log level and
again during parsing of arguments.
Example:
# ./build/app/dpdk-testpmd --bogus
./build/app/dpdk-testpmd: unrecognized option '--bogus'
EAL: Detected CPU lcores: 16
EAL: Detected NUMA nodes: 1
./build/app/dpdk-testpmd: unrecognized option '--bogus'
Usage: ./build/app/dpdk-testpmd [options]
Fix by suppressing printing error message on first pass.
Signed-off-by: Keith Wiles <keith.wiles@intel.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/eal/common/eal_common_log.c | 3 +++
lib/eal/windows/eal.c | 1 +
2 files changed, 4 insertions(+)
@@ -235,6 +235,7 @@ eal_log_level_parse(int argc, char *const argv[])
int option_index, opt;
const int old_optind = optind;
const int old_optopt = optopt;
+ const int old_opterr = opterr;
char * const old_optarg = optarg;
#ifdef RTE_EXEC_ENV_FREEBSD
const int old_optreset = optreset;
@@ -242,6 +243,7 @@ eal_log_level_parse(int argc, char *const argv[])
#endif
optind = 1;
+ opterr = 0;
while ((opt = getopt_long(argc, argv, eal_short_options,
eal_long_options, &option_index)) != EOF) {
@@ -263,6 +265,7 @@ eal_log_level_parse(int argc, char *const argv[])
optind = old_optind;
optopt = old_optopt;
optarg = old_optarg;
+ opterr = old_opterr;
#ifdef RTE_EXEC_ENV_FREEBSD
optreset = old_optreset;
#endif
@@ -108,6 +108,7 @@ eal_parse_args(int argc, char **argv)
eal_get_internal_configuration();
argvopt = argv;
+ opterr = 1;
while ((opt = getopt_long(argc, argvopt, eal_short_options,
eal_long_options, &option_index)) != EOF) {