From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1A880A04E7; Wed, 4 Nov 2020 09:04:13 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 559C1C7F4; Wed, 4 Nov 2020 09:04:11 +0100 (CET) Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by dpdk.org (Postfix) with ESMTP id ACB0CC6C8 for ; Wed, 4 Nov 2020 09:04:08 +0100 (CET) Received: by mail-wm1-f65.google.com with SMTP id 205so1430963wma.4 for ; Wed, 04 Nov 2020 00:04:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=RwtH0a19wV90HTXOr94zOO45ZZJt1j7dwnQ0Va71/qs=; b=dmwi0kXR44tLVocw5iwQARqNOwI/lfw0W7iGjMxcmJAYZqlWiEz2Qg3PSME30fLx3S p0aCtatA9F+V6t6f9rafRHVct2oQCaNJNjdxlGUKkzd2zD6xsNU7a9xF7nARAWwww4m/ D6W1h+XemDArPUzkZ1IbfsvsAYaoIKtSsM6nDcw27Ec1aD+dW1M3AH1mh4fXn4j2cgQY 0yAWjbJzX0typugOqGBcqZoyomn9VdhDzRRNBwiEzJlx46clqC7lE/GsxOrG0KHZGuO8 tzZuDACtxT/ZRxdRDhKLE61XlyuLahGllOU8T1R8HTdAo9muWcUMyjmqAHlrXhri+AMx wONQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=RwtH0a19wV90HTXOr94zOO45ZZJt1j7dwnQ0Va71/qs=; b=Azrsu5kDphkAuL4cblfr5rvdKTG797VQu4GH/cHVGvCETPeHepV5PsuI1495c88FvK DMzB8WAyPTWahmfKrACwmR2sb5Zx97WD6UM+pICRzrGUoe+1eaztv7zw7dxvX18LePCM j7yEFQO/mTAhVTDXVCG0zwyQU4EKeJXbqhBGT5gDm1rfe47QMFTxBNroK1ks/JPCI20y hApfmAujbRUZczh6nKGKyT+QcAIBZSpIBpo5T8dM4YmPIJ3N3oiSp+ZRSj4F+pvtdEpf 8MfbXwjKTHIU9aX+j8Ey9Cs0iSumT5Da+Jk6Ebi+dY0k3KDmX7qkGlEOzeoeVLWVim10 +nyw== X-Gm-Message-State: AOAM531qoSKM4kvGCPEvvyl2rO8ZO2qzQ2Z4xn1mlCEsvCuMJM9u9jJc p0jCOPwHGJAo6E5ohIsuDwpKmg== X-Google-Smtp-Source: ABdhPJw4trFQysQSGNi9ZiRrvet0miWBFsCEtNtEi33+yNhi8rr8f1RqzV98Fugdby2LMXS6t6EHBw== X-Received: by 2002:a1c:2ec6:: with SMTP id u189mr3242773wmu.85.1604477047352; Wed, 04 Nov 2020 00:04:07 -0800 (PST) Received: from 6wind.com (2a01cb0c0005a600345636f7e65ed1a0.ipv6.abo.wanadoo.fr. [2a01:cb0c:5:a600:3456:36f7:e65e:d1a0]) by smtp.gmail.com with ESMTPSA id g66sm1269484wmg.37.2020.11.04.00.04.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 00:04:06 -0800 (PST) Date: Wed, 4 Nov 2020 09:04:05 +0100 From: Olivier Matz To: Stephen Hemminger Cc: David Marchand , Robin Jarry , dev , Bruce Richardson , Neil Horman , Rosen Xu , Andrew Rybchenko , Luca Boccassi Message-ID: <20201104080405.GG1898@platinum> References: <20201103183906.8088-1-david.marchand@redhat.com> <20201103192750.zr6gh3oz3wjnbeys@6wind.com> <20201103155439.624bc17c@hermes.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201103155439.624bc17c@hermes.local> User-Agent: Mutt/1.10.1 (2018-07-13) Subject: Re: [dpdk-dev] [PATCH] usertools: fix pmdinfo parsing X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" On Tue, Nov 03, 2020 at 03:54:39PM -0800, Stephen Hemminger wrote: > On Tue, 3 Nov 2020 21:20:43 +0100 > David Marchand wrote: > > > On Tue, Nov 3, 2020 at 8:27 PM Robin Jarry wrote: > > > 2020-11-03, David Marchand: > > > > This script was using the librte_pmd prefix has a filter to follow > > > > as* > > > > > > DT_NEEDED entries. > > > > Now that we changed the driver names, update this heuristic with an > > > > explicit list of device classes. > > > > > > > > Fixes: a20b2c01a7a1 ("build: standardize component names and defines") > > > > > > > > Signed-off-by: David Marchand > > > > --- > > > > usertools/dpdk-pmdinfo.py | 5 ++++- > > > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/usertools/dpdk-pmdinfo.py b/usertools/dpdk-pmdinfo.py > > > > index 1661982791..687a9fd032 100755 > > > > --- a/usertools/dpdk-pmdinfo.py > > > > +++ b/usertools/dpdk-pmdinfo.py > > > > @@ -450,7 +450,10 @@ def process_dt_needed_entries(self): > > > > for tag in dynsec.iter_tags(): > > > > # pyelftools may return byte-strings, force decode them > > > > if force_unicode(tag.entry.d_tag) == 'DT_NEEDED': > > > > - if 'librte_pmd' in force_unicode(tag.needed): > > > > + words = force_unicode(tag.needed).split('_') > > > > + if words and len(words) >= 3 and words[0] == 'librte' and \ > > > > + words[1] in ['baseband', 'compress', 'crypto', 'event', > > > > + 'net', 'raw', 'regex', 'vdpa']: > > > > > > This code is already ugly and I don't have much better to suggest... > > > > Less ugly with a regular expression? > > > > if re.match(r"^librte_(baseband|compress|crypto|event|net|raw|regex|vdpa)_", > > force_unicode(tag.needed)): > > > > > > I prefer the list approach, much less error prone. > The code would read better if the list of drivers was in a variable > instead of a long line of code and the string processing was done separate from > the test. > Something like > drivers = ['baseband', 'compress'... > prefix = 'librte_pmd' > name = force_unicode(tag.needed) > if name.startswith(prefix): > suffix = name[len(prefix):] > if suffx in drivers: > > > I agree with Stephen that the list approach and an intermediate variable is clearer than regex. However, I'd keep the split() as in the original patch.