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 B83F7A0567; Wed, 10 Mar 2021 13:19:36 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 909C64068C; Wed, 10 Mar 2021 13:19:36 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 87A0140687 for ; Wed, 10 Mar 2021 13:19:34 +0100 (CET) IronPort-SDR: ul1O3rQvbSh2nK/p2Mp8Ae6uFNF1iH0eNRR3t9guDsLv4P8FVgO8u7a9i8/Kg9EoL+J1OIgjXZ NvMOI2jHRgXQ== X-IronPort-AV: E=McAfee;i="6000,8403,9917"; a="168368199" X-IronPort-AV: E=Sophos;i="5.81,237,1610438400"; d="scan'208";a="168368199" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2021 04:19:33 -0800 IronPort-SDR: BALZp79Z2Pkci0vii7rmh3uYckvF+JRx5nzfpZD3H94d4W01j1yZl9JAFb8brgTydH6q1/28kk JguzeoSh7QDQ== X-IronPort-AV: E=Sophos;i="5.81,237,1610438400"; d="scan'208";a="410164384" Received: from bricha3-mobl.ger.corp.intel.com ([10.252.9.86]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 10 Mar 2021 04:19:31 -0800 Date: Wed, 10 Mar 2021 12:19:24 +0000 From: Bruce Richardson To: Thomas Monjalon Cc: dev@dpdk.org, david.marchand@redhat.com Message-ID: <20210310121924.GA1267@bricha3-MOBL.ger.corp.intel.com> References: <20210309233116.1934666-1-thomas@monjalon.net> <20210309233116.1934666-7-thomas@monjalon.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210309233116.1934666-7-thomas@monjalon.net> Subject: Re: [dpdk-dev] [PATCH 06/11] eal: catch invalid log level number 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 Sender: "dev" On Wed, Mar 10, 2021 at 12:31:10AM +0100, Thomas Monjalon wrote: > The parsing check for invalid log level was not trying to catch > irrelevant numeric values. > A log level 0 or too high is now a failure in options parsing > so it can be caught early. > > Signed-off-by: Thomas Monjalon One thing I'd note here is that our log range of 1 to 8 is a little strange, and that it would be nice if we could accept 9 as a valid log level too on the cmdline. Ideally 0 would also be acceptable, for all logging off, but it's more likely that people want to up the log level than reduce it, and 9 is a more expected max value than 8. > --- > lib/librte_eal/common/eal_common_options.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c > index febc99612a..5b9ce286ff 100644 > --- a/lib/librte_eal/common/eal_common_options.c > +++ b/lib/librte_eal/common/eal_common_options.c > @@ -1289,7 +1289,7 @@ eal_parse_log_level(const char *arg) > } > > priority = eal_parse_log_priority(level); > - if (priority < 0) { > + if (priority <= 0 || priority > (int) RTE_LOG_MAX) { > fprintf(stderr, "invalid log priority: %s\n", level); > goto fail; > }