[PATCH 02/13] remote: dispatch: Don't use virStringListFreeCount for NULL terminated lists

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

 



Both virDomainAuthorizedSSHKeysGet and virDomainGetMessages return a
NULL-terminated string-list, so we can use g_auto(GStrv) to clear the
used memory on failures.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/remote/remote_daemon_dispatch.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index 99ae25c5f7..d43306d4c9 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -7253,7 +7253,7 @@ remoteDispatchDomainAuthorizedSshKeysGet(virNetServer *server G_GNUC_UNUSED,
     int rv = -1;
     virConnectPtr conn = remoteGetHypervisorConn(client);
     int nkeys = 0;
-    char **keys = NULL;
+    g_auto(GStrv) keys = NULL;
     virDomainPtr dom = NULL;

     if (!conn)
@@ -7281,8 +7281,6 @@ remoteDispatchDomainAuthorizedSshKeysGet(virNetServer *server G_GNUC_UNUSED,
  cleanup:
     if (rv < 0)
         virNetMessageSaveError(rerr);
-    if (nkeys > 0)
-        virStringListFreeCount(keys, nkeys);
     virObjectUnref(dom);

     return rv;
@@ -7335,7 +7333,7 @@ remoteDispatchDomainGetMessages(virNetServer *server G_GNUC_UNUSED,
     int rv = -1;
     virConnectPtr conn = remoteGetHypervisorConn(client);
     int nmsgs = 0;
-    char **msgs = NULL;
+    g_auto(GStrv) msgs = NULL;
     virDomainPtr dom = NULL;

     if (!conn)
@@ -7362,8 +7360,6 @@ remoteDispatchDomainGetMessages(virNetServer *server G_GNUC_UNUSED,
  cleanup:
     if (rv < 0)
         virNetMessageSaveError(rerr);
-    if (nmsgs > 0)
-        virStringListFreeCount(msgs, nmsgs);
     virObjectUnref(dom);

     return rv;
-- 
2.31.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