From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id CAA3142D8D;
	Thu, 29 Jun 2023 17:59:28 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 5D8E442BAC;
	Thu, 29 Jun 2023 17:59:21 +0200 (CEST)
Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com
 [209.85.210.174])
 by mails.dpdk.org (Postfix) with ESMTP id 64989410E4
 for <dev@dpdk.org>; Thu, 29 Jun 2023 17:59:18 +0200 (CEST)
Received: by mail-pf1-f174.google.com with SMTP id
 d2e1a72fcca58-668704a5b5bso804188b3a.0
 for <dev@dpdk.org>; Thu, 29 Jun 2023 08:59:18 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1688054357;
 x=1690646357; 
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=y3fHgsR0tPxSTSC5fciugWqXet9+wOwAz2x0F1wMyv0=;
 b=ruGHCNgQzA0oybSV/d1jXJrAnB1VZ5G8pjouQ4xXP+eF5uTSHfOEDnLFFCmUZbhlNL
 qReS5HUy2Vdsic7HAqRZj64ZOScfr4iYOKUM8/DO1rW+pGPKZQc/kcnCaLswAtNVU9Iz
 djb2rvPGvz7ewqmdvX1UJTD20iaXx4N4sVMm4ykBDQS15I4ikb+QOBjx7Sy7kGyzizH1
 2GsSTQFbBaQ4qezs3HhaUW4Oz7gPxa02mmVleIpVWhA1zpk5Mqz3Mn/Ki2EdFBhPQ2Dm
 Zq4kQ7U3d59tnkMEW/8Oup+FiN1MivGN1QogC3uzk+VBCqMaWICXA2DZZyONruZ4k89Z
 sa1A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20221208; t=1688054357; x=1690646357;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=y3fHgsR0tPxSTSC5fciugWqXet9+wOwAz2x0F1wMyv0=;
 b=e6x3slIiSCnTbV1Bhi+rIvTwt9S4uYD2bo098VeihREGqQuOzN0gx0RohDHGAE4XrQ
 gkpoPdnBzIr82/82XvB/q3dY9X/T75m7MpDGtiXZ6gBqMJDINe8PhevdOr+qfwGBqU5E
 JLUX+KbaLMg7/nIZDDdxwA13laceUemqlIPSVbiwW44HXggFX4tau7UvFo4E1m8Yw8yD
 Zjh1Pp35KfiBMOiRv4OaP9dCwhhGoI5HTEap3gf96mYMUbyG3IOM2J+VclCbOptV/o6o
 YBM2iNcwykiVkgYwD+2oEufKhkTNZ7Ra0j5lmDH5xja2P7rKwDJpDnm4epd04H40Lo8Z
 P8wA==
X-Gm-Message-State: AC+VfDy+hXkclDLtzwiHDMz8ReE3mgNEtNbutOxlLed77meBH000e37n
 MOnGkeSSouOvrhgxoakYxdWCbYY9TMTUhbjIHJ2Y8Q==
X-Google-Smtp-Source: ACHHUZ5FG4lJ/wQaSRlMU41HuW9hSIMekTbqHbAJ1Fz66Vwg2220HS1h1gWTs8qgUDkIWZ2PEJd42w==
X-Received: by 2002:a05:6a20:488:b0:126:3c08:77fa with SMTP id
 8-20020a056a20048800b001263c0877famr16916pzc.48.1688054357325; 
 Thu, 29 Jun 2023 08:59:17 -0700 (PDT)
Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218])
 by smtp.gmail.com with ESMTPSA id
 c6-20020a63ea06000000b0055b553157a5sm471716pgi.71.2023.06.29.08.59.16
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 29 Jun 2023 08:59:16 -0700 (PDT)
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
 Keith Wiles <keith.wiles@intel.com>,
 Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>,
 Narcisa Ana Maria Vasile <navasile@linux.microsoft.com>,
 Dmitry Malloy <dmitrym@microsoft.com>,
 Pallavi Kadam <pallavi.kadam@intel.com>
Subject: [PATCH v6 2/6] eal: turn off getopt_long error message during
 eal_log_level
Date: Thu, 29 Jun 2023 08:58:39 -0700
Message-Id: <20230629155858.75668-3-stephen@networkplumber.org>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <20230629155858.75668-1-stephen@networkplumber.org>
References: <20200814173441.23086-1-stephen@networkplumber.org>
 <20230629155858.75668-1-stephen@networkplumber.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

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(+)

diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 7e2f010fa371..ada3ed5ebec9 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -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
diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c
index 240d5b8ad3e4..c6006c48ddef 100644
--- a/lib/eal/windows/eal.c
+++ b/lib/eal/windows/eal.c
@@ -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) {
-- 
2.39.2