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 B60CF459C3; Wed, 18 Sep 2024 09:18:08 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A48C24029B; Wed, 18 Sep 2024 09:18:08 +0200 (CEST) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by mails.dpdk.org (Postfix) with ESMTP id 25AA74028F for ; Wed, 18 Sep 2024 09:18:07 +0200 (CEST) Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4X7qjL2V8Sz2DcBq; Wed, 18 Sep 2024 15:17:26 +0800 (CST) Received: from dggpeml500024.china.huawei.com (unknown [7.185.36.10]) by mail.maildlp.com (Postfix) with ESMTPS id 80AF91A0188; Wed, 18 Sep 2024 15:18:04 +0800 (CST) Received: from [10.67.121.161] (10.67.121.161) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Wed, 18 Sep 2024 15:18:04 +0800 Message-ID: Date: Wed, 18 Sep 2024 15:18:04 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v23 04/15] eal: make eal_log_level_parse common To: Stephen Hemminger , CC: Tyler Retzlaff , =?UTF-8?Q?Morten_Br=C3=B8rup?= References: <20200814173441.23086-1-stephen@networkplumber.org> <20240918045830.3798-1-stephen@networkplumber.org> <20240918045830.3798-5-stephen@networkplumber.org> Content-Language: en-US From: fengchengwen In-Reply-To: <20240918045830.3798-5-stephen@networkplumber.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.121.161] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500024.china.huawei.com (7.185.36.10) 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 On 2024/9/18 12:56, Stephen Hemminger wrote: > The code to parse for log-level option should be same on > all OS variants. > > Signed-off-by: Stephen Hemminger > Acked-by: Tyler Retzlaff > Acked-by: Morten Brørup > --- > lib/eal/common/eal_common_options.c | 45 +++++++++++++++++++++++++++++ > lib/eal/common/eal_options.h | 1 + > lib/eal/freebsd/eal.c | 42 --------------------------- > lib/eal/linux/eal.c | 39 ------------------------- > lib/eal/windows/eal.c | 35 ---------------------- > 5 files changed, 46 insertions(+), 116 deletions(-) > > diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c > index f1a5e329a5..b0ceeef632 100644 > --- a/lib/eal/common/eal_common_options.c > +++ b/lib/eal/common/eal_common_options.c > @@ -1640,6 +1640,51 @@ eal_parse_huge_unlink(const char *arg, struct hugepage_file_discipline *out) > return -1; > } > > +/* Parse the all arguments looking for log related ones */ > +int > +eal_log_level_parse(int argc, char * const argv[]) > +{ > + struct internal_config *internal_conf = eal_get_internal_configuration(); > + int option_index, opt; > + const int old_optind = optind; > + const int old_optopt = optopt; > + const int old_opterr = opterr; > + char *old_optarg = optarg; > +#ifdef RTE_EXEC_ENV_FREEBSD > + const int old_optreset = optreset; > + optreset = 1; > +#endif > + > + optind = 1; > + opterr = 0; > + > + while ((opt = getopt_long(argc, argv, eal_short_options, > + eal_long_options, &option_index)) != EOF) { > + > + switch (opt) { > + case OPT_LOG_LEVEL_NUM: > + if (eal_parse_common_option(opt, optarg, internal_conf) < 0) > + return -1; > + break; > + case '?': > + /* getopt is not happy, stop right now */ > + goto out; no need goto, could use break > + default: > + continue; > + } > + } > +out: > + /* restore getopt lib */ > + optind = old_optind; > + optopt = old_optopt; > + optarg = old_optarg; > + opterr = old_opterr; > +#ifdef RTE_EXEC_ENV_FREEBSD > + optreset = old_optreset; > +#endif > + return 0; > +} > + ...