On Mon, Apr 01, 2019 at 03:04:54PM +0200, Peter Krempa wrote:
Refactor code paths which clear strings on cleanup paths to use the
automatic helper.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/libxl/libxl_conf.c | 3 +--
src/qemu/qemu_command.c | 3 +--
src/rpc/virnetlibsshsession.c | 10 +++-------
src/storage/storage_backend_rbd.c | 3 +--
tools/virsh-secret.c | 3 +--
5 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c
index e851e40d48..832d4fd87d 100644
--- a/src/rpc/virnetlibsshsession.c
+++ b/src/rpc/virnetlibsshsession.c
@@ -605,7 +605,7 @@ static int
virNetLibsshAuthenticatePassword(virNetLibsshSessionPtr sess,
virNetLibsshAuthMethodPtr priv)
{
- char *password = NULL;
+ VIR_AUTODISPOSE_STR password = NULL;
const char *errmsg;
int ret = -1;
@@ -657,10 +657,7 @@ virNetLibsshAuthenticatePassword(virNetLibsshSessionPtr sess,
Here you can move the declaration iside the while(true) cycle to get rid
of the remaining VIR_DISPOSE_STRING
virReportError(VIR_ERR_AUTH_FAILED,
_("authentication failed: %s"), errmsg);
- return ret;
-
cleanup:
- VIR_DISPOSE_STRING(password);
return ret;
Also, you can get rid of the cleanup label in a followup patch.
}
Reviewed-by: Ján Tomko <jtomko(a)redhat.com>
Jano