[libvirt] [PATCH v2 12/37] Adapt to VIR_STRDUP in src/node_device/*

Eric Blake eblake at redhat.com
Mon Apr 29 20:08:19 UTC 2013


On 04/29/2013 12:51 PM, John Ferlan wrote:
> On 04/29/2013 09:50 AM, Michal Privoznik wrote:
>> ---
>>  src/node_device/node_device_driver.c |  28 ++++------
>>  src/node_device/node_device_hal.c    |  13 ++---
>>  src/node_device/node_device_udev.c   | 102 +++++++++++++++--------------------
>>  3 files changed, 60 insertions(+), 83 deletions(-)
>>
> ...
>> @@ -388,8 +385,7 @@ nodeDeviceListCaps(virNodeDevicePtr dev, char **const names, int maxnames)
>>      }
>>  
>>      for (caps = obj->def->caps; caps && ncaps < maxnames; caps = caps->next) {
>> -        names[ncaps] = strdup(virNodeDevCapTypeToString(caps->type));
>> -        if (names[ncaps++] == NULL) {
>> +        if (VIR_STRDUP(names[ncaps], virNodeDevCapTypeToString(caps->type)) < 0) {
> 
> Lost the autoincrement              ^^^

Except that you probably don't want an increment inside VIR_STRDUP,
since as an all-caps macro name, you aren't guaranteed that the
destination will be evaluated exactly once if we didn't document it that
way in virstring.h.  (Hmm, it looks like the implementation is actually
safe in evaluating exactly once, but we ought to make that part of the
contract.)

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130429/805f572b/attachment-0001.sig>


More information about the libvir-list mailing list