[libvirt] [PATCH v4 5/5] qemu_driver: use g_strdup_printf

Daniel Henrique Barboza danielhb413 at gmail.com
Thu Oct 17 13:11:37 UTC 2019



On 10/17/19 10:04 AM, Cole Robinson wrote:
> On 10/16/19 4:54 PM, Daniel Henrique Barboza wrote:
>> This patch changes all virAsprintf calls to use the GLib API
>> g_strdup_printf in qemu_driver.c
>>
>> Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
>> ---
>>   src/qemu/qemu_driver.c | 38 +++++++++++++++++---------------------
>>   1 file changed, 17 insertions(+), 21 deletions(-)
>>
>> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
>> index a263393626..c9b3ed877f 100644
>> --- a/src/qemu/qemu_driver.c
>> +++ b/src/qemu/qemu_driver.c
>> @@ -402,7 +402,7 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm,
>>   
>>       priv = vm->privateData;
>>   
>> -    if (virAsprintf(&snapDir, "%s/%s", baseDir, vm->def->name) < 0) {
>> +    if (!(snapDir = g_strdup_printf("%s/%s", baseDir, vm->def->name))) {
>>           virReportError(VIR_ERR_INTERNAL_ERROR,
>>                          _("Failed to allocate memory for "
>>                          "snapshot directory for domain %s"),
>> @@ -427,7 +427,7 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm,
>>              kill the whole process */
>>           VIR_INFO("Loading snapshot file '%s'", entry->d_name);
>>   
> No objection to this patch specifically, but if g_strdup_printf is a
> drop in replacement for virAsprintf, I think conversion should be done
> in a mass change-the-world series like Jano has done for other pieces.

Fair enough. Sadly I've just sent another series in which I did the same
thing for qemu_process.c :|


DHB

>
> - Cole




More information about the libvir-list mailing list