[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 10/10] Replace sscanf in PCI device address parsing



On Wed, Mar 31, 2010 at 10:48:47AM -0600, Eric Blake wrote:
> On 03/31/2010 10:38 AM, Eric Blake wrote:
> > Hmm, thinking aloud here: your patch series has introduced several
> > instances of checking STRPREFIX, then advancing to the end of the
> > prefix.  Maybe it's time to introduce a helper macro that does both the
> > check and advances the pointer to the end of the match?  Something like:
> > 
> > #define STPCMP(ptr, cmp) \
> >   (STRPREFIX (*(ptr), cmp) ? (ptr) += strlen (cmp) : NULL)
> > 
> > STPCMP(&tmp, " : ");
> > if (tmp == NULL)
> >     error...
> > else
> >     use tmp...
> 
> More thinking aloud - that looks a bit confusing compared to other stp*
> interfaces.  Maybe:
> 
> #define STPCMP(str, cmp) \
>     (STRPREFIX (str, cmp) ? (str) + strlen (cmp) : NULL)
> if ((tmp = STPCMP(tmp, " : ") == NULL)
>     error...
> else
>     use tmp...

I think the name is a little unclear here - I wouldn't be expecting
something named 'CMP' it to modify the argument. How about calling it
STR_ADVANCE or STR_SKIP


Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]