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

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

 



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

Attachment: signature.asc
Description: OpenPGP digital signature

--
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]