Re: [PATCH] virAsprintf: correctly check return value

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

 



On 07/18/2013 12:58 PM, Peter Krempa wrote:
> On 07/18/13 12:37, Ján Tomko wrote:
>> When virAsprintf was changed from a function to a macro
>> reporting OOM error in dc6f2da, it was documented as returning
>> 0 on success. This is incorrect, it returns the number of bytes
>> written as asprintf does.
>>
>> Some of the functions were converted to use virAsprintf's return
>> value directly, changing the return value on success from 0 to >= 0.
>>
>> For most of these, this is not a problem, but the change in
>> virPCIDriverDir breaks PCI passthrough.
>>
>> The return value check in virhashtest pre-dates virAsprintf OOM
>> conversion.
>>
>> vmwareMakePath seems to be unused.
>> ---
>>   src/util/virstring.h     | 10 ++++++----
>>   src/util/virpci.c        | 26 ++++++++++++++++++--------
>>   tests/virhashtest.c      |  2 +-
>>
>>   src/qemu/qemu_command.c  | 13 ++++++++++---
>>   src/qemu/qemu_process.c  |  6 ++++--
>>   src/util/virnetdev.c     | 10 +++++++---
>>   src/util/virrandom.c     |  6 ++++--
>>   src/vmware/vmware_conf.c | 15 ++++++++++++---
>>   8 files changed, 62 insertions(+), 26 deletions(-)
>>
> 
>>
>>   /**
>> diff --git a/src/util/virrandom.c b/src/util/virrandom.c
>> index e2d18f8..c233732 100644
>> --- a/src/util/virrandom.c
>> +++ b/src/util/virrandom.c
>> @@ -178,6 +178,8 @@ virRandomGenerateWWN(char **wwn,
>>           return -1;
>>       }
>>
>> -    return virAsprintf(wwn, "5" "%s%09llx", oui,
> 
> Hmmm, interresting construction of strings.
> 
>> -                       (unsigned long long)virRandomBits(36));
>> +    if (virAsprintf(wwn, "5" "%s%09llx", oui,
>> +                    (unsigned long long)virRandomBits(36)) < 0)
>> +        return -1;
>> +    return 0;
>>   }
> 
> ACK.
> 
> Peter
> 

Thanks, pushed now.

Jan

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