From 0c7674d027ce5dfdb0f7e65c4d0c7bba91bfe266 Mon Sep 17 00:00:00 2001 From: Laine Stump Date: Wed, 3 Feb 2021 21:12:21 -0500 Subject: [PATCH] rpc: eliminate static function virNetLibsshSessionAuthMethodsFree() 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 Reviewed-by: Daniel Henrique Barboza --- src/rpc/virnetlibsshsession.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c index 76934c7c0b..48ef914c70 100644 --- a/src/rpc/virnetlibsshsession.c +++ b/src/rpc/virnetlibsshsession.c @@ -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); -- 2.47.2