From nobody Sun Feb 8 13:39:29 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 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 --- 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