From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7382342D82; Wed, 28 Jun 2023 19:58:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 373E742BC9; Wed, 28 Jun 2023 19:58:37 +0200 (CEST) Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by mails.dpdk.org (Postfix) with ESMTP id 7B68C40E2D for ; Wed, 28 Jun 2023 19:58:33 +0200 (CEST) Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1b809354a15so1358885ad.1 for ; Wed, 28 Jun 2023 10:58:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1687975112; x=1690567112; 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=aFjKo6J4vWeRRCmVV+Rnr9f2wmRMmQKTwPLzfJX+Zig=; b=QoAH45mZWwwHJNldwyjBElKlRc/eYcVVaunhTg7D86NtWQwLcth65peFRa9U/u7Uoa cxv7uiEILXO8GLd3ntAxaSesGX2aQ6yHHaFI/HDYFrgEE/Deg2NTcog0LxkZQQ2STAjg AiMFyFHCZtoQx6ux76kZUEwXHxMWfk8vMg6hwPZUI/Aaq8j2vKytbxFE73UKlxV0Tvdd RmGiioEh3XQ2XEsWoej+01CggDp/K9JmReiojNqX0/t8fablaeOQtSZ7nL0RzHk62vmA RT+r+y8bc1PetWSVUi8eVeNvWm1/vrupabqiSQI6+DD49FCd8kwWdFau7Kip/+HPC4cH QbdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687975112; x=1690567112; 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=aFjKo6J4vWeRRCmVV+Rnr9f2wmRMmQKTwPLzfJX+Zig=; b=mGdgDds0pIpfdShltowhpvZECLmo1Za9gHqxhEUPIRyp6vevtJB8BmluSKDgHUK0at EBJ7tLi6yLpBvxEAVVauDc1n2IORC15yGNb37//1EFEQasLIAfW9BPdWcGNDa+2rd2ny JGiAh0bYTFa19v/MK22q/X1c+Bgu0bHcjL2s8Zd/OacDGyEsZqlnmpdnuLHRCi+yy4ib 6t0AX0DsF04VJAaj9jM01OGw/m27EbhXRSqvRC66Bk0N5fP7zSqGBpjuLLfDWEY0bbmc gP5SNnEjRRJPf4BQzH4vvnhCnoTL6tBSgcBCiOWFhUgmMnzl3y5riGM2JaITON5Tkzye 8mNQ== X-Gm-Message-State: AC+VfDwpOdQ/jskWqJH4YQ67nTEKh7LzrR4gKxMx1UBKgxupi4fRyeIo ujusp0pa7IZuMIy5S6fzQKRsz2kEjtL73SXI0cQXeA== X-Google-Smtp-Source: ACHHUZ6tMonIqY9rBnBaj7pQcYjapvHcPWgVciry/yc0SdbUdQkyZ2+Z0eroBRmIju9AsNnMR7n46Q== X-Received: by 2002:a17:902:c1c5:b0:1b8:11b9:d40a with SMTP id c5-20020a170902c1c500b001b811b9d40amr5652148plc.69.1687975112237; Wed, 28 Jun 2023 10:58:32 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id g11-20020a170902868b00b001b80d399730sm5047875plo.242.2023.06.28.10.58.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jun 2023 10:58:31 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Keith Wiles , Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Subject: [PATCH v5 2/6] eal: turn off getopt_long error message during eal_log_level Date: Wed, 28 Jun 2023 10:58:23 -0700 Message-Id: <20230628175827.471909-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230628175827.471909-1-stephen@networkplumber.org> References: <20200814173441.23086-1-stephen@networkplumber.org> <20230628175827.471909-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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 Signed-off-by: Stephen Hemminger --- lib/eal/unix/eal_log.c | 3 +++ lib/eal/windows/eal.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/lib/eal/unix/eal_log.c b/lib/eal/unix/eal_log.c index f8a5c853f2df..3f54284494d7 100644 --- a/lib/eal/unix/eal_log.c +++ b/lib/eal/unix/eal_log.c @@ -64,12 +64,14 @@ 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_optrset = optreset; #endif optind = 1; + opterr = 0; #ifdef RTE_EXEC_ENV_FREEBSD optreset = 1; #endif @@ -94,6 +96,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 2d7a0e9ab27e..0800a9e5c2d2 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