[libvirt] [PATCH 03/10] Use VIR_AUTODISPOSE_STR instead of VIR_DISPOSE_STRING where possible
Ján Tomko
jtomko at redhat.com
Tue Apr 2 13:19:39 UTC 2019
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 at 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 at redhat.com>
Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190402/ecc8c4a6/attachment-0001.sig>
More information about the libvir-list
mailing list