From nobody Mon Feb 9 00:42:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580673741654876.1407641250556; Sun, 2 Feb 2020 12:02:21 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-253-NkrV2D6HOpWCmgspXh15kw-1; Sun, 02 Feb 2020 15:02:18 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C8A1618FE860; Sun, 2 Feb 2020 20:02:12 +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 9C91D8642B; Sun, 2 Feb 2020 20:02:12 +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 5B3C718089D0; Sun, 2 Feb 2020 20:02:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 012K1svK003435 for ; Sun, 2 Feb 2020 15:01:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 762E15DA82; Sun, 2 Feb 2020 20:01:54 +0000 (UTC) Received: from icr.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id F228E5D9CA for ; Sun, 2 Feb 2020 20:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580673740; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=pP+Ulu4LEzdsxq3dD17fN9fYx055O9pQEsvtijAbHzw=; b=IAfBc8IN2pRxvGPZ9SgX05URE98FG+HudhbfW9ozMILk5Y9R/0aEXqNhkT+k4vnBAporNj SiaAr/ySf4eDCbeaL3ICTv6auPco+FVVP1XK023Vnh6rdCE/Dx8xx6Zy8mCQ4utXd9or/s Ar6NUPSbd9PXK3e4IWwcbeNz0LXuiis= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/4] qemu: tpm: use g_autoptr where applicable Date: Sun, 2 Feb 2020 21:01:46 +0100 Message-Id: <9685016153209ffdaeb2ce341302ea0fc4de0f77.1580673678.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: NkrV2D6HOpWCmgspXh15kw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This requires stealing one cmd pointer before returning it. Signed-off-by: J=C3=A1n Tomko --- src/qemu/qemu_tpm.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index cfe7eb1846..f9cea2ffde 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -425,7 +425,7 @@ qemuTPMEmulatorRunSetup(const char *storagepath, const unsigned char *secretuuid, bool incomingMigration) { - virCommandPtr cmd =3D NULL; + g_autoptr(virCommand) cmd =3D NULL; int exitstatus; int ret =3D -1; char uuid[VIR_UUID_STRING_BUFLEN]; @@ -512,8 +512,6 @@ qemuTPMEmulatorRunSetup(const char *storagepath, ret =3D 0; =20 cleanup: - virCommandFree(cmd); - return ret; } =20 @@ -547,7 +545,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDefPtr tpm, const char *shortName, bool incomingMigration) { - virCommandPtr cmd =3D NULL; + g_autoptr(virCommand) cmd =3D NULL; bool created =3D false; g_autofree char *pidfile =3D NULL; g_autofree char *swtpm =3D virTPMGetSwtpm(); @@ -639,14 +637,12 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDefPtr tpm, migpwdfile_fd =3D -1; } =20 - return cmd; + return g_steal_pointer(&cmd); =20 error: if (created) qemuTPMDeleteEmulatorStorage(tpm); =20 - virCommandFree(cmd); - return NULL; } =20 @@ -703,7 +699,7 @@ int qemuExtTPMInitPaths(virQEMUDriverPtr driver, virDomainDefPtr def) { - virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); int ret =3D 0; =20 switch (def->tpm->type) { @@ -716,8 +712,6 @@ qemuExtTPMInitPaths(virQEMUDriverPtr driver, break; } =20 - virObjectUnref(cfg); - return ret; } =20 @@ -726,7 +720,7 @@ int qemuExtTPMPrepareHost(virQEMUDriverPtr driver, virDomainDefPtr def) { - virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); int ret =3D 0; g_autofree char *shortName =3D NULL; =20 @@ -748,8 +742,6 @@ qemuExtTPMPrepareHost(virQEMUDriverPtr driver, } =20 cleanup: - virObjectUnref(cfg); - return ret; } =20 @@ -876,7 +868,7 @@ void qemuExtTPMStop(virQEMUDriverPtr driver, virDomainObjPtr vm) { - virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autofree char *shortName =3D NULL; =20 switch (vm->def->tpm->type) { @@ -894,7 +886,7 @@ qemuExtTPMStop(virQEMUDriverPtr driver, } =20 cleanup: - virObjectUnref(cfg); + return; } =20 =20 @@ -903,7 +895,7 @@ qemuExtTPMSetupCgroup(virQEMUDriverPtr driver, virDomainDefPtr def, virCgroupPtr cgroup) { - virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autofree char *shortName =3D NULL; int ret =3D -1, rc; pid_t pid; @@ -930,7 +922,5 @@ qemuExtTPMSetupCgroup(virQEMUDriverPtr driver, ret =3D 0; =20 cleanup: - virObjectUnref(cfg); - return ret; } --=20 2.19.2