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 C2258A0546; Tue, 6 Apr 2021 15:12:06 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A3DE4140F5D; Tue, 6 Apr 2021 15:11:54 +0200 (CEST) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by mails.dpdk.org (Postfix) with ESMTP id D5017140F3E for ; Tue, 6 Apr 2021 15:11:51 +0200 (CEST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 7EAD95C009F; Tue, 6 Apr 2021 09:11:51 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 06 Apr 2021 09:11:51 -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=VTpKRPVlIczBiONGXytu0PMDroozg sIYmXqL/CTZF59Sx/tU7v43+mNSvyTlhpajXI0MhqqiZYy1P+yCKPYZg4Fex9BXM jbh5Llixl+iEJHqvKQZqFBPAWcamAA8mKaHLz9CDwdOx2NjXhP6t15YqUxmGiVB5 SuuSWoW3/kguOGuk/N3GGu2cqXzz1z7d0RQX1gAKUUzAGKdBPgNUWnGDXj601uKb WK692/dhdPuHBp86hEuCPdM06+5h2XKFJeKmc8ObEo7MAk5qSXD0tg0waKXvilLG 34hspVjSq1G/xmy4bPy6lwMVCq3onGlyeQnLgMhDZ1l5dJ9zM8fb85+fA== 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=F0KH9Bnq q6WzCQln+WRfnSzLga6sjW5VXGQzy52WEWHLKExDNbia1MQ1IidkMf+pMeTi8bkp M/ghsVlRWIs4vGlm2RcvTVbyPaPHhrP4YyWjQ6yHZRjNJHAPv6Bi7RSN5a3gkJ1h W9GtMwcdwvCBSm7FK4kAgHD1X2KQ4ImTTJuzdP+VEOrtXERnYc8Bc9/u/jVCkrnX ptuUeKVF7JkoJMoNDueBgXnYvSrPxLskN7XXA7HL2e0m0lou4828f+HEnLLtAu+v eMiWUe+2Bw0WaXJbyk6Uu5MqaSLpMO8vYHpBtA8YK/+ZYFYcfN656X2NQbZdMA68 YVH66OA5lYe50w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudejhedgtdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl ohhnrdhnvght 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 C87B724005C; Tue, 6 Apr 2021 09:11:50 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson , Andrew Rybchenko Date: Tue, 6 Apr 2021 15:11:36 +0200 Message-Id: <20210406131137.1732110-4-thomas@monjalon.net> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210406131137.1732110-1-thomas@monjalon.net> References: <20210405193000.1113542-1-thomas@monjalon.net> <20210406131137.1732110-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v6 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) { -- 2.31.1