From nobody Mon Feb 9 14:16:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554123938305515.240436944249; Mon, 1 Apr 2019 06:05:38 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D356486668; Mon, 1 Apr 2019 13:05:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A5D301001DD1; Mon, 1 Apr 2019 13:05:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5FA29180338B; Mon, 1 Apr 2019 13:05:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x31D5ENO016017 for ; Mon, 1 Apr 2019 09:05:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8396B1001DD1; Mon, 1 Apr 2019 13:05:14 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03B711001E65 for ; Mon, 1 Apr 2019 13:05:13 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 1 Apr 2019 15:04:54 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/10] Use VIR_AUTODISPOSE_STR instead of VIR_DISPOSE_STRING where possible X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 01 Apr 2019 13:05:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Refactor code paths which clear strings on cleanup paths to use the automatic helper. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- 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/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index e55a9fe22e..0c7a5f3dd5 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -980,7 +980,7 @@ libxlMakeNetworkDiskSrc(virStorageSourcePtr src, char *= *srcstr) { virConnectPtr conn =3D NULL; uint8_t *secret =3D NULL; - char *base64secret =3D NULL; + VIR_AUTODISPOSE_STR base64secret =3D NULL; size_t secretlen =3D 0; char *username =3D NULL; int ret =3D -1; @@ -1008,7 +1008,6 @@ libxlMakeNetworkDiskSrc(virStorageSourcePtr src, char= **srcstr) cleanup: VIR_DISPOSE_N(secret, secretlen); - VIR_DISPOSE_STRING(base64secret); virObjectUnref(conn); return ret; } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f81d20e5f7..98d67dab2c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -842,7 +842,7 @@ static int qemuBuildRBDSecinfoURI(virBufferPtr buf, qemuDomainSecretInfoPtr secinfo) { - char *base64secret =3D NULL; + VIR_AUTODISPOSE_STR base64secret =3D NULL; if (!secinfo) { virBufferAddLit(buf, ":auth_supported=3Dnone"); @@ -858,7 +858,6 @@ qemuBuildRBDSecinfoURI(virBufferPtr buf, virBufferEscape(buf, '\\', ":", ":key=3D%s:auth_supported=3Dcephx\\;none", base64secret); - VIR_DISPOSE_STRING(base64secret); break; case VIR_DOMAIN_SECRET_INFO_TYPE_AES: 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 =3D NULL; + VIR_AUTODISPOSE_STR password =3D NULL; const char *errmsg; int ret =3D -1; @@ -657,10 +657,7 @@ virNetLibsshAuthenticatePassword(virNetLibsshSessionPt= r sess, virReportError(VIR_ERR_AUTH_FAILED, _("authentication failed: %s"), errmsg); - return ret; - cleanup: - VIR_DISPOSE_STRING(password); return ret; } @@ -1052,7 +1049,7 @@ virNetLibsshSessionAuthAddPrivKeyAuth(virNetLibsshSes= sionPtr sess, { int ret; virNetLibsshAuthMethodPtr auth; - char *pass =3D NULL; + VIR_AUTODISPOSE_STR pass =3D NULL; char *file =3D NULL; if (!keyfile) { @@ -1076,7 +1073,7 @@ virNetLibsshSessionAuthAddPrivKeyAuth(virNetLibsshSes= sionPtr sess, goto error; } - auth->password =3D pass; + VIR_STEAL_PTR(auth->password, pass); auth->filename =3D file; auth->method =3D VIR_NET_LIBSSH_AUTH_PRIVKEY; auth->ssh_flags =3D SSH_AUTH_METHOD_PUBLICKEY; @@ -1088,7 +1085,6 @@ virNetLibsshSessionAuthAddPrivKeyAuth(virNetLibsshSes= sionPtr sess, return ret; error: - VIR_DISPOSE_STRING(pass); VIR_FREE(file); goto cleanup; } diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index 61ebb9b541..29f6a5de60 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -209,7 +209,7 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDS= tatePtr ptr, virStorageAuthDefPtr authdef =3D source->auth; unsigned char *secret_value =3D NULL; size_t secret_value_size =3D 0; - char *rados_key =3D NULL; + VIR_AUTODISPOSE_STR rados_key =3D NULL; virBuffer mon_host =3D VIR_BUFFER_INITIALIZER; size_t i; const char *client_mount_timeout =3D "30"; @@ -343,7 +343,6 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDS= tatePtr ptr, cleanup: VIR_DISPOSE_N(secret_value, secret_value_size); - VIR_DISPOSE_STRING(rados_key); virObjectUnref(conn); virBufferFreeAndReset(&mon_host); diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index 9227fd064c..b9fc5ededf 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -253,7 +253,7 @@ static bool cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd) { virSecretPtr secret; - char *base64 =3D NULL; + VIR_AUTODISPOSE_STR base64 =3D NULL; unsigned char *value; size_t value_size; bool ret =3D false; @@ -274,7 +274,6 @@ cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd) cleanup: VIR_DISPOSE_N(value, value_size); - VIR_DISPOSE_STRING(base64); virSecretFree(secret); return ret; } --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list