From nobody Sat May 4 19:32:48 2024 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 1548078992881558.4955818070258; Mon, 21 Jan 2019 05:56:32 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8AE02C0495BF; Mon, 21 Jan 2019 13:56:30 +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 5066B60123; Mon, 21 Jan 2019 13:56:30 +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 F38F141FB9; Mon, 21 Jan 2019 13:56:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0LDuN4D011786 for ; Mon, 21 Jan 2019 08:56:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id A27645D757; Mon, 21 Jan 2019 13:56:23 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 281A65D736 for ; Mon, 21 Jan 2019 13:56:22 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Mon, 21 Jan 2019 14:56:14 +0100 Message-Id: <8306008298009601e676fdba6b5d708235160344.1548078934.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/4] virQEMUDriverConfigLoadProcessEntry: use VIR_AUTOFREE 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 21 Jan 2019 13:56:31 +0000 (UTC) Switch the function to use VIR_AUTOFREE and VIR_AUTOPTR macros to get rid of the cleanup section. Requested-by: John Ferlan Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/qemu/qemu_conf.c | 45 +++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 256aad2c0b..fc7101904e 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -642,15 +642,14 @@ static int virQEMUDriverConfigLoadProcessEntry(virQEMUDriverConfigPtr cfg, virConfPtr conf) { - char *stdioHandler =3D NULL; - char **hugetlbfs =3D NULL; - char *corestr =3D NULL; - int ret =3D -1; + VIR_AUTOFREE(char *) stdioHandler =3D NULL; + VIR_AUTOPTR(virString) hugetlbfs =3D NULL; + VIR_AUTOFREE(char *) corestr =3D NULL; size_t i; =20 if (virConfGetValueStringList(conf, "hugetlbfs_mount", true, &hugetlbfs) < 0) - goto cleanup; + return -1; if (hugetlbfs) { /* There already might be something autodetected. Avoid leaking it= . */ while (cfg->nhugetlbfs) { @@ -662,49 +661,49 @@ virQEMUDriverConfigLoadProcessEntry(virQEMUDriverConf= igPtr cfg, cfg->nhugetlbfs =3D virStringListLength((const char *const *)huget= lbfs); if (hugetlbfs[0] && VIR_ALLOC_N(cfg->hugetlbfs, cfg->nhugetlbfs) < 0) - goto cleanup; + return -1; =20 for (i =3D 0; hugetlbfs[i] !=3D NULL; i++) { if (virQEMUDriverConfigHugeTLBFSInit(&cfg->hugetlbfs[i], hugetlbfs[i], i !=3D 0) <= 0) - goto cleanup; + return -1; } } =20 if (virConfGetValueBool(conf, "clear_emulator_capabilities", &cfg->cle= arEmulatorCapabilities) < 0) - goto cleanup; + return -1; if (virConfGetValueString(conf, "bridge_helper", &cfg->bridgeHelperNam= e) < 0) - goto cleanup; + return -1; =20 if (virConfGetValueString(conf, "pr_helper", &cfg->prHelperName) < 0) - goto cleanup; + return -1; =20 if (virConfGetValueBool(conf, "set_process_name", &cfg->setProcessName= ) < 0) - goto cleanup; + return -1; if (virConfGetValueUInt(conf, "max_processes", &cfg->maxProcesses) < 0) - goto cleanup; + return -1; if (virConfGetValueUInt(conf, "max_files", &cfg->maxFiles) < 0) - goto cleanup; + return -1; =20 if (virConfGetValueType(conf, "max_core") =3D=3D VIR_CONF_STRING) { if (virConfGetValueString(conf, "max_core", &corestr) < 0) - goto cleanup; + return -1; if (STREQ(corestr, "unlimited")) { cfg->maxCore =3D ULLONG_MAX; } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unknown core size '%s'"), corestr); - goto cleanup; + return -1; } } else if (virConfGetValueULLong(conf, "max_core", &cfg->maxCore) < 0)= { - goto cleanup; + return -1; } =20 if (virConfGetValueBool(conf, "dump_guest_core", &cfg->dumpGuestCore) = < 0) - goto cleanup; + return -1; if (virConfGetValueString(conf, "stdio_handler", &stdioHandler) < 0) - goto cleanup; + return -1; if (stdioHandler) { if (STREQ(stdioHandler, "logd")) { cfg->stdioLogD =3D true; @@ -714,17 +713,11 @@ virQEMUDriverConfigLoadProcessEntry(virQEMUDriverConf= igPtr cfg, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unknown stdio handler %s"), stdioHandler); - VIR_FREE(stdioHandler); - goto cleanup; + return -1; } - VIR_FREE(stdioHandler); } =20 - ret =3D 0; - cleanup: - virStringListFree(hugetlbfs); - VIR_FREE(corestr); - return ret; + return 0; } =20 =20 --=20 2.16.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 19:32:48 2024 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 1548078998290832.1013140872983; Mon, 21 Jan 2019 05:56:38 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 83F2080F8D; Mon, 21 Jan 2019 13:56:35 +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 49A6E60F97; Mon, 21 Jan 2019 13:56:35 +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 EF4B64EA3B; Mon, 21 Jan 2019 13:56:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0LDuOZR011797 for ; Mon, 21 Jan 2019 08:56:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 769215D6AA; Mon, 21 Jan 2019 13:56:24 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE9BD5D757 for ; Mon, 21 Jan 2019 13:56:23 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Mon, 21 Jan 2019 14:56:15 +0100 Message-Id: <05e0154e144f31e94fed94213ea73d559cbfa245.1548078934.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/4] virQEMUDriverConfigLoadNVRAMEntry: use VIR_AUTOFREE 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 21 Jan 2019 13:56:37 +0000 (UTC) Switch the function to use VIR_AUTOFREE and VIR_AUTOPTR macros to get rid of the cleanup section. Requested-by: John Ferlan Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/qemu/qemu_conf.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index fc7101904e..04061b0135 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -829,31 +829,27 @@ static int virQEMUDriverConfigLoadNVRAMEntry(virQEMUDriverConfigPtr cfg, virConfPtr conf) { - char **nvram =3D NULL; - int ret =3D -1; + VIR_AUTOPTR(virString) nvram =3D NULL; size_t i; =20 if (virConfGetValueStringList(conf, "nvram", false, &nvram) < 0) - goto cleanup; + return -1; if (nvram) { virFirmwareFreeList(cfg->firmwares, cfg->nfirmwares); =20 cfg->nfirmwares =3D virStringListLength((const char *const *)nvram= ); if (nvram[0] && VIR_ALLOC_N(cfg->firmwares, cfg->nfirmwares) < 0) - goto cleanup; + return -1; =20 for (i =3D 0; nvram[i] !=3D NULL; i++) { if (VIR_ALLOC(cfg->firmwares[i]) < 0) - goto cleanup; + return -1; if (virFirmwareParse(nvram[i], cfg->firmwares[i]) < 0) - goto cleanup; + return -1; } } =20 - ret =3D 0; - cleanup: - virStringListFree(nvram); - return ret; + return 0; } =20 =20 --=20 2.16.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 19:32:48 2024 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 1548078989886149.83809246056398; Mon, 21 Jan 2019 05:56:29 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AC77119CF24; Mon, 21 Jan 2019 13:56:27 +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 728D31992A; Mon, 21 Jan 2019 13:56:27 +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 24C7041FB9; Mon, 21 Jan 2019 13:56:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0LDuPJB011806 for ; Mon, 21 Jan 2019 08:56:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 484CE5D739; Mon, 21 Jan 2019 13:56:25 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C35525D736 for ; Mon, 21 Jan 2019 13:56:24 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Mon, 21 Jan 2019 14:56:16 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/4] virQEMUDriverConfigLoadSecurityEntry: use VIR_AUTOFREE 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-Type: text/plain; charset="utf-8" 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 21 Jan 2019 13:56:28 +0000 (UTC) Switch the function to use VIR_AUTOFREE and VIR_AUTOPTR macros to get rid of the cleanup section. Requested-by: John Ferlan Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/qemu/qemu_conf.c | 52 +++++++++++++++++++++++-------------------------= ---- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 04061b0135..524e5d4d0f 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -866,14 +866,14 @@ virQEMUDriverConfigLoadSecurityEntry(virQEMUDriverCon= figPtr cfg, virConfPtr conf, bool privileged) { - char *user =3D NULL, *group =3D NULL; - char **controllers =3D NULL; - char **namespaces =3D NULL; - int ret =3D -1; + VIR_AUTOPTR(virString) controllers =3D NULL; + VIR_AUTOPTR(virString) namespaces =3D NULL; + VIR_AUTOFREE(char *) user =3D NULL; + VIR_AUTOFREE(char *) group =3D NULL; size_t i, j; =20 if (virConfGetValueStringList(conf, "security_driver", true, &cfg->sec= urityDriverNames) < 0) - goto cleanup; + return -1; =20 for (i =3D 0; cfg->securityDriverNames && cfg->securityDriverNames[i] = !=3D NULL; i++) { for (j =3D i + 1; cfg->securityDriverNames[j] !=3D NULL; j++) { @@ -882,32 +882,32 @@ virQEMUDriverConfigLoadSecurityEntry(virQEMUDriverCon= figPtr cfg, virReportError(VIR_ERR_CONF_SYNTAX, _("Duplicate security driver %s"), cfg->securityDriverNames[i]); - goto cleanup; + return -1; } } } =20 if (virConfGetValueBool(conf, "security_default_confined", &cfg->secur= ityDefaultConfined) < 0) - goto cleanup; + return -1; if (virConfGetValueBool(conf, "security_require_confined", &cfg->secur= ityRequireConfined) < 0) - goto cleanup; + return -1; =20 if (virConfGetValueString(conf, "user", &user) < 0) - goto cleanup; + return -1; if (user && virGetUserID(user, &cfg->user) < 0) - goto cleanup; + return -1; =20 if (virConfGetValueString(conf, "group", &group) < 0) - goto cleanup; + return -1; if (group && virGetGroupID(group, &cfg->group) < 0) - goto cleanup; + return -1; =20 if (virConfGetValueBool(conf, "dynamic_ownership", &cfg->dynamicOwners= hip) < 0) - goto cleanup; + return -1; =20 if (virConfGetValueStringList(conf, "cgroup_controllers", false, &controllers) < 0) - goto cleanup; + return -1; =20 if (controllers) { cfg->cgroupControllers =3D 0; @@ -917,7 +917,7 @@ virQEMUDriverConfigLoadSecurityEntry(virQEMUDriverConfi= gPtr cfg, virReportError(VIR_ERR_CONF_SYNTAX, _("Unknown cgroup controller '%s'"), controllers[i]); - goto cleanup; + return -1; } cfg->cgroupControllers |=3D (1 << ctl); } @@ -925,13 +925,13 @@ virQEMUDriverConfigLoadSecurityEntry(virQEMUDriverCon= figPtr cfg, =20 if (virConfGetValueStringList(conf, "cgroup_device_acl", false, &cfg->cgroupDeviceACL) < 0) - goto cleanup; + return -1; =20 if (virConfGetValueInt(conf, "seccomp_sandbox", &cfg->seccompSandbox) = < 0) - goto cleanup; + return -1; =20 if (virConfGetValueStringList(conf, "namespaces", false, &namespaces) = < 0) - goto cleanup; + return -1; =20 if (namespaces) { virBitmapClearAll(cfg->namespaces); @@ -943,38 +943,32 @@ virQEMUDriverConfigLoadSecurityEntry(virQEMUDriverCon= figPtr cfg, virReportError(VIR_ERR_CONF_SYNTAX, _("Unknown namespace: %s"), namespaces[i]); - goto cleanup; + return -1; } =20 if (!privileged) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("cannot use namespaces in session mode")); - goto cleanup; + return -1; } =20 if (!qemuDomainNamespaceAvailable(ns)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("%s namespace is not available"), namespaces[i]); - goto cleanup; + return -1; } =20 if (virBitmapSetBit(cfg->namespaces, ns) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to enable namespace: %s"), namespaces[i]); - goto cleanup; + return -1; } } } =20 - ret =3D 0; - cleanup: - virStringListFree(controllers); - virStringListFree(namespaces); - VIR_FREE(user); - VIR_FREE(group); - return ret; + return 0; } =20 =20 --=20 2.16.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 19:32:48 2024 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 1548078990510746.0233449687805; Mon, 21 Jan 2019 05:56:30 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id B7BCBDC8F2; Mon, 21 Jan 2019 13:56:27 +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 7BEFE60C6B; Mon, 21 Jan 2019 13:56:27 +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 262BE180339C; Mon, 21 Jan 2019 13:56:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0LDuQRc011811 for ; Mon, 21 Jan 2019 08:56:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2833E5D759; Mon, 21 Jan 2019 13:56:26 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 95B6D5D739 for ; Mon, 21 Jan 2019 13:56:25 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Mon, 21 Jan 2019 14:56:17 +0100 Message-Id: <9589cdb9e311bf2ab55f6714d967c16c40393a40.1548078934.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/4] virQEMUDriverConfigLoadSWTPMEntry: use VIR_AUTOFREE 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 21 Jan 2019 13:56:28 +0000 (UTC) Switch the function to use VIR_AUTOFREE and VIR_AUTOPTR macros to get rid of the cleanup section. Requested-by: John Ferlan Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/qemu/qemu_conf.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 524e5d4d0f..ba491e448b 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -984,24 +984,20 @@ static int virQEMUDriverConfigLoadSWTPMEntry(virQEMUDriverConfigPtr cfg, virConfPtr conf) { - char *swtpm_user =3D NULL, *swtpm_group =3D NULL; - int ret =3D -1; + VIR_AUTOFREE(char *) swtpm_user =3D NULL; + VIR_AUTOFREE(char *) swtpm_group =3D NULL; =20 if (virConfGetValueString(conf, "swtpm_user", &swtpm_user) < 0) - goto cleanup; + return -1; if (swtpm_user && virGetUserID(swtpm_user, &cfg->swtpm_user) < 0) - goto cleanup; + return -1; =20 if (virConfGetValueString(conf, "swtpm_group", &swtpm_group) < 0) - goto cleanup; + return -1; if (swtpm_group && virGetGroupID(swtpm_group, &cfg->swtpm_group) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - VIR_FREE(swtpm_user); - VIR_FREE(swtpm_group); - return ret; + return 0; } =20 =20 --=20 2.16.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list