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 0186CA0579; Thu, 8 Apr 2021 18:47:36 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F16E6141182; Thu, 8 Apr 2021 18:47:24 +0200 (CEST) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by mails.dpdk.org (Postfix) with ESMTP id 1A925141174 for ; Thu, 8 Apr 2021 18:47:22 +0200 (CEST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id C64DF5C0089; Thu, 8 Apr 2021 12:47:21 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 08 Apr 2021 12:47:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=Y38rRCnPnNa4H /s/Cf2beEhSXXrJflgCLqLSBxvOmJE=; b=aKWsetsqn6TwwIvwBci3pIme+GPi6 vIOxW9wS0v5s4RP+nsyukGvkRi6y13TGF6LwlStmL2RfU2BtvQwl2DEa9GuAGwAO ziZg9xyQe1xthXfdNkNe2u5sApK7QxG576hVzvW+LumIDT8CQU176F/Wt0NzuGQv GC43Q4D4s/Xqs3kJXlRcg4ynvku2IJijCjHH8RDRFe2nQBPTPl0rpqAa/7Q40p8f sxQk3/iqsHFsMN9xD01fhFnXt0Gc+kgIiHyM64Q52TXta4Fuo6sGvdgOGxrcYPI4 X4Q9E+9hI/9asAy3/7oT2VS20Hve0aJrTtnv7taWqZlcDhYA19eb0zBGg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=Y38rRCnPnNa4H/s/Cf2beEhSXXrJflgCLqLSBxvOmJE=; b=LuOHDnOB c8hemSvK3vCC9Ik+EjAG9TRCZwoz2Opev+8KpVdCyOMm8tNYagTOQIBsXWri4Hzs 0Q+ibmz/yvvCO1l5hfBa9N7QnrREj57ycDp+fCnVljoN/V6MLfeMNMXKie2/FySl nChT8Sl4Fr9rhCCFMeqsiTbSjiagRimL9oB0bigN/avZ4dNJZmkq4Vsjt7WVfXHX blg+XPk7MF7pUXIshc8PBT2KXEh+W/dmWFPx+QHwD9BOTVCLjALrAqmEPkHvKb7c 8J+Fc9keaX2AQ088Cf2OkbVrsEA1TjiOAA8iA/9jjYSxwhHmKZdReI4BfPsGiq5P YjMNGOM8otibjA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudejledguddtjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedt gfeutdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrh fuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr lhhonhdrnhgvth X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 38C32108005C; Thu, 8 Apr 2021 12:47:21 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson , Andrew Rybchenko Date: Thu, 8 Apr 2021 18:47:12 +0200 Message-Id: <20210408164713.3455145-4-thomas@monjalon.net> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210408164713.3455145-1-thomas@monjalon.net> References: <20210405193000.1113542-1-thomas@monjalon.net> <20210408164713.3455145-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v7 3/4] log: catch invalid level option 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" The parsing check for invalid log level was not trying to catch irrelevant numeric values. A log level 0 becomes a failure in parsing so it can be caught early. A log level higher than the max (8) is accepted with a warning message. Signed-off-by: Thomas Monjalon Acked-by: Bruce Richardson Acked-by: Andrew Rybchenko Reviewed-by: David Marchand --- lib/librte_eal/common/eal_common_options.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 38b72fb665..7075a051b8 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -1289,10 +1289,15 @@ eal_parse_log_level(const char *arg) } priority = eal_parse_log_priority(level); - if (priority < 0) { - fprintf(stderr, "invalid log priority: %s\n", level); + if (priority <= 0) { + fprintf(stderr, "Invalid log level: %s\n", level); goto fail; } + if (priority > (int)RTE_LOG_MAX) { + fprintf(stderr, "Log level %d higher than maximum (%d)\n", + priority, RTE_LOG_MAX); + priority = RTE_LOG_MAX; + } if (regex) { if (rte_log_set_level_regexp(regex, priority) < 0) { -- 2.31.1