From patchwork Mon Apr 5 19:29:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 90572 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 06295A0A02; Mon, 5 Apr 2021 21:30:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C8C45140E8E; Mon, 5 Apr 2021 21:30:14 +0200 (CEST) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by mails.dpdk.org (Postfix) with ESMTP id CE5FC140E8A for ; Mon, 5 Apr 2021 21:30:13 +0200 (CEST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id C54511A73; Mon, 5 Apr 2021 15:30:12 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 05 Apr 2021 15:30:13 -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=zQz8ZcofkXN67 fgoxI9rvLy38vrHic5K38f7t1jD3U8=; b=qHfHnOG5UGWc1X9ir9yoYOWuuAINs Y2noGdx1mFRiQPGeabq0X6oSJFhBHrCxuJJfpV20j7xWWmg1LBakdPCXTaMK5jQ5 ZvcwKRvIbZ+idKhrnW3tCaxHx/NgZw8BHv240QcTmSYJgJOKFc+5btKYQQcRbz4r OuM1IRCXguL4ZF+tnK1Cop3ssqQj860CEKEdxj4tWy7yxaS6OZYk1t7UeN/HdbWh W9E5v9G9H9nea0uSSc7F0yUj8douZbUTkmNVhi2YUEL0KB0r7vGZevHeb2GQC4XH gxmjlOudSaWiTUGjKFRgozTtVMfHvHN3QuIEDIwCYVCXWMN2LRMgFvh+g== 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=zQz8ZcofkXN67fgoxI9rvLy38vrHic5K38f7t1jD3U8=; b=dyvK7X1K PsjFrS58jQ6anEARmhwzlj3yJAbUhDb4n3bdvAEGApn3jxuwq4sARVR8A/a25lwp y36YRzy8SCYgYBN81pdRwNMQ3JPvHYFQLGrzDSETzqIxAKDVF79Phbezwr+3A3Wz OTLPt2w8j6/dDcyEIIKwyUPIQcLBTtPrZGyeW/+3ifR+AnjiNtoE50KIu8vKGqdh 7Aj5OSK+pqaMUUzUXAODL9UL2QBH65ji9Xp5K6w1kmAiBmHYW7ZI5Iw+IIn6hXl8 CIM5B7aaZjpqy2cEZYeXM3AKDl90CUZOhnjcy00ai/zrjzcLEgcLaI1G1gyf+k2v nXxn7kq6L8WEkQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudejvddgudegtdcutefuodetggdotefrod 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 8D9D9240057; Mon, 5 Apr 2021 15:30:11 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson , Andrew Rybchenko Date: Mon, 5 Apr 2021 21:29:59 +0200 Message-Id: <20210405193000.1113542-4-thomas@monjalon.net> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210405193000.1113542-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> <20210405193000.1113542-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 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 --- 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) {