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 <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
Laine Stump 2021-02-03 21:12:21 -05:00
parent f772c48697
commit 0c7674d027

View 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);