From nobody Fri May 3 15:44:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 158067372976377.57711381512081; Sun, 2 Feb 2020 12:02:09 -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-80-dEc2mHIPOziDoc-3yjnbnA-1; Sun, 02 Feb 2020 15:02:06 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E665518FE863; Sun, 2 Feb 2020 20:02:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BD5468CCFC; Sun, 2 Feb 2020 20:02:00 +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 632C48173A; Sun, 2 Feb 2020 20:02:00 +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 012K1qPA003419 for ; Sun, 2 Feb 2020 15:01:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id D48A05D9E5; Sun, 2 Feb 2020 20:01:52 +0000 (UTC) Received: from icr.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D4475D9CA for ; Sun, 2 Feb 2020 20:01:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580673728; 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=Mx5rwb7bets35ntiXggbud4rk5nki9U/1O0hr+gxy7k=; b=ORQpyBrXTnw25IKQU7tx/aHahx2Jmd0e8AsNHmex9mOQItrvUaa4mcvSigjfP9LAHtX4mv MRkT5GLNmoOrJOX60tYDt7alpYFPX5cT0Ghv3KLY42d3/RXWRuxtIPXA/2pVaKg44P3G5l 33EwhNsBGI+IHHR2BnbFDX9T69SmeN0= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/4] qemu: tpm: remove unused pidfile variable Date: Sun, 2 Feb 2020 21:01:44 +0100 Message-Id: <6a37ae53e6c018ab981642c2ca0f5030e1ebf937.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.13 X-MC-Unique: dEc2mHIPOziDoc-3yjnbnA-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" qemuExtTPMSetupCgroup declares pidfile but never uses it. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/qemu/qemu_tpm.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 6741373583..385f4c74f7 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -913,7 +913,6 @@ qemuExtTPMSetupCgroup(virQEMUDriverPtr driver, virCgroupPtr cgroup) { virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); - char *pidfile =3D NULL; char *shortName =3D NULL; int ret =3D -1, rc; pid_t pid; @@ -940,7 +939,6 @@ qemuExtTPMSetupCgroup(virQEMUDriverPtr driver, ret =3D 0; =20 cleanup: - VIR_FREE(pidfile); VIR_FREE(shortName); virObjectUnref(cfg); =20 --=20 2.19.2 From nobody Fri May 3 15:44:48 2024 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 1580673736536110.60376408788886; Sun, 2 Feb 2020 12:02:16 -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-225-RoaLndWtM0qx_5w7dsBhcQ-1; Sun, 02 Feb 2020 15:02:11 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6B7BD105046A; Sun, 2 Feb 2020 20:02:05 +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 3FD825C3FD; Sun, 2 Feb 2020 20:02:05 +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 E264018089CE; Sun, 2 Feb 2020 20:02:04 +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 012K1rX9003424 for ; Sun, 2 Feb 2020 15:01:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id BEAA85D9E5; Sun, 2 Feb 2020 20:01:53 +0000 (UTC) Received: from icr.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DD7C5D9CA 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=1580673735; 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=kiO2Gi5CR7BRoPEJXpK+4xqkVPZIJuTrQyd5zKUbDfE=; b=BXF5HTS7jH5iGy29XbMXV8apUDxI77HDp9ShyWgXKKIHsZwdwrYkDF6GuAVh2llzDBeqnt 90ui3/RakTcl5cV+Plead5A+AI6XXaHxFhuVoEwirDS6ukGB4TSo1ASsP5vrulVpP594KW i/rGGhqKKUQKaeEfVqm6KXJP2igFxJI= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/4] qemu: tpm: use g_autofree Date: Sun, 2 Feb 2020 21:01:45 +0100 Message-Id: <67dbb235284237f6c56d5cf2cbe1eeb5c43ab7a6.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.16 X-MC-Unique: RoaLndWtM0qx_5w7dsBhcQ-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" Mark eligible declarations as g_autofree and remove the corresponding VIR_FREE calls. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/qemu/qemu_tpm.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 385f4c74f7..cfe7eb1846 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -126,7 +126,7 @@ qemuTPMCreateEmulatorStorage(const char *storagepath, gid_t swtpm_group) { int ret =3D -1; - char *swtpmStorageDir =3D g_path_get_dirname(storagepath); + g_autofree char *swtpmStorageDir =3D g_path_get_dirname(storagepath); =20 if (qemuTPMEmulatorInitStorage(swtpmStorageDir) < 0) goto cleanup; @@ -150,8 +150,6 @@ qemuTPMCreateEmulatorStorage(const char *storagepath, ret =3D 0; =20 cleanup: - VIR_FREE(swtpmStorageDir); - return ret; } =20 @@ -220,14 +218,12 @@ qemuTPMEmulatorCreatePidFilename(const char *swtpmSta= teDir, const char *shortName) { char *pidfile =3D NULL; - char *devicename =3D NULL; + g_autofree char *devicename =3D NULL; =20 devicename =3D g_strdup_printf("%s-swtpm", shortName); =20 pidfile =3D virPidFileBuildPath(swtpmStateDir, devicename); =20 - VIR_FREE(devicename); - return pidfile; } =20 @@ -433,7 +429,7 @@ qemuTPMEmulatorRunSetup(const char *storagepath, int exitstatus; int ret =3D -1; char uuid[VIR_UUID_STRING_BUFLEN]; - char *vmid =3D NULL; + g_autofree char *vmid =3D NULL; g_autofree char *swtpm_setup =3D virTPMGetSwtpmSetup(); VIR_AUTOCLOSE pwdfile_fd =3D -1; =20 @@ -516,7 +512,6 @@ qemuTPMEmulatorRunSetup(const char *storagepath, ret =3D 0; =20 cleanup: - VIR_FREE(vmid); virCommandFree(cmd); =20 return ret; @@ -554,7 +549,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDefPtr tpm, { virCommandPtr cmd =3D NULL; bool created =3D false; - char *pidfile; + g_autofree char *pidfile =3D NULL; g_autofree char *swtpm =3D virTPMGetSwtpm(); VIR_AUTOCLOSE pwdfile_fd =3D -1; VIR_AUTOCLOSE migpwdfile_fd =3D -1; @@ -615,7 +610,6 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDefPtr tpm, =20 virCommandAddArg(cmd, "--pid"); virCommandAddArgFormat(cmd, "file=3D%s", pidfile); - VIR_FREE(pidfile); =20 if (tpm->data.emulator.hassecretuuid) { if (!virTPMSwtpmCapsGet(VIR_TPM_SWTPM_FEATURE_CMDARG_PWD_FD)) { @@ -669,8 +663,8 @@ qemuTPMEmulatorStop(const char *swtpmStateDir, const char *shortName) { virCommandPtr cmd; - char *pathname; - char *errbuf =3D NULL; + g_autofree char *pathname =3D NULL; + g_autofree char *errbuf =3D NULL; g_autofree char *swtpm_ioctl =3D virTPMGetSwtpmIoctl(); =20 if (!swtpm_ioctl) @@ -701,8 +695,7 @@ qemuTPMEmulatorStop(const char *swtpmStateDir, unlink(pathname); =20 cleanup: - VIR_FREE(pathname); - VIR_FREE(errbuf); + return; } =20 =20 @@ -735,7 +728,7 @@ qemuExtTPMPrepareHost(virQEMUDriverPtr driver, { virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); int ret =3D 0; - char *shortName =3D NULL; + g_autofree char *shortName =3D NULL; =20 switch (def->tpm->type) { case VIR_DOMAIN_TPM_TYPE_EMULATOR: @@ -755,7 +748,6 @@ qemuExtTPMPrepareHost(virQEMUDriverPtr driver, } =20 cleanup: - VIR_FREE(shortName); virObjectUnref(cfg); =20 return ret; @@ -885,7 +877,7 @@ qemuExtTPMStop(virQEMUDriverPtr driver, virDomainObjPtr vm) { virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); - char *shortName =3D NULL; + g_autofree char *shortName =3D NULL; =20 switch (vm->def->tpm->type) { case VIR_DOMAIN_TPM_TYPE_EMULATOR: @@ -902,7 +894,6 @@ qemuExtTPMStop(virQEMUDriverPtr driver, } =20 cleanup: - VIR_FREE(shortName); virObjectUnref(cfg); } =20 @@ -913,7 +904,7 @@ qemuExtTPMSetupCgroup(virQEMUDriverPtr driver, virCgroupPtr cgroup) { virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); - char *shortName =3D NULL; + g_autofree char *shortName =3D NULL; int ret =3D -1, rc; pid_t pid; =20 @@ -939,7 +930,6 @@ qemuExtTPMSetupCgroup(virQEMUDriverPtr driver, ret =3D 0; =20 cleanup: - VIR_FREE(shortName); virObjectUnref(cfg); =20 return ret; --=20 2.19.2 From nobody Fri May 3 15:44:48 2024 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 Reviewed-by: Peter Krempa --- 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 From nobody Fri May 3 15:44:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1580673725328100.48053300508207; Sun, 2 Feb 2020 12:02:05 -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-302-bd574gQpNTq_s7vauIjLkA-1; Sun, 02 Feb 2020 15:02:01 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 546D08017CC; Sun, 2 Feb 2020 20:01:56 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2A39660BE1; Sun, 2 Feb 2020 20:01:56 +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 A4DF938A1; Sun, 2 Feb 2020 20:01:55 +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 012K1tMo003443 for ; Sun, 2 Feb 2020 15:01:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4718B5DA82; Sun, 2 Feb 2020 20:01:55 +0000 (UTC) Received: from icr.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C2D965D9CA for ; Sun, 2 Feb 2020 20:01:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580673724; 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=8sjFaQsJ3sR+k2U9mT+tLPDrP2bJGbeig9f3XTacB44=; b=an6Kx3S18R5e4p4yreAKv4IjA5YrRUpo7VsbVcTkLNWm7zTXXVZ8J2b9sBXUSKQkkPHsi4 4Maavcuzfcp2kCVRNQSlRnfXo1Q2uirLt+BU1RDF0+XCOpEkqwi39YvHEmJiJuDusglR5d 3W+HJPZkVMnZ39dj6YvdqJQWDXEJDeI= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 4/4] qemu: tpm: remove unused labels Date: Sun, 2 Feb 2020 21:01:47 +0100 Message-Id: <50ed0b35c02f65d39ab9dd739a136ff5c6ed71bc.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.12 X-MC-Unique: bd574gQpNTq_s7vauIjLkA-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" Remove all the labels that are now redundant. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/qemu/qemu_tpm.c | 74 +++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 47 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index f9cea2ffde..f3562d7dfe 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -125,11 +125,10 @@ qemuTPMCreateEmulatorStorage(const char *storagepath, uid_t swtpm_user, gid_t swtpm_group) { - int ret =3D -1; g_autofree char *swtpmStorageDir =3D g_path_get_dirname(storagepath); =20 if (qemuTPMEmulatorInitStorage(swtpmStorageDir) < 0) - goto cleanup; + return -1; =20 *created =3D false; =20 @@ -141,16 +140,13 @@ qemuTPMCreateEmulatorStorage(const char *storagepath, virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not create directory %s as %u:%d"), storagepath, swtpm_user, swtpm_group); - goto cleanup; + return -1; } =20 if (virFileChownFiles(storagepath, swtpm_user, swtpm_group) < 0) - goto cleanup; - - ret =3D 0; + return -1; =20 - cleanup: - return ret; + return 0; } =20 =20 @@ -427,7 +423,6 @@ qemuTPMEmulatorRunSetup(const char *storagepath, { g_autoptr(virCommand) cmd =3D NULL; int exitstatus; - int ret =3D -1; char uuid[VIR_UUID_STRING_BUFLEN]; g_autofree char *vmid =3D NULL; g_autofree char *swtpm_setup =3D virTPMGetSwtpmSetup(); @@ -444,7 +439,7 @@ qemuTPMEmulatorRunSetup(const char *storagepath, =20 cmd =3D virCommandNew(swtpm_setup); if (!cmd) - goto cleanup; + return -1; =20 virUUIDFormat(vmuuid, uuid); vmid =3D g_strdup_printf("%s:%s", vmname, uuid); @@ -469,10 +464,10 @@ qemuTPMEmulatorRunSetup(const char *storagepath, virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, _("%s does not support passing a passphrase using a file " "descriptor"), swtpm_setup); - goto cleanup; + return -1; } if ((pwdfile_fd =3D qemuTPMSetupEncryption(secretuuid, cmd)) < 0) - goto cleanup; + return -1; =20 virCommandAddArg(cmd, "--pwdfile-fd"); virCommandAddArgFormat(cmd, "%d", pwdfile_fd); @@ -506,13 +501,10 @@ qemuTPMEmulatorRunSetup(const char *storagepath, _("Could not run '%s'. exitstatus: %d; " "Check error log '%s' for details."), swtpm_setup, exitstatus, logfile); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -673,11 +665,11 @@ qemuTPMEmulatorStop(const char *swtpmStateDir, return; =20 if (!virFileExists(pathname)) - goto cleanup; + return; =20 cmd =3D virCommandNew(swtpm_ioctl); if (!cmd) - goto cleanup; + return; =20 virCommandAddArgList(cmd, "--unix", pathname, "-s", NULL); =20 @@ -689,9 +681,6 @@ qemuTPMEmulatorStop(const char *swtpmStateDir, =20 /* clean up the socket */ unlink(pathname); - - cleanup: - return; } =20 =20 @@ -700,19 +689,17 @@ qemuExtTPMInitPaths(virQEMUDriverPtr driver, virDomainDefPtr def) { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - int ret =3D 0; =20 switch (def->tpm->type) { case VIR_DOMAIN_TPM_TYPE_EMULATOR: - ret =3D qemuTPMEmulatorInitPaths(def->tpm, cfg->swtpmStorageDir, - def->uuid); - break; + return qemuTPMEmulatorInitPaths(def->tpm, cfg->swtpmStorageDir, + def->uuid); case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: case VIR_DOMAIN_TPM_TYPE_LAST: break; } =20 - return ret; + return 0; } =20 =20 @@ -721,28 +708,25 @@ qemuExtTPMPrepareHost(virQEMUDriverPtr driver, virDomainDefPtr def) { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - int ret =3D 0; g_autofree char *shortName =3D NULL; =20 switch (def->tpm->type) { case VIR_DOMAIN_TPM_TYPE_EMULATOR: shortName =3D virDomainDefGetShortName(def); if (!shortName) - goto cleanup; + return -1; =20 - ret =3D qemuTPMEmulatorPrepareHost(def->tpm, cfg->swtpmLogDir, - def->name, cfg->swtpm_user, - cfg->swtpm_group, - cfg->swtpmStateDir, cfg->user, - shortName); - break; + return qemuTPMEmulatorPrepareHost(def->tpm, cfg->swtpmLogDir, + def->name, cfg->swtpm_user, + cfg->swtpm_group, + cfg->swtpmStateDir, cfg->user, + shortName); case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: case VIR_DOMAIN_TPM_TYPE_LAST: break; } =20 - cleanup: - return ret; + return 0; } =20 =20 @@ -875,7 +859,7 @@ qemuExtTPMStop(virQEMUDriverPtr driver, case VIR_DOMAIN_TPM_TYPE_EMULATOR: shortName =3D virDomainDefGetShortName(vm->def); if (!shortName) - goto cleanup; + return; =20 qemuTPMEmulatorStop(cfg->swtpmStateDir, shortName); qemuSecurityCleanupTPMEmulator(driver, vm); @@ -885,7 +869,6 @@ qemuExtTPMStop(virQEMUDriverPtr driver, break; } =20 - cleanup: return; } =20 @@ -897,30 +880,27 @@ qemuExtTPMSetupCgroup(virQEMUDriverPtr driver, { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autofree char *shortName =3D NULL; - int ret =3D -1, rc; + int rc; pid_t pid; =20 switch (def->tpm->type) { case VIR_DOMAIN_TPM_TYPE_EMULATOR: shortName =3D virDomainDefGetShortName(def); if (!shortName) - goto cleanup; + return -1; rc =3D qemuTPMEmulatorGetPid(cfg->swtpmStateDir, shortName, &pid); if (rc < 0 || (rc =3D=3D 0 && pid =3D=3D (pid_t)-1)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not get process id of swtpm")); - goto cleanup; + return -1; } if (virCgroupAddProcess(cgroup, pid) < 0) - goto cleanup; + return -1; break; case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: case VIR_DOMAIN_TPM_TYPE_LAST: break; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } --=20 2.19.2