[PATCH] virQEMUCapsInitQMPArch: Refactor cleanup

Yi Li posted 1 patch 3 years, 2 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20210310074629.630859-1-yili@winhong.com
src/qemu/qemu_capabilities.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
[PATCH] virQEMUCapsInitQMPArch: Refactor cleanup
Posted by Yi Li 3 years, 2 months ago
Switch to using the 'g_auto*' helpers.

Signed-off-by: Yi Li <yili@winhong.com>
---
 src/qemu/qemu_capabilities.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 790375ac38..447cf77875 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -5044,23 +5044,18 @@ static int
 virQEMUCapsInitQMPArch(virQEMUCapsPtr qemuCaps,
                             qemuMonitorPtr mon)
 {
-    char *archstr = NULL;
-    int ret = -1;
+    g_autofree char *archstr = NULL;
 
     if (!(archstr = qemuMonitorGetTargetArch(mon)))
-        goto cleanup;
+        return -1;
 
     if ((qemuCaps->arch = virQEMUCapsArchFromString(archstr)) == VIR_ARCH_NONE) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Unknown QEMU arch %s"), archstr);
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
-
- cleanup:
-    VIR_FREE(archstr);
-    return ret;
+    return 0;
 }
 
 
-- 
2.25.3




Re: [PATCH] virQEMUCapsInitQMPArch: Refactor cleanup
Posted by Ján Tomko 3 years, 2 months ago
On a Wednesday in 2021, Yi Li wrote:
>Switch to using the 'g_auto*' helpers.
>
>Signed-off-by: Yi Li <yili@winhong.com>
>---
> src/qemu/qemu_capabilities.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano