[libvirt PATCH 3/6] vz: refactor testURIParse

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use g_autofree for the two strings still using manual cleanup
and remove the pointless cleanup label.

Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 src/vz/vz_sdk.c | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 5ea3f29a8f..ecf610d7db 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -1130,26 +1130,25 @@ prlsdkGetSerialInfo(PRL_HANDLE serialPort, virDomainChrDef *chr)
     PRL_RESULT pret;
     PRL_UINT32 serialPortIndex;
     PRL_UINT32 emulatedType;
-    char *friendlyName = NULL;
+    g_autofree char *friendlyName = NULL;
     PRL_SERIAL_PORT_SOCKET_OPERATION_MODE socket_mode;
-    char *uristr = NULL;
+    g_autofree char *uristr = NULL;
     g_autoptr(virURI) uri = NULL;
-    int ret = -1;
 
     chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
     pret = PrlVmDev_GetIndex(serialPort, &serialPortIndex);
-    prlsdkCheckRetGoto(pret, cleanup);
+    prlsdkCheckRetExit(pret, -1);
     chr->target.port = serialPortIndex;
 
     pret = PrlVmDev_GetEmulatedType(serialPort, &emulatedType);
-    prlsdkCheckRetGoto(pret, cleanup);
+    prlsdkCheckRetExit(pret, -1);
 
     if (!(friendlyName = prlsdkGetStringParamVar(PrlVmDev_GetFriendlyName,
                                                  serialPort)))
-        goto cleanup;
+        return -1;
 
     pret = PrlVmDevSerial_GetSocketMode(serialPort, &socket_mode);
-    prlsdkCheckRetGoto(pret, cleanup);
+    prlsdkCheckRetExit(pret, -1);
 
     switch (emulatedType) {
     case PDT_USE_OUTPUT_FILE:
@@ -1169,7 +1168,7 @@ prlsdkGetSerialInfo(PRL_HANDLE serialPort, virDomainChrDef *chr)
         chr->source->type = VIR_DOMAIN_CHR_TYPE_TCP;
         uristr = g_strdup_printf("tcp://%s", friendlyName);
         if (!(uri = virURIParse(uristr)))
-            goto cleanup;
+            return -1;
         chr->source->data.tcp.host = g_strdup(uri->server);
         chr->source->data.tcp.service = g_strdup_printf("%d", uri->port);
         chr->source->data.tcp.listen = socket_mode == PSP_SERIAL_SOCKET_SERVER;
@@ -1178,7 +1177,7 @@ prlsdkGetSerialInfo(PRL_HANDLE serialPort, virDomainChrDef *chr)
         chr->source->type = VIR_DOMAIN_CHR_TYPE_UDP;
         uristr = g_strdup_printf("udp://%s", friendlyName);
         if (!(uri = virURIParse(uristr)))
-            goto cleanup;
+            return -1;
         chr->source->data.udp.bindHost = g_strdup(uri->server);
         chr->source->data.udp.bindService = g_strdup_printf("%d", uri->port);
         chr->source->data.udp.connectHost = g_strdup(uri->server);
@@ -1187,17 +1186,10 @@ prlsdkGetSerialInfo(PRL_HANDLE serialPort, virDomainChrDef *chr)
     default:
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Unknown serial type: %X"), emulatedType);
-        goto cleanup;
-        break;
+        return -1;
     }
 
-    ret = 0;
-
- cleanup:
-    VIR_FREE(friendlyName);
-    VIR_FREE(uristr);
-
-    return ret;
+    return 0;
 }
 
 
-- 
2.34.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux