]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
rpc: eliminate static function virNetLibsshSessionAuthMethodsFree()
authorLaine Stump <laine@redhat.com>
Thu, 4 Feb 2021 02:12:21 +0000 (21:12 -0500)
committerLaine Stump <laine@redhat.com>
Fri, 5 Feb 2021 05:22:09 +0000 (00:22 -0500)
This function is only called from one place, and has, well... not a
*misleading* name, but it doesn't fit the standard frame of functions
that end in "Free" (it doesn't actually free the object pointed to by
its argument, but frees *some parts* of the content of the object).

Rather than try to think up an appropriate name, let's just move the
meat of this function into its one and only caller,
virNetLibsshSessionDispose(), which will allow us to convert its
VIR_FREEs into g_free in a future patch.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/rpc/virnetlibsshsession.c

index 76934c7c0b2fa1abe99cd3af3dbfe00f48ca6475..48ef914c700c8563f041cfad16fead9ba4ca1716 100644 (file)
@@ -108,26 +108,12 @@ struct _virNetLibsshSession {
     size_t bufStart;
 };
 
-static void
-virNetLibsshSessionAuthMethodsFree(virNetLibsshSessionPtr sess)
-{
-    size_t i;
-
-    for (i = 0; i < sess->nauths; i++) {
-        virSecureEraseString(sess->auths[i]->password);
-        g_free(sess->auths[i]->password);
-        VIR_FREE(sess->auths[i]->filename);
-        VIR_FREE(sess->auths[i]);
-    }
-
-    VIR_FREE(sess->auths);
-    sess->nauths = 0;
-}
-
 static void
 virNetLibsshSessionDispose(void *obj)
 {
     virNetLibsshSessionPtr sess = obj;
+    size_t i;
+
     VIR_DEBUG("sess=0x%p", sess);
 
     if (!sess)
@@ -144,7 +130,14 @@ virNetLibsshSessionDispose(void *obj)
         ssh_free(sess->session);
     }
 
-    virNetLibsshSessionAuthMethodsFree(sess);
+    for (i = 0; i < sess->nauths; i++) {
+        virSecureEraseString(sess->auths[i]->password);
+        VIR_FREE(sess->auths[i]->password);
+        VIR_FREE(sess->auths[i]->filename);
+        VIR_FREE(sess->auths[i]);
+    }
+
+    VIR_FREE(sess->auths);
 
     VIR_FREE(sess->channelCommand);
     VIR_FREE(sess->hostname);