[libvirt] [PATCHv2 2/2] sysinfo: convert to virCommand

Eric Blake eblake at redhat.com
Mon Dec 13 23:29:16 UTC 2010


On 12/13/2010 04:10 PM, Matthias Bolte wrote:
> 2010/12/7 Eric Blake <eblake at redhat.com>:
>> * src/util/sysinfo.c (virSysinfoRead): Use virCommand instead of
>> virExec.
>> ---
>> v2: remove unused variable, rebase on top of whitespace cleanups.

>>     path = virFindFileInPath(SYSINFO_SMBIOS_DECODER);
>>     if (path == NULL) {

allocated...

>> @@ -108,43 +106,13 @@ virSysinfoRead(void) {
>>                              SYSINFO_SMBIOS_DECODER);
>>         return NULL;
>>     }
>> -    argv[0] = path;

the old code freed it as part of argv cleanups

>>
>> -    res = virExec(argv, NULL, NULL, &pid, -1, &outfd, &errfd,
>> -                  VIR_EXEC_NONE | VIR_EXEC_NONBLOCK);
>> -    if (res < 0) {
>> +    cmd = virCommandNewArgList(path, "-q", "-t", "0,1", NULL);

oh, you're right - the new code strdup's it, so I did leak it.

>>  cleanup:
>>     VIR_FREE(outbuf);
>> -    VIR_FREE(errbuf);
>> -    VIR_FREE(path);
>> +    virCommandFree(cmd);
> 
> Why not free path anymore, doesn't it leak now?
> 
> ACK, with that possible leak addressed.

I've restored the VIR_FREE(path).

Thanks for the review, and pushed.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


More information about the libvir-list mailing list