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 C3A29A0547; Fri, 12 Mar 2021 19:18:11 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B8F2C1608F6; Fri, 12 Mar 2021 19:17:40 +0100 (CET) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by mails.dpdk.org (Postfix) with ESMTP id D51B61608E4 for ; Fri, 12 Mar 2021 19:17:37 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 880285C0192; Fri, 12 Mar 2021 13:17:37 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Fri, 12 Mar 2021 13:17:37 -0500 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=NrugjjMlUy0qw GPMaC5t3BrE4IriGFoFPOQ6U9Mxpbc=; b=Qn2SBWGvwhIt7qLT5W9dBgDEiHc/G P0ISuyrp3Sv8clm97hT0n7ECgoiDAKoOXKRE4dvznqFeANjlGkmsVLcE2zHXMCR9 H7cBv4nDYKi4e6T1pHX7D2KzxpC+x2YlGsyDxe5YVJ3N29h3gjHMt5yGVTmfdxKL mLqFw5Cn11MN+ispRJPDg3e0GQh54N3BPmISUKCn1o2Eal8MU2mO8PdwWUUBMD9y +kEh64/NzLsgHn9W3CZB9hiKamCGQijihbrxDAPX8BZRrT+za+Gqjk5I0fpijTMf eS96Wp729fsFk2P9LSEQlnraNDfSMW8Dky0/sQQlS2K+63lYpTjlnoLUw== 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=NrugjjMlUy0qwGPMaC5t3BrE4IriGFoFPOQ6U9Mxpbc=; b=FC6IYmCH mw2s+Mv2MjvxlQzQyG03OBgdFn4oIs9vbbdsERVac8u3Oxhb4lQCdSKixqqJEICl xofDe+qk8DZLR6EMqcmvOASRtqcQdyT5Xw3mjBm5t5i/lV8WuTFwQkX3oFaqqb3U Xwsgws+D76hIhjXbjDUHp/unqidGyxjSAdVC3G2DIzk5tYR/9N2WDsxDzsiEHQGx k7HbCuhFLRnLKW7LtxLYZ+H4+P6nzQ7mc36kysk5OTokiwlesa0YEvRO5RWcHhjD 4qa4PL9RpJFalLzwaOFDXQ6zqpO9G9vTpFUkS4zc+cPo7YhygRA3gKhSl9Xr/CjL 95kN7Hi53/oLpg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddvvddguddutdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvhhhomhgrshcuofhonhhjrghlohhnuceothhhohhmrghs sehmohhnjhgrlhhonhdrnhgvtheqnecuggftrfgrthhtvghrnhepvdehgfeivdejgedtve ehfefhteelfefgieevgfffveefjeegtdfguedthedtgeevnecukfhppeejjedrudefgedr vddtfedrudekgeenucevlhhushhtvghrufhiiigvpeefnecurfgrrhgrmhepmhgrihhlfh hrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght 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 D82E2240054; Fri, 12 Mar 2021 13:17:36 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: david.marchand@redhat.com, bruce.richardson@intel.com, mb@smartsharesystems.com Date: Fri, 12 Mar 2021 19:17:15 +0100 Message-Id: <20210312181720.242252-7-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210312181720.242252-1-thomas@monjalon.net> References: <20210309233116.1934666-1-thomas@monjalon.net> <20210312181720.242252-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 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 --- 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