On 7/15/20 8:10 AM, Peter Krempa wrote:
We can return the formatted string directly. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_domain.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 3d136a6b8a..cfdd9270da 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11517,14 +11517,10 @@ char * qemuDomainDiskBackingStoreGetName(virDomainDiskDefPtr disk, unsigned int idx) { - char *ret = NULL; - if (idx) - ret = g_strdup_printf("%s[%d]", disk->dst, idx); + return g_strdup_printf("%s[%d]", disk->dst, idx); else - ret = g_strdup(disk->dst); - - return ret; + return g_strdup(disk->dst);
You could even get rid of the 'else', and less indentation on this line. Whichever way is fine.
Reviewed-by: Eric Blake <eblake@xxxxxxxxxx> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org