From: Stephen Hemminger <stephen@networkplumber.org>
To: keith.wiles@intel.com
Cc: dev@dpdk.org, Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH v2] eal: turn off getopt_long error message during eal_log_level
Date: Fri, 9 Jun 2023 08:23:42 -0700 [thread overview]
Message-ID: <20230609152342.77405-1-stephen@networkplumber.org> (raw)
In-Reply-To: <20181216164559.89835-1-keith.wiles@intel.com>
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 supressing 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/freebsd/eal.c | 2 ++
lib/eal/linux/eal.c | 2 ++
lib/eal/windows/eal.c | 3 +++
3 files changed, 7 insertions(+)
diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index 78ffb45c5987..51e65181282f 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -380,6 +380,7 @@ eal_log_level_parse(int argc, char **argv)
argvopt = argv;
optind = 1;
optreset = 1;
+ opterr = 0;
while ((opt = getopt_long(argc, argvopt, eal_short_options,
eal_long_options, &option_index)) != EOF) {
@@ -423,6 +424,7 @@ eal_parse_args(int argc, char **argv)
argvopt = argv;
optind = 1;
optreset = 1;
+ opterr = 1;
while ((opt = getopt_long(argc, argvopt, eal_short_options,
eal_long_options, &option_index)) != EOF) {
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 99b0a597061d..72b62c181238 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -561,6 +561,7 @@ eal_log_level_parse(int argc, char **argv)
argvopt = argv;
optind = 1;
+ opterr = 0;
while ((opt = getopt_long(argc, argvopt, eal_short_options,
eal_long_options, &option_index)) != EOF) {
@@ -638,6 +639,7 @@ eal_parse_args(int argc, char **argv)
argvopt = argv;
optind = 1;
+ opterr = 1;
while ((opt = getopt_long(argc, argvopt, eal_short_options,
eal_long_options, &option_index)) != EOF) {
diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c
index de44d7d67a08..d3745caa8b65 100644
--- a/lib/eal/windows/eal.c
+++ b/lib/eal/windows/eal.c
@@ -106,6 +106,8 @@ eal_log_level_parse(int argc, char **argv)
struct internal_config *internal_conf =
eal_get_internal_configuration();
+ opterr = 0;
+
argvopt = argv;
eal_reset_internal_config(internal_conf);
@@ -143,6 +145,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) {
--
2.39.2
prev parent reply other threads:[~2023-06-09 15:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-16 16:45 [dpdk-dev] [PATCH] eal: turn off getopt_long error messages Keith Wiles
2018-12-19 20:35 ` Thomas Monjalon
2019-01-14 14:02 ` Thomas Monjalon
2023-06-09 15:23 ` Stephen Hemminger [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230609152342.77405-1-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=keith.wiles@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).