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

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

 



2010/3/31 Eric Blake <eblake@xxxxxxxxxx>:
> 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...
>

Good idea, but I think the name STPCMP is confusing. I misread it as
STRCMP at first.

Maybe STRPREFIXSKIP or STRPFXSKIP are better names.

Matthias

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]