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

Cole Robinson crobinso at redhat.com
Thu Oct 17 13:04:05 UTC 2019


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.

- Cole




More information about the libvir-list mailing list