Re: [PATCH 41/42] admin: Use g_autofree on getSocketPath()

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

 



On 12/19/19 8:33 PM, Ján Tomko wrote:
> On Thu, Dec 19, 2019 at 05:22:32PM +0100, Fabiano Fidêncio wrote:
>> On Thu, Dec 19, 2019 at 5:14 PM Pavel Hrdina <phrdina@xxxxxxxxxx> wrote:
>>>
>>> On Thu, Dec 19, 2019 at 11:04:46AM +0100, Fabiano Fidêncio wrote:
>>> > Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
>>> > ---
>>> >  src/admin/libvirt-admin.c | 3 +--
>>> >  1 file changed, 1 insertion(+), 2 deletions(-)
>>>
>>> s/on/in/ $SUBJECT?
>>>
>>> This might be the case for other patches as well.
>>
>> Noted.
>>
>>>
>>> One note, I would say it's ok to squash some of the patches from this
>>> series together, for example all the g_autofree patches per file for
>>> example.
>>
>> I really thought about that. However, it may be misleading as I'm not
>> touching all the possible conversions to use g_autofree in the other
>> functions.
> 
> Well this case is also misleading, since you aren't touching all the
> possible g_autofree conversions in this functions


ACK if you squash this in:

diff --git i/src/admin/libvirt-admin.c w/src/admin/libvirt-admin.c
index dcbb8ca84d..4099a54854 100644
--- i/src/admin/libvirt-admin.c
+++ w/src/admin/libvirt-admin.c
@@ -100,11 +100,11 @@ static char *
 getSocketPath(virURIPtr uri)
 {
     g_autofree char *rundir = virGetUserRuntimeDirectory();
-    char *sock_path = NULL;
+    g_autofree char *sock_path = NULL;
     size_t i = 0;

     if (!uri)
-        goto cleanup;
+        return NULL;


     for (i = 0; i < uri->paramsCount; i++) {
@@ -116,7 +116,7 @@ getSocketPath(virURIPtr uri)
         } else {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("Unknown URI parameter '%s'"), param->name);
-            goto error;
+            return NULL;
         }
     }

@@ -127,7 +127,7 @@ getSocketPath(virURIPtr uri)
         if (!uri->scheme) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            "%s", _("No URI scheme specified"));
-            goto error;
+            return NULL;
         }
         if (STREQ(uri->scheme, "libvirtd")) {
             legacy = true;
@@ -135,7 +135,7 @@ getSocketPath(virURIPtr uri)
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("Unsupported URI scheme '%s'"),
                            uri->scheme);
-            goto error;
+            return NULL;
         }

         if (legacy) {
@@ -152,16 +152,11 @@ getSocketPath(virURIPtr uri)
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("Invalid URI path '%s', try '/system'"),
                            NULLSTR_EMPTY(uri->path));
-            goto error;
+            return NULL;
         }
     }

- cleanup:
-    return sock_path;
-
- error:
-    VIR_FREE(sock_path);
-    goto cleanup;
+    return g_steal_pointer(&sock_path);
 }


Michal

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list





[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