DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] eal: turn off getopt_long error messages
@ 2018-12-16 16:45 Keith Wiles
  2018-12-19 20:35 ` Thomas Monjalon
  2023-06-09 15:23 ` [PATCH v2] eal: turn off getopt_long error message during eal_log_level Stephen Hemminger
  0 siblings, 2 replies; 4+ messages in thread
From: Keith Wiles @ 2018-12-16 16:45 UTC (permalink / raw)
  To: dev

When using dpdk register option api when parsing for log level
the opterr flags was still set to one causing an error message
from getopt_long(). Set opterr to zero to disable error messages.

Signed-off-by: Keith Wiles <keith.wiles@intel.com>
---
 lib/librte_eal/bsdapp/eal/eal.c   | 1 +
 lib/librte_eal/linuxapp/eal/eal.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index b8152a75c..85d6dddc9 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -374,6 +374,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) {
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 361744d40..9a1289532 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -565,6 +565,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) {
-- 
2.17.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] eal: turn off getopt_long error messages
  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 ` [PATCH v2] eal: turn off getopt_long error message during eal_log_level Stephen Hemminger
  1 sibling, 1 reply; 4+ messages in thread
From: Thomas Monjalon @ 2018-12-19 20:35 UTC (permalink / raw)
  To: Keith Wiles; +Cc: dev

16/12/2018 17:45, Keith Wiles:
> When using dpdk register option api when parsing for log level
> the opterr flags was still set to one causing an error message
> from getopt_long(). Set opterr to zero to disable error messages.

Please could you be more specific?
Which function call? Which error message?

We need also Fixes: and stable tags for backport.
Thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] eal: turn off getopt_long error messages
  2018-12-19 20:35 ` Thomas Monjalon
@ 2019-01-14 14:02   ` Thomas Monjalon
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2019-01-14 14:02 UTC (permalink / raw)
  To: Keith Wiles; +Cc: dev

Keith, it seems you missed my questions below:

19/12/2018 21:35, Thomas Monjalon:
> 16/12/2018 17:45, Keith Wiles:
> > When using dpdk register option api when parsing for log level
> > the opterr flags was still set to one causing an error message
> > from getopt_long(). Set opterr to zero to disable error messages.
> 
> Please could you be more specific?
> Which function call? Which error message?
> 
> We need also Fixes: and stable tags for backport.
> Thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] eal: turn off getopt_long error message during eal_log_level
  2018-12-16 16:45 [dpdk-dev] [PATCH] eal: turn off getopt_long error messages Keith Wiles
  2018-12-19 20:35 ` Thomas Monjalon
@ 2023-06-09 15:23 ` Stephen Hemminger
  1 sibling, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2023-06-09 15:23 UTC (permalink / raw)
  To: keith.wiles; +Cc: dev, Stephen Hemminger

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-06-09 15:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v2] eal: turn off getopt_long error message during eal_log_level Stephen Hemminger

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).