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 91D0B42C6F; Fri, 9 Jun 2023 17:23:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 34C0F42FC4; Fri, 9 Jun 2023 17:23:47 +0200 (CEST) Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by mails.dpdk.org (Postfix) with ESMTP id F156542D8F for ; Fri, 9 Jun 2023 17:23:45 +0200 (CEST) Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-662f0feafb2so1473217b3a.1 for ; Fri, 09 Jun 2023 08:23:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1686324225; x=1688916225; 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=rMUdUcWPfcT6PqsrWo9BcORI48BDUo4L20IFUu3BbEQ=; b=h8yJJQHJY+84Y2pjLyqhW2U2uUNO6XGOAC2rIwjbqbRKYAP8H2IdS87PJjAp9hlIdv 36J3TksXa+aXNDF/WhUzauLqwrwnu+mP1by7otYecuQIxt56W/0b4HcGUYxZpxbqjG0p JWJTRRf3GP/CFZKh6DlTKG5iNy2S/vAsXq71M4U6lodrC4kB6ATnSiqcN8hFUTah4BMy gTfoz20Rjo79Pey8Node4uK+78UU/voCH9nSnx9JsyraKSuQAv0cboS/aha2RiFbcX3A H6NiDL5YApJhxZNLa8IcAFBqc+BgCpPWiswVxgLB+YgMyHEVX05nEWB/tz4iqqGDu5os NIDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686324225; x=1688916225; 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=rMUdUcWPfcT6PqsrWo9BcORI48BDUo4L20IFUu3BbEQ=; b=EfPzFqKLlfTh/dqz38+TBPRAFI/93wOx5n6KeSbAtVGdnz02xty2jlsSX05a7BAMZw MSEsxI1qDQMxkH+EaGHwuHxkyk7hBFA3m1ZmO4c5yC5ik2cVJRYX5l5Ul6i8QDRkr96H OY5qtwmF+0SLT4TRjS8Qj+IaIntEBmp5YRNUTbhZqRYJVRRdJJkAhkQfc2WkRhzoHlP8 M2wBanJndQdQCNVIq/IyENdCcGRz0C+4ovNVYJLXHTK8w3G4pZ2liv148TeB3nsslvOH JSd5OlbMefWWLaoBih2LhdlquJvTs27eFalVTlAudLnfGBI6/qrOMWKUmQscCBM+CdbB MruA== X-Gm-Message-State: AC+VfDzAUnkEGd/EUjx6DTLxOerYSk9VJUchnsMm0wlP6zc5rNNUQcSW Vlg/zCGAmk3+7Z/c7sSGAV1cmQ== X-Google-Smtp-Source: ACHHUZ4Poz0NJKYwFNzsH4TwoPL4+s1LMwLkZz30V5VZ9o59qPLhwv1oAx0OsApu7HY55/2sVlChCg== X-Received: by 2002:a05:6a00:1884:b0:64d:40e0:5580 with SMTP id x4-20020a056a00188400b0064d40e05580mr2924680pfh.3.1686324224843; Fri, 09 Jun 2023 08:23:44 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id c9-20020a62e809000000b0064d48d98260sm2804037pfi.156.2023.06.09.08.23.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 08:23:44 -0700 (PDT) From: Stephen Hemminger To: keith.wiles@intel.com Cc: dev@dpdk.org, Stephen Hemminger Subject: [PATCH v2] eal: turn off getopt_long error message during eal_log_level Date: Fri, 9 Jun 2023 08:23:42 -0700 Message-Id: <20230609152342.77405-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20181216164559.89835-1-keith.wiles@intel.com> References: <20181216164559.89835-1-keith.wiles@intel.com> 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 supressing printing error message on first pass. Signed-off-by: Keith Wiles Signed-off-by: Stephen Hemminger --- 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