DPDK patches and discussions
 help / color / mirror / Atom feed
From: Olivier Matz <olivier.matz@6wind.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: David Marchand <david.marchand@redhat.com>,
	Robin Jarry <robin.jarry@6wind.com>, dev <dev@dpdk.org>,
	Bruce Richardson <bruce.richardson@intel.com>,
	Neil Horman <nhorman@tuxdriver.com>,
	Rosen Xu <rosen.xu@intel.com>,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
	Luca Boccassi <bluca@debian.org>
Subject: Re: [dpdk-dev] [PATCH] usertools: fix pmdinfo parsing
Date: Wed, 4 Nov 2020 09:04:05 +0100	[thread overview]
Message-ID: <20201104080405.GG1898@platinum> (raw)
In-Reply-To: <20201103155439.624bc17c@hermes.local>

On Tue, Nov 03, 2020 at 03:54:39PM -0800, Stephen Hemminger wrote:
> On Tue, 3 Nov 2020 21:20:43 +0100
> David Marchand <david.marchand@redhat.com> wrote:
> 
> > On Tue, Nov 3, 2020 at 8:27 PM Robin Jarry <robin.jarry@6wind.com> 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 <david.marchand@redhat.com>
> > > > ---
> > > >  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.

  reply	other threads:[~2020-11-04  8:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-03 18:39 David Marchand
2020-11-03 19:27 ` Robin Jarry
2020-11-03 20:20   ` David Marchand
2020-11-03 23:54     ` Stephen Hemminger
2020-11-04  8:04       ` Olivier Matz [this message]
2020-11-04  8:06     ` Robin Jarry
2020-11-04  9:40 ` [dpdk-dev] [PATCH v2] " David Marchand
2020-11-04 10:32   ` Bruce Richardson
2020-11-04 10:42     ` David Marchand
2020-11-05 11:46   ` Xu, Rosen
2020-11-12 13:28   ` David Marchand
2020-11-04 15:57 ` [dpdk-dev] [PATCH v3] " David Marchand
2020-11-04 16:35   ` Bruce Richardson
2020-11-04 16:48     ` David Marchand
2020-11-05 11:49       ` Bruce Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201104080405.GG1898@platinum \
    --to=olivier.matz@6wind.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=bluca@debian.org \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=nhorman@tuxdriver.com \
    --cc=robin.jarry@6wind.com \
    --cc=rosen.xu@intel.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).