Re: [PATCH 03/10] Use VIR_AUTODISPOSE_STR instead of VIR_DISPOSE_STRING where possible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
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@xxxxxxxxxx>

Jano

Attachment: signature.asc
Description: PGP signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux