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 9C93CA034F; Sun, 21 Mar 2021 23:32:41 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 562F6140E30; Sun, 21 Mar 2021 23:32:08 +0100 (CET) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by mails.dpdk.org (Postfix) with ESMTP id DC803140DF0 for ; Sun, 21 Mar 2021 23:32:02 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id D4A0611F6; Sun, 21 Mar 2021 18:32:01 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 21 Mar 2021 18:32:02 -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=BlJKgr9N2Sc8x w5BWBp9B3vDQESft/zos79GhHzXwIE=; b=H6BTcCPgyiEAvJcrzYOxOf1c5CnDj CJ/y0HhZv92rHi+lsJonO1BTxeNlIXqF5wnNryN73vT3A7BJ+FX5RIRiG031qH7p P/y+IMrWDDZwKUszZS92xiCNK5QC+ZBUtV25Z0BIlvP/Bz9oCK8iJWCi6rydJPFZ tlNTCNvhZM41m2C7nx9S+2b2AYHcWCffmmS1VjUNvsXXrH464F8x3dorKqvqSH/G OhgnMDLe5UXmfIQNlygUUQYC+IdSUL1EaQNd3kMqG27kfICo4X4Bq/h/2Tx+BxHh ibueYb+FzkJqMk8FGuFNMljw/8ICUsFE40vXJs8D+hlc6acMj98OKBZbA== 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=BlJKgr9N2Sc8xw5BWBp9B3vDQESft/zos79GhHzXwIE=; b=Ltq9U1DS e95uR9h6VAbsGvm5Lg8mLFKl1YyFGUmUvu3cUc2+FxaNd14986hdSaUVCf3cCRLU w9kIQxeR7+FhVxv3P6i2l+Yn2lrRGkrfyWH8neR4Y3IMYlAGKY9NqF9vVn4AyMcK kx03Te/IZKOg6KIzXU7S1bnYPQv5FQqRCOEqH42fEnhHn+kfnB2IRo2Q4bhvIDpi Q7XfDntGEQr40XUM//eceHEOZNncnzZMlBaX3UAG0qwzL7XbyFNRkIuBjl591R4+ MpYWRiSGvzPFn9bb5OFGwhTTZcMRRtjDVgGcMDy8wAU0sStL6wVKSWGyuzWgVLRI Q4NFRZDysKgwCg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudegvddgudeivdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedt gfeutdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrh fuihiivgepgeenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr 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 D2B55240356; Sun, 21 Mar 2021 18:32:00 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson , Andrew Rybchenko Date: Sun, 21 Mar 2021 23:31:10 +0100 Message-Id: <20210321223116.1340974-7-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210321223116.1340974-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> <20210321223116.1340974-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 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" The parsing check for invalid log level was not trying to catch irrelevant numeric values. A log level 0 is now a failure in options 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 --- 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 3675e55fc9..2df3ae04ea 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.30.1