From nobody Sun Apr 28 19:11:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639152443; cv=none; d=zohomail.com; s=zohoarc; b=Kl2lrzhMhHUJdwxZZ84D1kPHPayHzoiVdkiSt1asewkCE3JKBAcQzGJDh+Uq/VgJQ2q+2+E8EhZpH6VOUxQ0a1rV5lxfCoqDTy073NnL3cA5NdQSnzJnrvI5UVfHM4gaMhkJP2bUGuKhMC4mYRheJc/lgbjwl1x184ZQliKY9MI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639152443; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QQU1tLvB82CIgWfP+bUXWcL7i4r/lCBfO+o9zrKZI4w=; b=G4RvmhDAGs8LolE+5kZ5IyQJxtBRGOUU+/SE4wSkdig3c5gyw63OD7gNpfCpdLZIQnyL49AKHKbP6TG0ExYzEqyVMuc1sSJ4vj1eB+JQMHPkoJhDipsyM8dcPg9cCk3Sr7baWQODy/fG2r/vj6OHo9yRZ5PpixTIeoMw+hQaPPM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 16391524438711009.1065833471275; Fri, 10 Dec 2021 08:07:23 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-515-XkkVPMTmOVSsLosLJHYrpw-1; Fri, 10 Dec 2021 11:07:19 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 723F181EE60; Fri, 10 Dec 2021 16:07:13 +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 89E555DF37; Fri, 10 Dec 2021 16:07:10 +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 B4D574BB7C; Fri, 10 Dec 2021 16:07:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BAG6Lns015217 for ; Fri, 10 Dec 2021 11:06:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id F40D060BF4; Fri, 10 Dec 2021 16:06:20 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7BC9360C04 for ; Fri, 10 Dec 2021 16:06:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639152442; 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=QQU1tLvB82CIgWfP+bUXWcL7i4r/lCBfO+o9zrKZI4w=; b=AgZwZUCMbov+ClFahnBAL8yj8yFBs8RjZSbrulQbfuElFUwLHg7BPTE7My7FQXVUit01SO ci4HYYFXLJGDqHsbAs/wJWRbpSmLhX6Bgkg4agYf1RxowYoML49bIhq863CxOEHycDV+MF UJz6iJn3ANKhW0bd6Bc+Bxpz2vipmZk= X-MC-Unique: XkkVPMTmOVSsLosLJHYrpw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/8] lxc: fix error value of lxcNodeGetSecurityModel Date: Fri, 10 Dec 2021 17:06:11 +0100 Message-Id: <543d2fed9bf69980ff6e9554219221e695e4f603.1639152235.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639152446149100001 When adding the ACL check and caps getter, we assumed that the default return value is -1, not 0 as usual. Fix the return value on error by assigning them explicitly. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/lxc/lxc_driver.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 349783ca7c..d86147cc28 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1234,11 +1234,15 @@ static int lxcNodeGetSecurityModel(virConnectPtr co= nn, =20 memset(secmodel, 0, sizeof(*secmodel)); =20 - if (virNodeGetSecurityModelEnsureACL(conn) < 0) + if (virNodeGetSecurityModelEnsureACL(conn) < 0) { + ret =3D -1; goto cleanup; + } =20 - if (!(caps =3D virLXCDriverGetCapabilities(driver, false))) + if (!(caps =3D virLXCDriverGetCapabilities(driver, false))) { + ret =3D -1; goto cleanup; + } =20 /* we treat no driver as success, but simply return no data in *secmod= el */ if (caps->host.nsecModels =3D=3D 0 --=20 2.31.1 From nobody Sun Apr 28 19:11:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639152463; cv=none; d=zohomail.com; s=zohoarc; b=CBPXrnBVhHQbTQWLZgcW6X7fuGVx9jOCPuhpT+S9Y/RxEqeQXQ7j/aNXv4ChndvpEj7mXue9e0THy6cavrNh35qbFZ6Y1kOAgOxZ3jf5poRZ6Dmlzv4JUIdmtqICzQEnKcgR1kNfZ7XrjKSFb3a73tgN0dETSQ9oxY2baTR754w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639152463; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=df0V+KfMRLtboRjOCpO7/r3uJ2Ee2oxE6PQdUFOq+Sc=; b=T6vjVBLfGzgdvonpvDMkk1QHWVdAlLYq/od+AOmltwaC/qFapWepoLc9tgMaJb6jdLPgD9yxw2SxAvdZAycjGwxiTAtmaFI6GaMbVafBBWwUvpDLlDCG2LEyQu2bChQSPLDg23lIRCH1jnVgKrkiV5dEkoQ8VJnmo/EVbnjkbkU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1639152463365625.4874045887536; Fri, 10 Dec 2021 08:07:43 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-17-NjYP7aFIOna8l1elJ1X2aw-1; Fri, 10 Dec 2021 11:07:40 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8AB6E100F942; Fri, 10 Dec 2021 16:07:33 +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 D230360657; Fri, 10 Dec 2021 16:07:32 +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 7D6C04CA9B; Fri, 10 Dec 2021 16:07:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BAG6LhX015227 for ; Fri, 10 Dec 2021 11:06:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id C74B660C4A; Fri, 10 Dec 2021 16:06:21 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4EDB460BF4 for ; Fri, 10 Dec 2021 16:06:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639152462; 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=df0V+KfMRLtboRjOCpO7/r3uJ2Ee2oxE6PQdUFOq+Sc=; b=NhX0xeFRBa8IlUEFDbSMr+EY3XN8l2hY2yNxqE4ZLck5VJknS5HiuV8K5T1fZq84m9aR+a mnFwriE32rPxwhC2avRTKuQgyBFamVsIAXIumVI3hiERPWTkp+dUV+MMFwGF8S7vN4cuzc 3GO5Q7k+OIrH7r/MtTsJfQJ0fzNQnWU= X-MC-Unique: NjYP7aFIOna8l1elJ1X2aw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/8] Use g_auto for freeing virCaps Date: Fri, 10 Dec 2021 17:06:12 +0100 Message-Id: <162b336f33aff9fcbbb30a85333fb3d2aa133de7.1639152235.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639152464940100001 Convert all the users who unref their virCaps object unconditionally. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_driver.c | 9 +++------ src/ch/ch_driver.c | 3 +-- src/lxc/lxc_driver.c | 21 +++++++-------------- src/lxc/lxc_process.c | 3 +-- 4 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 250e10b9d0..e445c8cadf 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -140,7 +140,7 @@ static char * bhyveConnectGetCapabilities(virConnectPtr conn) { struct _bhyveConn *privconn =3D conn->privateData; - virCaps *caps; + g_autoptr(virCaps) caps =3D NULL; char *xml =3D NULL; =20 if (virConnectGetCapabilitiesEnsureACL(conn) < 0) @@ -156,7 +156,6 @@ bhyveConnectGetCapabilities(virConnectPtr conn) goto cleanup; =20 cleanup: - virObjectUnref(caps); return xml; } =20 @@ -508,7 +507,7 @@ bhyveDomainDefineXMLFlags(virConnectPtr conn, const cha= r *xml, unsigned int flag g_autoptr(virDomainDef) oldDef =3D NULL; virDomainObj *vm =3D NULL; virObjectEvent *event =3D NULL; - virCaps *caps =3D NULL; + g_autoptr(virCaps) caps =3D NULL; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE; =20 virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL); @@ -554,7 +553,6 @@ bhyveDomainDefineXMLFlags(virConnectPtr conn, const cha= r *xml, unsigned int flag dom =3D virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id); =20 cleanup: - virObjectUnref(caps); virDomainObjEndAPI(&vm); virObjectEventStateQueue(privconn->domainEventState, event); =20 @@ -1434,7 +1432,7 @@ bhyveConnectCompareCPU(virConnectPtr conn, { struct _bhyveConn *driver =3D conn->privateData; int ret =3D VIR_CPU_COMPARE_ERROR; - virCaps *caps =3D NULL; + g_autoptr(virCaps) caps =3D NULL; bool failIncompatible; bool validateXML; =20 @@ -1466,7 +1464,6 @@ bhyveConnectCompareCPU(virConnectPtr conn, } =20 cleanup: - virObjectUnref(caps); return ret; } =20 diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index 108644e503..06cfb1c5ef 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -187,7 +187,7 @@ static int chNodeGetInfo(virConnectPtr conn, static char *chConnectGetCapabilities(virConnectPtr conn) { virCHDriver *driver =3D conn->privateData; - virCaps *caps; + g_autoptr(virCaps) caps =3D NULL; char *xml; =20 if (virConnectGetCapabilitiesEnsureACL(conn) < 0) @@ -198,7 +198,6 @@ static char *chConnectGetCapabilities(virConnectPtr con= n) =20 xml =3D virCapabilitiesFormatXML(caps); =20 - virObjectUnref(caps); return xml; } =20 diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index d86147cc28..92ae22ef2b 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -197,7 +197,7 @@ static int lxcConnectIsAlive(virConnectPtr conn G_GNUC_= UNUSED) =20 static char *lxcConnectGetCapabilities(virConnectPtr conn) { virLXCDriver *driver =3D conn->privateData; - virCaps *caps; + g_autoptr(virCaps) caps =3D NULL; char *xml; =20 if (virConnectGetCapabilitiesEnsureACL(conn) < 0) @@ -208,7 +208,6 @@ static char *lxcConnectGetCapabilities(virConnectPtr co= nn) { =20 xml =3D virCapabilitiesFormatXML(caps); =20 - virObjectUnref(caps); return xml; } =20 @@ -405,7 +404,7 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char = *xml, unsigned int flags) virObjectEvent *event =3D NULL; g_autoptr(virDomainDef) oldDef =3D NULL; virLXCDriverConfig *cfg =3D virLXCDriverGetConfig(driver); - virCaps *caps =3D NULL; + g_autoptr(virCaps) caps =3D NULL; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE; =20 virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL); @@ -459,7 +458,6 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char = *xml, unsigned int flags) cleanup: virDomainObjEndAPI(&vm); virObjectEventStateQueue(driver->domainEventState, event); - virObjectUnref(caps); virObjectUnref(cfg); return dom; } @@ -937,7 +935,7 @@ static char *lxcConnectDomainXMLFromNative(virConnectPt= r conn, char *xml =3D NULL; g_autoptr(virDomainDef) def =3D NULL; virLXCDriver *driver =3D conn->privateData; - virCaps *caps =3D virLXCDriverGetCapabilities(driver, false); + g_autoptr(virCaps) caps =3D virLXCDriverGetCapabilities(driver, false); =20 virCheckFlags(0, NULL); =20 @@ -956,7 +954,6 @@ static char *lxcConnectDomainXMLFromNative(virConnectPt= r conn, xml =3D virDomainDefFormat(def, driver->xmlopt, 0); =20 cleanup: - virObjectUnref(caps); return xml; } =20 @@ -1082,7 +1079,7 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn, virDomainPtr dom =3D NULL; virObjectEvent *event =3D NULL; virLXCDriverConfig *cfg =3D virLXCDriverGetConfig(driver); - virCaps *caps =3D NULL; + g_autoptr(virCaps) caps =3D NULL; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE; =20 virCheckFlags(VIR_DOMAIN_START_AUTODESTROY | @@ -1150,7 +1147,6 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn, cleanup: virDomainObjEndAPI(&vm); virObjectEventStateQueue(driver->domainEventState, event); - virObjectUnref(caps); virObjectUnref(cfg); virNWFilterUnlockFilterUpdates(); return dom; @@ -1229,7 +1225,7 @@ static int lxcNodeGetSecurityModel(virConnectPtr conn, virSecurityModelPtr secmodel) { virLXCDriver *driver =3D conn->privateData; - virCaps *caps =3D NULL; + g_autoptr(virCaps) caps =3D NULL; int ret =3D 0; =20 memset(secmodel, 0, sizeof(*secmodel)); @@ -1268,7 +1264,6 @@ static int lxcNodeGetSecurityModel(virConnectPtr conn, } =20 cleanup: - virObjectUnref(caps); return ret; } =20 @@ -1807,7 +1802,7 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom, unsigned int flags) { virLXCDriver *driver =3D dom->conn->privateData; - virCaps *caps =3D NULL; + g_autoptr(virCaps) caps =3D NULL; size_t i; virDomainObj *vm =3D NULL; virDomainDef *def =3D NULL; @@ -1925,7 +1920,6 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom, =20 cleanup: virDomainObjEndAPI(&vm); - virObjectUnref(caps); virObjectUnref(cfg); return ret; } @@ -4456,7 +4450,7 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr do= m, unsigned int flags) { virLXCDriver *driver =3D dom->conn->privateData; - virCaps *caps =3D NULL; + g_autoptr(virCaps) caps =3D NULL; virDomainObj *vm =3D NULL; g_autoptr(virDomainDef) vmdef =3D NULL; virDomainDeviceDef *dev =3D NULL; @@ -4540,7 +4534,6 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr do= m, virDomainDeviceDefFree(dev_copy); virDomainDeviceDefFree(dev); virDomainObjEndAPI(&vm); - virObjectUnref(caps); virObjectUnref(cfg); return ret; } diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index d262128a50..501f418557 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -1207,7 +1207,7 @@ int virLXCProcessStart(virConnectPtr conn, int nsInheritFDs[VIR_LXC_DOMAIN_NAMESPACE_LAST]; virCommand *cmd =3D NULL; virLXCDomainObjPrivate *priv =3D vm->privateData; - virCaps *caps =3D NULL; + g_autoptr(virCaps) caps =3D NULL; virErrorPtr err =3D NULL; virLXCDriverConfig *cfg =3D virLXCDriverGetConfig(driver); g_autoptr(virCgroup) selfcgroup =3D NULL; @@ -1579,7 +1579,6 @@ int virLXCProcessStart(virConnectPtr conn, for (i =3D 0; i < G_N_ELEMENTS(handshakefds); i++) VIR_FORCE_CLOSE(handshakefds[i]); virObjectUnref(cfg); - virObjectUnref(caps); =20 virErrorRestore(&err); =20 --=20 2.31.1 From nobody Sun Apr 28 19:11:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639152552; cv=none; d=zohomail.com; s=zohoarc; b=Zu3mnN1brrJZAklwv+cmw83R5KrPmYl4LxETSPyaJYuJfzi01XgoWXkTzjER+9eZ0UU4AD7VGuD+R6WNA8eMghw/e2tc6jKC01oBkhsPv4EPmD5BOfcQAHg1y9Vx1npyAaN0W4xrLvYUXRI/AQmeRMSV6y0G8aREl2SGw5p297o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639152552; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qUKKwxKjbriQFIjFo9oosLr+THSRaD6fxlaibxLQLiY=; b=VBu0z7widFYH476+KmC+R1bwdp85yHgBIVogFBO66/5MeEP17XDd5Ke9iEkr+tF1r2Fhot9D4Is63zCyF7a9ENQydwnaWSHgdF1imMbWLUtfhY1ztYphKoTsrCuEW07yM8Q0ujwNluLMLuasvTW1NzShQ5ucqZjag5kmrNUqCys= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1639152552577778.2232677868384; Fri, 10 Dec 2021 08:09:12 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-386-o6o09nixPAa1YNKmWWfwpQ-1; Fri, 10 Dec 2021 11:09:09 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 425B5100CCC4; Fri, 10 Dec 2021 16:09:03 +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 2779345D74; Fri, 10 Dec 2021 16:09:03 +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 F00304A706; Fri, 10 Dec 2021 16:09:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BAG6MD2015233 for ; Fri, 10 Dec 2021 11:06:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9ADAC60C04; Fri, 10 Dec 2021 16:06:22 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22A0160BF4 for ; Fri, 10 Dec 2021 16:06:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639152551; 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=qUKKwxKjbriQFIjFo9oosLr+THSRaD6fxlaibxLQLiY=; b=jLW8mbawTw3tYehTfIGRl6C3azAICDhEJYsQTdF46iwt6PBVSfEX4gKEjRGhQWV8PpjmCL hZ+QrLLpK9iiJcxrfmla0dc694Gkkqsy8WXb2lcSjBGw0GqQkwnnd7smQlozeS/jQejPRw ezf9F1k5+6qdpJzJY55UK3ijar2t7YE= X-MC-Unique: o6o09nixPAa1YNKmWWfwpQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/8] Use g_auto for stealing virCaps Date: Fri, 10 Dec 2021 17:06:13 +0100 Message-Id: <85850846d152d86c976e8a19ae751f2591953f17.1639152235.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639152554360100001 Convert all the functions that generate virCaps to use g_auto and g_steal_pointer. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/ch/ch_conf.c | 5 ++--- src/hyperv/hyperv_driver.c | 5 ++--- src/libxl/libxl_capabilities.c | 5 ++--- src/lxc/lxc_conf.c | 5 ++--- src/test/test_driver.c | 5 ++--- src/vmware/vmware_conf.c | 5 ++--- src/vz/vz_driver.c | 5 ++--- tests/qemucaps2xmltest.c | 5 ++--- tests/testutilsxen.c | 5 ++--- 9 files changed, 18 insertions(+), 27 deletions(-) diff --git a/src/ch/ch_conf.c b/src/ch/ch_conf.c index ef6f4b5ba8..a9cbbca560 100644 --- a/src/ch/ch_conf.c +++ b/src/ch/ch_conf.c @@ -52,7 +52,7 @@ VIR_ONCE_GLOBAL_INIT(virCHConfig); /* Functions */ virCaps *virCHDriverCapsInit(void) { - virCaps *caps; + g_autoptr(virCaps) caps =3D NULL; virCapsGuest *guest; =20 if ((caps =3D virCapabilitiesNew(virArchFromHost(), @@ -70,10 +70,9 @@ virCaps *virCHDriverCapsInit(void) =20 virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM, NULL, NULL, 0, NULL); - return caps; + return g_steal_pointer(&caps); =20 cleanup: - virObjectUnref(caps); return NULL; } =20 diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index bafec27a88..4d938f4d7f 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -262,7 +262,7 @@ hypervLookupHostSystemBiosUuid(hypervPrivate *priv, uns= igned char *uuid) static virCaps * hypervCapsInit(hypervPrivate *priv) { - virCaps *caps =3D NULL; + g_autoptr(virCaps) caps =3D NULL; virCapsGuest *guest =3D NULL; =20 caps =3D virCapabilitiesNew(VIR_ARCH_X86_64, 1, 1); @@ -287,10 +287,9 @@ hypervCapsInit(hypervPrivate *priv) virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_HYPERV, NULL, NULL, 0, NULL); =20 - return caps; + return g_steal_pointer(&caps); =20 error: - virObjectUnref(caps); return NULL; } =20 diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c index 6263b5c8b5..9084dacb40 100644 --- a/src/libxl/libxl_capabilities.c +++ b/src/libxl/libxl_capabilities.c @@ -635,7 +635,7 @@ libxlMakeDomainDeviceHostdevCaps(virDomainCapsDeviceHos= tdev *dev) virCaps * libxlMakeCapabilities(libxl_ctx *ctx) { - virCaps *caps; + g_autoptr(virCaps) caps =3D NULL; =20 #ifdef LIBXL_HAVE_NO_SUSPEND_RESUME if ((caps =3D virCapabilitiesNew(virArchFromHost(), false, false)) =3D= =3D NULL) @@ -653,10 +653,9 @@ libxlMakeCapabilities(libxl_ctx *ctx) if (libxlCapsInitGuests(ctx, caps) < 0) goto error; =20 - return caps; + return g_steal_pointer(&caps); =20 error: - virObjectUnref(caps); return NULL; } =20 diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index 73156f15a3..e9186b879e 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -58,7 +58,7 @@ VIR_ONCE_GLOBAL_INIT(virLXCConfig); /* Functions */ virCaps *virLXCDriverCapsInit(virLXCDriver *driver) { - virCaps *caps; + g_autoptr(virCaps) caps =3D NULL; virCapsGuest *guest; virArch altArch; g_autofree char *lxc_path =3D NULL; @@ -138,10 +138,9 @@ virCaps *virLXCDriverCapsInit(virLXCDriver *driver) VIR_INFO("No driver, not initializing security driver"); } =20 - return caps; + return g_steal_pointer(&caps); =20 error: - virObjectUnref(caps); return NULL; } =20 diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 995e63b004..020a9e5df0 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -291,7 +291,7 @@ static virCaps * testBuildCapabilities(virConnectPtr conn) { testDriver *privconn =3D conn->privateData; - virCaps *caps; + g_autoptr(virCaps) caps =3D NULL; virCapsGuest *guest; int guest_types[] =3D { VIR_DOMAIN_OSTYPE_HVM, VIR_DOMAIN_OSTYPE_XEN }; @@ -361,10 +361,9 @@ testBuildCapabilities(virConnectPtr conn) =20 caps->host.secModels[0].doi =3D g_strdup(""); =20 - return caps; + return g_steal_pointer(&caps); =20 error: - virObjectUnref(caps); return NULL; } =20 diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index 8c8ecc8120..3f6b51ac44 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -64,7 +64,7 @@ vmwareFreeDriver(struct vmware_driver *driver) virCaps * vmwareCapsInit(void) { - virCaps *caps =3D NULL; + g_autoptr(virCaps) caps =3D NULL; virCapsGuest *guest =3D NULL; =20 if ((caps =3D virCapabilitiesNew(virArchFromHost(), @@ -106,11 +106,10 @@ vmwareCapsInit(void) guest =3D NULL; } =20 - return caps; + return g_steal_pointer(&caps); =20 error: virCapabilitiesFreeGuest(guest); - virObjectUnref(caps); return NULL; } =20 diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 83ff119dd9..1353efa6ab 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -94,7 +94,7 @@ vzCapsAddGuestDomain(virCaps *caps, static virCaps * vzBuildCapabilities(void) { - virCaps *caps =3D NULL; + g_autoptr(virCaps) caps =3D NULL; virNodeInfo nodeinfo; virDomainOSType ostypes[] =3D { VIR_DOMAIN_OSTYPE_HVM, @@ -137,10 +137,9 @@ vzBuildCapabilities(void) if (virCapabilitiesAddHostMigrateTransport(caps, "vzmigr") < 0) goto error; =20 - return caps; + return g_steal_pointer(&caps); =20 error: - virObjectUnref(caps); return NULL; } =20 diff --git a/tests/qemucaps2xmltest.c b/tests/qemucaps2xmltest.c index 78a2148e1a..aec4647678 100644 --- a/tests/qemucaps2xmltest.c +++ b/tests/qemucaps2xmltest.c @@ -86,7 +86,7 @@ static virCaps * testGetCaps(char *capsData, const testQemuData *data) { g_autoptr(virQEMUCaps) qemuCaps =3D NULL; - virCaps *caps =3D NULL; + g_autoptr(virCaps) caps =3D NULL; virArch arch =3D virArchFromString(data->archName); g_autofree char *binary =3D NULL; =20 @@ -110,10 +110,9 @@ testGetCaps(char *capsData, const testQemuData *data) goto error; } =20 - return caps; + return g_steal_pointer(&caps); =20 error: - virObjectUnref(caps); return NULL; } =20 diff --git a/tests/testutilsxen.c b/tests/testutilsxen.c index 1b584e34b1..821ee49d94 100644 --- a/tests/testutilsxen.c +++ b/tests/testutilsxen.c @@ -11,7 +11,7 @@ static virCaps * testXLInitCaps(void) { - virCaps *caps; + g_autoptr(virCaps) caps =3D NULL; virCapsGuest *guest; virCapsGuestMachine **machines; int nmachines; @@ -68,11 +68,10 @@ testXLInitCaps(void) =20 virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN, NULL, NULL, 0, NULL); - return caps; + return g_steal_pointer(&caps); =20 cleanup: virCapabilitiesFreeMachines(machines, nmachines); - virObjectUnref(caps); return NULL; } =20 --=20 2.31.1 From nobody Sun Apr 28 19:11:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639152469; cv=none; d=zohomail.com; s=zohoarc; b=MXI4fpqz6rOhCLMp5X7iJtse3zy+FybvhyRjBvrU1qhnrfmr2aGVgRAsprCxfkX7QfrfhlSfuR7tgQLhImS3NDFPD57rWjZX+Mck0ZWwsC42mxxF/88zD0V9cV7a0b+0mVDe4VioYsUvX3MiiNm8fsA1hQZDl0+Ic9DV0Bz2C3w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639152469; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sZxkXGwjqZbYQxA1z4n4c68/0iWPbuf5rb1zeURpioc=; b=ZqmCrGfrb8/G0/JItVVDvEaV++rdjUJIzYALZj7Qz4Q7Qb12StFblx7UE1AuQnLmT7ODn3sLtdBHaq58NpM3RZzxH47FV3kKihG1akFdYJMqvdWhIJjgLrRAyT/CuSoMEWF2Pv+utvb5H4bEHRGjL+TWB9e/CXmbtyZy/gTQRNI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1639152469043124.56966271496822; Fri, 10 Dec 2021 08:07:49 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-394-NvQX6XnlM-2pqFoYnlRViw-1; Fri, 10 Dec 2021 11:07:44 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3DA1185B660; Fri, 10 Dec 2021 16:07:39 +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 213311001F4D; Fri, 10 Dec 2021 16:07:39 +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 E8DFC4A7CA; Fri, 10 Dec 2021 16:07:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BAG6NEA015242 for ; Fri, 10 Dec 2021 11:06:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6F2EF60C04; Fri, 10 Dec 2021 16:06:23 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8E2F60BF4 for ; Fri, 10 Dec 2021 16:06:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639152468; 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=sZxkXGwjqZbYQxA1z4n4c68/0iWPbuf5rb1zeURpioc=; b=Sh0znmpVh7i8/S2QNApl7bapVT1uOJI/ZvnQZVdGprLPYdL0QIyQHtCYAnOwgv+/Bl8GJD LEfTyYmIfMhSP9oa59qu+j0rG1/EU4SQ9L2yPxlipyiHtKu5uFTs5Govr25ploL6ZQ7lts haFGD0AXVc6jqQsNJZRdMJXgspBGins= X-MC-Unique: NvQX6XnlM-2pqFoYnlRViw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 4/8] lxc: define cleanup function for virLXCDriverConfig Date: Fri, 10 Dec 2021 17:06:14 +0100 Message-Id: <6f32ef2fa135c663d258f0a42e1d0eaec0e3991e.1639152235.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639152470383100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/lxc/lxc_conf.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lxc/lxc_conf.h b/src/lxc/lxc_conf.h index 8993013ea4..5a1351bd63 100644 --- a/src/lxc/lxc_conf.h +++ b/src/lxc/lxc_conf.h @@ -102,6 +102,8 @@ struct _virLXCDriver { virCloseCallbacks *closeCallbacks; }; =20 +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virLXCDriverConfig, virObjectUnref); + virLXCDriverConfig *virLXCDriverConfigNew(void); virLXCDriverConfig *virLXCDriverGetConfig(virLXCDriver *driver); int virLXCLoadDriverConfig(virLXCDriverConfig *cfg, --=20 2.31.1 From nobody Sun Apr 28 19:11:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639152556; cv=none; d=zohomail.com; s=zohoarc; b=Mn9tkvdXbMJrbSC8FqKURDP3d54BiW5BzMFVpCmNC3iluAiirM7CHw4+qZPmTJiiUyPkLNkpnw+SZ6e618TjWVFnGN0ulGoshxW41odf0rNkv8/cHA/ghEL1RL94pQ984uuubQ2mq843jKbqyPC0w5QCHd+7O6ctuqgw5onjEtw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639152556; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=w8S9cUvR++ZOf7pzLaxKfFveyzINNkoHWHvO08nd37A=; b=W5m4EFANpYKm7gfj550iIYwPArta9sZ2YJn58gfqVT1zZvCo9dtFjv5TFqZ2A3JL8F2cjVQY69iodszMEB8KHrLyD3bzHXyofUejgTtaSAn7WNAEm70XGX18zskK19ecT9lhsbUMNPCg8qXeRngpaY3gafqN1ax8j1xPBMUseCs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1639152556411381.8918957685926; Fri, 10 Dec 2021 08:09:16 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-62-2zu2GxMJN72CB8UjzUSkCg-1; Fri, 10 Dec 2021 11:09:12 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9C94B100CCD9; Fri, 10 Dec 2021 16:09:06 +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 831C845D66; Fri, 10 Dec 2021 16:09:06 +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 575FE1809CB9; Fri, 10 Dec 2021 16:09:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BAG6Oi8015247 for ; Fri, 10 Dec 2021 11:06:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 40E6E60C4A; Fri, 10 Dec 2021 16:06:24 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC21560BF4 for ; Fri, 10 Dec 2021 16:06:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639152555; 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=w8S9cUvR++ZOf7pzLaxKfFveyzINNkoHWHvO08nd37A=; b=VVi0xSDtXz4n+RB4jkRjOXbYdLaIn3im7qdYq5EXSroNNeg/Q4kG5lIwc8ob1SGW1MNLjV Xe2XBiGp5srFOA2NPxVLy+ae6xkAn4xNnW8h97G8T8QGNawRNL7oCq2HPaex7kgosvZYL6 EcuMhrVV+AJPlIp0pUibDmJswBb364U= X-MC-Unique: 2zu2GxMJN72CB8UjzUSkCg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 5/8] lxc: use g_auto for virLXCDriverGetConfig Date: Fri, 10 Dec 2021 17:06:15 +0100 Message-Id: <84fcf4661eb24f001024cdac470abd4c31d6947e.1639152235.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639152557298100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/lxc/lxc_driver.c | 48 +++++++++++++++---------------------------- src/lxc/lxc_process.c | 22 +++++++------------- 2 files changed, 23 insertions(+), 47 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 92ae22ef2b..0d438de4a5 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -403,7 +403,7 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char = *xml, unsigned int flags) virDomainPtr dom =3D NULL; virObjectEvent *event =3D NULL; g_autoptr(virDomainDef) oldDef =3D NULL; - virLXCDriverConfig *cfg =3D virLXCDriverGetConfig(driver); + g_autoptr(virLXCDriverConfig) cfg =3D virLXCDriverGetConfig(driver); g_autoptr(virCaps) caps =3D NULL; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE; =20 @@ -458,7 +458,6 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char = *xml, unsigned int flags) cleanup: virDomainObjEndAPI(&vm); virObjectEventStateQueue(driver->domainEventState, event); - virObjectUnref(cfg); return dom; } =20 @@ -475,7 +474,7 @@ static int lxcDomainUndefineFlags(virDomainPtr dom, virDomainObj *vm; virObjectEvent *event =3D NULL; int ret =3D -1; - virLXCDriverConfig *cfg =3D virLXCDriverGetConfig(driver); + g_autoptr(virLXCDriverConfig) cfg =3D virLXCDriverGetConfig(driver); =20 virCheckFlags(0, -1); =20 @@ -510,7 +509,6 @@ static int lxcDomainUndefineFlags(virDomainPtr dom, cleanup: virDomainObjEndAPI(&vm); virObjectEventStateQueue(driver->domainEventState, event); - virObjectUnref(cfg); return ret; } =20 @@ -638,7 +636,7 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, un= signed long newmem, int ret =3D -1; virLXCDomainObjPrivate *priv; virLXCDriver *driver =3D dom->conn->privateData; - virLXCDriverConfig *cfg =3D NULL; + g_autoptr(virLXCDriverConfig) cfg =3D NULL; =20 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG | @@ -719,7 +717,6 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, un= signed long newmem, =20 cleanup: virDomainObjEndAPI(&vm); - virObjectUnref(cfg); return ret; } =20 @@ -743,7 +740,7 @@ lxcDomainSetMemoryParameters(virDomainPtr dom, virDomainDef *persistentDef =3D NULL; virDomainObj *vm =3D NULL; virLXCDomainObjPrivate *priv =3D NULL; - virLXCDriverConfig *cfg =3D NULL; + g_autoptr(virLXCDriverConfig) cfg =3D NULL; virLXCDriver *driver =3D dom->conn->privateData; int ret =3D -1; =20 @@ -804,7 +801,6 @@ lxcDomainSetMemoryParameters(virDomainPtr dom, =20 cleanup: virDomainObjEndAPI(&vm); - virObjectUnref(cfg); return ret; } =20 @@ -975,7 +971,7 @@ static int lxcDomainCreateWithFiles(virDomainPtr dom, virDomainObj *vm; virObjectEvent *event =3D NULL; int ret =3D -1; - virLXCDriverConfig *cfg =3D virLXCDriverGetConfig(driver); + g_autoptr(virLXCDriverConfig) cfg =3D virLXCDriverGetConfig(driver); =20 virCheckFlags(VIR_DOMAIN_START_AUTODESTROY, -1); =20 @@ -1022,7 +1018,6 @@ static int lxcDomainCreateWithFiles(virDomainPtr dom, cleanup: virDomainObjEndAPI(&vm); virObjectEventStateQueue(driver->domainEventState, event); - virObjectUnref(cfg); virNWFilterUnlockFilterUpdates(); return ret; } @@ -1078,7 +1073,7 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn, g_autoptr(virDomainDef) def =3D NULL; virDomainPtr dom =3D NULL; virObjectEvent *event =3D NULL; - virLXCDriverConfig *cfg =3D virLXCDriverGetConfig(driver); + g_autoptr(virLXCDriverConfig) cfg =3D virLXCDriverGetConfig(driver); g_autoptr(virCaps) caps =3D NULL; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE; =20 @@ -1147,7 +1142,6 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn, cleanup: virDomainObjEndAPI(&vm); virObjectEventStateQueue(driver->domainEventState, event); - virObjectUnref(cfg); virNWFilterUnlockFilterUpdates(); return dom; } @@ -1592,7 +1586,7 @@ static void lxcNotifyLoadDomain(virDomainObj *vm, int= newVM, void *opaque) static int lxcStateReload(void) { - virLXCDriverConfig *cfg =3D NULL; + g_autoptr(virLXCDriverConfig) cfg =3D NULL; =20 if (!lxc_driver) return 0; @@ -1604,7 +1598,6 @@ lxcStateReload(void) cfg->autostartDir, false, lxc_driver->xmlopt, lxcNotifyLoadDomain, lxc_driver); - virObjectUnref(cfg); return 0; } =20 @@ -1811,7 +1804,7 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom, int ret =3D -1; int rc; virLXCDomainObjPrivate *priv; - virLXCDriverConfig *cfg =3D virLXCDriverGetConfig(driver); + g_autoptr(virLXCDriverConfig) cfg =3D virLXCDriverGetConfig(driver); =20 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1); @@ -1920,7 +1913,6 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom, =20 cleanup: virDomainObjEndAPI(&vm); - virObjectUnref(cfg); return ret; } =20 @@ -2245,7 +2237,7 @@ lxcDomainSetBlkioParameters(virDomainPtr dom, virDomainDef *def =3D NULL; virDomainDef *persistentDef =3D NULL; int ret =3D -1; - virLXCDriverConfig *cfg =3D NULL; + g_autoptr(virLXCDriverConfig) cfg =3D NULL; virLXCDomainObjPrivate *priv; =20 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | @@ -2310,7 +2302,6 @@ lxcDomainSetBlkioParameters(virDomainPtr dom, =20 cleanup: virDomainObjEndAPI(&vm); - virObjectUnref(cfg); return ret; } =20 @@ -2470,7 +2461,7 @@ static int lxcDomainSetAutostart(virDomainPtr dom, g_autofree char *configFile =3D NULL; g_autofree char *autostartLink =3D NULL; int ret =3D -1; - virLXCDriverConfig *cfg =3D virLXCDriverGetConfig(driver); + g_autoptr(virLXCDriverConfig) cfg =3D virLXCDriverGetConfig(driver); =20 if (!(vm =3D lxcDomObjFromDomain(dom))) goto cleanup; @@ -2534,7 +2525,6 @@ static int lxcDomainSetAutostart(virDomainPtr dom, =20 cleanup: virDomainObjEndAPI(&vm); - virObjectUnref(cfg); return ret; } =20 @@ -2622,7 +2612,7 @@ static int lxcDomainSuspend(virDomainPtr dom) virDomainObj *vm; virObjectEvent *event =3D NULL; int ret =3D -1; - virLXCDriverConfig *cfg =3D virLXCDriverGetConfig(driver); + g_autoptr(virLXCDriverConfig) cfg =3D virLXCDriverGetConfig(driver); =20 if (!(vm =3D lxcDomObjFromDomain(dom))) goto cleanup; @@ -2659,7 +2649,6 @@ static int lxcDomainSuspend(virDomainPtr dom) cleanup: virObjectEventStateQueue(driver->domainEventState, event); virDomainObjEndAPI(&vm); - virObjectUnref(cfg); return ret; } =20 @@ -2671,7 +2660,7 @@ static int lxcDomainResume(virDomainPtr dom) int ret =3D -1; int state; virLXCDomainObjPrivate *priv; - virLXCDriverConfig *cfg =3D virLXCDriverGetConfig(driver); + g_autoptr(virLXCDriverConfig) cfg =3D virLXCDriverGetConfig(driver); =20 if (!(vm =3D lxcDomObjFromDomain(dom))) goto cleanup; @@ -2716,7 +2705,6 @@ static int lxcDomainResume(virDomainPtr dom) cleanup: virObjectEventStateQueue(driver->domainEventState, event); virDomainObjEndAPI(&vm); - virObjectUnref(cfg); return ret; } =20 @@ -4286,7 +4274,7 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr do= m, virDomainDeviceDef *dev =3D NULL; virDomainDeviceDef *dev_copy =3D NULL; int ret =3D -1; - virLXCDriverConfig *cfg =3D virLXCDriverGetConfig(driver); + g_autoptr(virLXCDriverConfig) cfg =3D virLXCDriverGetConfig(driver); =20 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1); @@ -4370,7 +4358,6 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr do= m, virDomainDeviceDefFree(dev_copy); virDomainDeviceDefFree(dev); virDomainObjEndAPI(&vm); - virObjectUnref(cfg); return ret; } =20 @@ -4392,7 +4379,7 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr do= m, g_autoptr(virDomainDef) vmdef =3D NULL; virDomainDeviceDef *dev =3D NULL; int ret =3D -1; - virLXCDriverConfig *cfg =3D virLXCDriverGetConfig(driver); + g_autoptr(virLXCDriverConfig) cfg =3D virLXCDriverGetConfig(driver); =20 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1); @@ -4440,7 +4427,6 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr do= m, cleanup: virDomainDeviceDefFree(dev); virDomainObjEndAPI(&vm); - virObjectUnref(cfg); return ret; } =20 @@ -4456,7 +4442,7 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr do= m, virDomainDeviceDef *dev =3D NULL; virDomainDeviceDef *dev_copy =3D NULL; int ret =3D -1; - virLXCDriverConfig *cfg =3D virLXCDriverGetConfig(driver); + g_autoptr(virLXCDriverConfig) cfg =3D virLXCDriverGetConfig(driver); =20 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1); @@ -4534,7 +4520,6 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr do= m, virDomainDeviceDefFree(dev_copy); virDomainDeviceDefFree(dev); virDomainObjEndAPI(&vm); - virObjectUnref(cfg); return ret; } =20 @@ -4807,7 +4792,7 @@ lxcDomainSetMetadata(virDomainPtr dom, { virLXCDriver *driver =3D dom->conn->privateData; virDomainObj *vm; - virLXCDriverConfig *cfg =3D NULL; + g_autoptr(virLXCDriverConfig) cfg =3D NULL; int ret =3D -1; =20 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | @@ -4838,7 +4823,6 @@ lxcDomainSetMetadata(virDomainPtr dom, =20 cleanup: virDomainObjEndAPI(&vm); - virObjectUnref(cfg); return ret; } =20 diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 501f418557..9cae025517 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -170,7 +170,7 @@ static void virLXCProcessCleanup(virLXCDriver *driver, size_t i; virLXCDomainObjPrivate *priv =3D vm->privateData; const virNetDevVPortProfile *vport =3D NULL; - virLXCDriverConfig *cfg =3D virLXCDriverGetConfig(driver); + g_autoptr(virLXCDriverConfig) cfg =3D virLXCDriverGetConfig(driver); g_autoptr(virConnect) conn =3D NULL; =20 VIR_DEBUG("Cleanup VM name=3D%s pid=3D%d reason=3D%d flags=3D0x%x", @@ -278,8 +278,6 @@ static void virLXCProcessCleanup(virLXCDriver *driver, =20 if (flags & VIR_LXC_PROCESS_CLEANUP_REMOVE_TRANSIENT) virDomainObjRemoveTransientDef(vm); - - virObjectUnref(cfg); } =20 =20 @@ -367,7 +365,7 @@ virLXCProcessSetupInterfaceDirect(virLXCDriver *driver, char *res_ifname =3D NULL; const virNetDevBandwidth *bw; const virNetDevVPortProfile *prof; - virLXCDriverConfig *cfg =3D virLXCDriverGetConfig(driver); + g_autoptr(virLXCDriverConfig) cfg =3D virLXCDriverGetConfig(driver); const char *linkdev =3D virDomainNetGetActualDirectDev(net); unsigned int macvlan_create_flags =3D VIR_NETDEV_MACVLAN_CREATE_IFUP; =20 @@ -414,7 +412,6 @@ virLXCProcessSetupInterfaceDirect(virLXCDriver *driver, ret =3D res_ifname; =20 cleanup: - virObjectUnref(cfg); return ret; } =20 @@ -801,7 +798,7 @@ static void virLXCProcessMonitorInitNotify(virLXCMonito= r *mon G_GNUC_UNUSED, { virLXCDriver *driver =3D lxc_driver; virLXCDomainObjPrivate *priv; - virLXCDriverConfig *cfg =3D virLXCDriverGetConfig(driver); + g_autoptr(virLXCDriverConfig) cfg =3D virLXCDriverGetConfig(driver); ino_t inode =3D 0; =20 virObjectLock(vm); @@ -821,7 +818,6 @@ static void virLXCProcessMonitorInitNotify(virLXCMonito= r *mon G_GNUC_UNUSED, VIR_WARN("Cannot update XML with PID for LXC %s", vm->def->name); =20 virObjectUnlock(vm); - virObjectUnref(cfg); } =20 static virLXCMonitorCallbacks monitorCallbacks =3D { @@ -835,7 +831,7 @@ static virLXCMonitor *virLXCProcessConnectMonitor(virLX= CDriver *driver, virDomainObj *vm) { virLXCMonitor *monitor =3D NULL; - virLXCDriverConfig *cfg =3D virLXCDriverGetConfig(driver); + g_autoptr(virLXCDriverConfig) cfg =3D virLXCDriverGetConfig(driver); =20 if (virSecurityManagerSetSocketLabel(driver->securityManager, vm->def)= < 0) goto cleanup; @@ -859,7 +855,6 @@ static virLXCMonitor *virLXCProcessConnectMonitor(virLX= CDriver *driver, } =20 cleanup: - virObjectUnref(cfg); return monitor; } =20 @@ -948,7 +943,7 @@ virLXCProcessBuildControllerCmd(virLXCDriver *driver, g_autofree char *filterstr =3D NULL; g_autofree char *outputstr =3D NULL; virCommand *cmd; - virLXCDriverConfig *cfg =3D virLXCDriverGetConfig(driver); + g_autoptr(virLXCDriverConfig) cfg =3D virLXCDriverGetConfig(driver); =20 cmd =3D virCommandNew(vm->def->emulator); =20 @@ -1020,7 +1015,6 @@ virLXCProcessBuildControllerCmd(virLXCDriver *driver, virCommandRequireHandshake(cmd); =20 cleanup: - virObjectUnref(cfg); return cmd; error: virCommandFree(cmd); @@ -1209,7 +1203,7 @@ int virLXCProcessStart(virConnectPtr conn, virLXCDomainObjPrivate *priv =3D vm->privateData; g_autoptr(virCaps) caps =3D NULL; virErrorPtr err =3D NULL; - virLXCDriverConfig *cfg =3D virLXCDriverGetConfig(driver); + g_autoptr(virLXCDriverConfig) cfg =3D virLXCDriverGetConfig(driver); g_autoptr(virCgroup) selfcgroup =3D NULL; int status; g_autofree char *pidfile =3D NULL; @@ -1578,7 +1572,6 @@ int virLXCProcessStart(virConnectPtr conn, VIR_FORCE_CLOSE(ttyFDs[i]); for (i =3D 0; i < G_N_ELEMENTS(handshakefds); i++) VIR_FORCE_CLOSE(handshakefds[i]); - virObjectUnref(cfg); =20 virErrorRestore(&err); =20 @@ -1689,7 +1682,7 @@ virLXCProcessReconnectDomain(virDomainObj *vm, { virLXCDriver *driver =3D opaque; virLXCDomainObjPrivate *priv; - virLXCDriverConfig *cfg =3D virLXCDriverGetConfig(driver); + g_autoptr(virLXCDriverConfig) cfg =3D virLXCDriverGetConfig(driver); int ret =3D -1; =20 virObjectLock(vm); @@ -1752,7 +1745,6 @@ virLXCProcessReconnectDomain(virDomainObj *vm, =20 ret =3D 0; cleanup: - virObjectUnref(cfg); virObjectUnlock(vm); return ret; =20 --=20 2.31.1 From nobody Sun Apr 28 19:11:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639152727; cv=none; d=zohomail.com; s=zohoarc; b=NGWZpvQNELWT8cIlznzSjLldyobk5MnQsd4xitShuJ1EoEJNjZTiVKqpIpuJPfj2GWcFQ3qB9BrYOZAW6zltp4158Wb42BOeRnQFK3NnkbfpHyvH/WtwiiD+/subtgohU3hN8U867zQvty1wxeGYaFKbhOz9I56/q36XLKHUrq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639152727; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WrHRUC0IRHsJqeNHiiSHbgWbB4JvMg8SOKoYx2GeJ2Y=; b=LIpWuDVofHWVHvGd89Q+gcJom1J3tAdQwR8/o+6gGuLAoGwxJN2wy3RsHDpMwPv1SyrfYhbgAy6wlFAtwWvK805C1GOA0LydxQM6fur+H6l+l9srVZfF/5njo6URT1WTWy4PhrGB8SFjywFliUZ5FbXPBZmyL8maOjuwoLUwqtk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1639152727049503.51603551126345; Fri, 10 Dec 2021 08:12:07 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-223-y3cXPyJcNsWTzpkwB4BncQ-1; Fri, 10 Dec 2021 11:12:02 -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 58C1310151E6; Fri, 10 Dec 2021 16:11:56 +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 2D7E2694DE; Fri, 10 Dec 2021 16:11: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 F15101809C88; Fri, 10 Dec 2021 16:11:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BAG6PVG015254 for ; Fri, 10 Dec 2021 11:06:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 12B6360BF4; Fri, 10 Dec 2021 16:06:25 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8ECC260C04 for ; Fri, 10 Dec 2021 16:06:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639152726; 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=WrHRUC0IRHsJqeNHiiSHbgWbB4JvMg8SOKoYx2GeJ2Y=; b=Z6VOgikF/IJVNlru8HiubjqD3lAT6IcXCwTlCvPLjmfZz7ce1Y3dLaL5vSO5IzcAkm02TG MQ44BAE2Xd/zEjPSlSGoFeW3qSrfCllRSWOXRSWMiFxYvgQfYEsDhr3SIS8xn8CxsE6W4v FgWLsvGCpVJZpUydUnikapp0P2EoESs= X-MC-Unique: y3cXPyJcNsWTzpkwB4BncQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 6/8] lxc: remove cleanup from lxcNodeGetSecurityModel Date: Fri, 10 Dec 2021 17:06:16 +0100 Message-Id: <92577aca038a7a17902749b540474d10e995db0e.1639152235.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639152728350100001 Return the values directly. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/lxc/lxc_driver.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 0d438de4a5..aa4bdd68ac 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1220,32 +1220,26 @@ static int lxcNodeGetSecurityModel(virConnectPtr co= nn, { virLXCDriver *driver =3D conn->privateData; g_autoptr(virCaps) caps =3D NULL; - int ret =3D 0; =20 memset(secmodel, 0, sizeof(*secmodel)); =20 - if (virNodeGetSecurityModelEnsureACL(conn) < 0) { - ret =3D -1; - goto cleanup; - } + if (virNodeGetSecurityModelEnsureACL(conn) < 0) + return -1; =20 - if (!(caps =3D virLXCDriverGetCapabilities(driver, false))) { - ret =3D -1; - goto cleanup; - } + if (!(caps =3D virLXCDriverGetCapabilities(driver, false))) + return -1; =20 /* we treat no driver as success, but simply return no data in *secmod= el */ if (caps->host.nsecModels =3D=3D 0 || caps->host.secModels[0].model =3D=3D NULL) - goto cleanup; + return 0; =20 if (virStrcpy(secmodel->model, caps->host.secModels[0].model, VIR_SECURITY_MODEL_BUFLEN) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("security model string exceeds max %d bytes"), VIR_SECURITY_MODEL_BUFLEN - 1); - ret =3D -1; - goto cleanup; + return -1; } =20 if (virStrcpy(secmodel->doi, caps->host.secModels[0].doi, @@ -1253,12 +1247,10 @@ static int lxcNodeGetSecurityModel(virConnectPtr co= nn, virReportError(VIR_ERR_INTERNAL_ERROR, _("security DOI string exceeds max %d bytes"), VIR_SECURITY_DOI_BUFLEN-1); - ret =3D -1; - goto cleanup; + return -1; } =20 - cleanup: - return ret; + return 0; } =20 =20 --=20 2.31.1 From nobody Sun Apr 28 19:11:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639152730; cv=none; d=zohomail.com; s=zohoarc; b=HPR/C9a5i2+9aPoSw7jQZlm07njhu0fJLkQ7zBxiofoF4LRPkvwhj1eSPqdszB1ZeW1OdDaciVpGhRYdsfh5spGXnNpF2MYY5tVXbnt/u8dkcbosA8QuWNK1nKyDUK6SMkl/jSvFChuqG0ZBznAMPN0TKBTWI4Ej7CnB9N2x7nc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639152730; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kdeDeZXaebJd6o5cIT0wisOs2g8W5iVdEtTSGkdUzjs=; b=LZJp1INc+i9DfxRQl2Ob4K9NSQbjNVT5JqhWhGGduKN/Z1Cno+Y6mpYdmUDspmLN+Mvbq+OJ/aLz8w5F0t/9/7gvokc3UW9ZUNtxmeCxVr5dyN8CYiJUiCt1MM5JRCNIhaGCKlKkR9/8W/z1ZFkSmyrstgF0No6s64snlVX3650= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1639152730016527.7400411395075; Fri, 10 Dec 2021 08:12:10 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-35-QQ5FnIs8PTCkbPyb1oWEvA-1; Fri, 10 Dec 2021 11:12:07 -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 D73A91015214; Fri, 10 Dec 2021 16:11:58 +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 92DC1781FF; Fri, 10 Dec 2021 16:11:58 +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 618281809CBF; Fri, 10 Dec 2021 16:11:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BAG6PEG015267 for ; Fri, 10 Dec 2021 11:06:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id D8E2560C04; Fri, 10 Dec 2021 16:06:25 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60A3960C4A for ; Fri, 10 Dec 2021 16:06:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639152728; 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=kdeDeZXaebJd6o5cIT0wisOs2g8W5iVdEtTSGkdUzjs=; b=KlZZzZTSOU1aephyCxMX3ZqVupDcJeL3h5SBPJ84rKLLDel4ciI/7sVyYmCgpqPCDoBwii 4MZ6zARQ4rz8j9VKFbSxDH5FSWXxqvP8sq5KRHgFAMbXmvNAJWfrBP1Clx0DiW+sYvxDGo G0nK1KjE5ANJSVNSJ0nNw8BU0/hGRW8= X-MC-Unique: QQ5FnIs8PTCkbPyb1oWEvA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 7/8] bhyve: bhyveConnectCompareCPU: remove cleanup label Date: Fri, 10 Dec 2021 17:06:17 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639152731703100002 Return the desired values directly and clean up the redundant else branches. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_driver.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index e445c8cadf..cb1544665e 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -1431,7 +1431,6 @@ bhyveConnectCompareCPU(virConnectPtr conn, unsigned int flags) { struct _bhyveConn *driver =3D conn->privateData; - int ret =3D VIR_CPU_COMPARE_ERROR; g_autoptr(virCaps) caps =3D NULL; bool failIncompatible; bool validateXML; @@ -1441,30 +1440,27 @@ bhyveConnectCompareCPU(virConnectPtr conn, VIR_CPU_COMPARE_ERROR); =20 if (virConnectCompareCPUEnsureACL(conn) < 0) - goto cleanup; + return VIR_CPU_COMPARE_ERROR; =20 failIncompatible =3D !!(flags & VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATI= BLE); validateXML =3D !!(flags & VIR_CONNECT_COMPARE_CPU_VALIDATE_XML); =20 if (!(caps =3D bhyveDriverGetCapabilities(driver))) - goto cleanup; + return VIR_CPU_COMPARE_ERROR; =20 if (!caps->host.cpu || !caps->host.cpu->model) { if (failIncompatible) { virReportError(VIR_ERR_CPU_INCOMPATIBLE, "%s", _("cannot get host CPU capabilities")); - } else { - VIR_WARN("cannot get host CPU capabilities"); - ret =3D VIR_CPU_COMPARE_INCOMPATIBLE; + return VIR_CPU_COMPARE_ERROR; } - } else { - ret =3D virCPUCompareXML(caps->host.arch, caps->host.cpu, - xmlDesc, failIncompatible, validateXML); + VIR_WARN("cannot get host CPU capabilities"); + return VIR_CPU_COMPARE_INCOMPATIBLE; } =20 - cleanup: - return ret; + return virCPUCompareXML(caps->host.arch, caps->host.cpu, + xmlDesc, failIncompatible, validateXML); } =20 static int --=20 2.31.1 From nobody Sun Apr 28 19:11:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639152731; cv=none; d=zohomail.com; s=zohoarc; b=RQBpaDkPUL8D89+coTI04EZNJZr1TlL+wbfn6lNsojNGM4wDKWI0hr3z7J072JUrMSN6IW3F3VSGzqa5ClHxfw+sC16Plyq9HsRBduQd2Uo7FeR9cEvIYpA6yi6VQ+uyUEJyTU6dlpX+OUouh3xFf4f8thK+6H5yq0tzmVGldfk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639152731; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Co87OhRjdqoQIg7NniOqo/SHUeiUnUjTPBdP7LeQOow=; b=FbS67GOj+PPJg9rcQm+8Wm33MiT5XiivXx0WteFKR9HvJOneDGAIL5vVnjNsmrzFxYdXU2yuTuuBbTK0itQ9b0CGqB+M5itHvdMSCxgiwsh0zrfFiZJSRvDs8ROCo7mly0tgf8I5t4m1x+9z5hBlG3m+pwp6pUaDFek97Co/424= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 163915273143499.08284378404255; Fri, 10 Dec 2021 08:12:11 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-336--iwP2HWBN0CZIJC2uO_jTw-1; Fri, 10 Dec 2021 11:12:06 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 389021015208; Fri, 10 Dec 2021 16:12:01 +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 1A9EA5D9D5; Fri, 10 Dec 2021 16:12:01 +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 DDBC24A706; Fri, 10 Dec 2021 16:12:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BAG6QXb015284 for ; Fri, 10 Dec 2021 11:06:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id D2BE060BF4; Fri, 10 Dec 2021 16:06:26 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33AB160C4A for ; Fri, 10 Dec 2021 16:06:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639152730; 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=Co87OhRjdqoQIg7NniOqo/SHUeiUnUjTPBdP7LeQOow=; b=gRzfay2b84TpG80vUeF9khInCXME8HTAmGEIECJWYUcVGAdCyZ1GJsxtTlfPF0hokpcCYn DG0hxPxd1xHEml54YTtdyU4+ypAz+XaW5o84x70+WJxgO0pw/J5cETb4e5EaepR60omulW La2emX7/JxZwbQrr7hgw4tKD6DFavKQ= X-MC-Unique: -iwP2HWBN0CZIJC2uO_jTw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 8/8] Remove empty cleanup sections Date: Fri, 10 Dec 2021 17:06:18 +0100 Message-Id: <979b608af9dd21b721e220598c3c72be47af066c.1639152235.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639152732311100005 After recent cleanups, there are some pointless cleanup sections. Clean them up. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_driver.c | 19 +++++----------- src/ch/ch_conf.c | 9 +++----- src/hyperv/hyperv_driver.c | 5 +---- src/libxl/libxl_capabilities.c | 9 +++----- src/libxl/libxl_conf.c | 11 +++------ src/libxl/xen_common.c | 8 ++----- src/libxl/xen_xl.c | 32 +++++++++----------------- src/lxc/lxc_conf.c | 13 +++++------ src/lxc/lxc_container.c | 12 ++++------ src/lxc/lxc_driver.c | 12 ++++------ src/lxc/lxc_native.c | 41 ++++++++++++---------------------- src/lxc/lxc_process.c | 19 +++++----------- src/test/test_driver.c | 9 +++----- src/util/vircgroup.c | 12 ++++------ src/util/virfirmware.c | 18 +++++---------- src/vz/vz_driver.c | 15 +++++-------- tests/qemucaps2xmltest.c | 9 +++----- tests/vboxsnapshotxmltest.c | 8 ++----- tests/virconftest.c | 24 +++++++++----------- tests/virfiletest.c | 14 +++++------- tests/virstringtest.c | 16 +++++-------- 21 files changed, 106 insertions(+), 209 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index cb1544665e..21407a3957 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -141,7 +141,6 @@ bhyveConnectGetCapabilities(virConnectPtr conn) { struct _bhyveConn *privconn =3D conn->privateData; g_autoptr(virCaps) caps =3D NULL; - char *xml =3D NULL; =20 if (virConnectGetCapabilitiesEnsureACL(conn) < 0) return NULL; @@ -149,14 +148,10 @@ bhyveConnectGetCapabilities(virConnectPtr conn) if (!(caps =3D bhyveDriverGetCapabilities(privconn))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unable to get Capabilities")); - goto cleanup; + return NULL; } =20 - if (!(xml =3D virCapabilitiesFormatXML(caps))) - goto cleanup; - - cleanup: - return xml; + return virCapabilitiesFormatXML(caps); } =20 static virDomainObj * @@ -1558,7 +1553,6 @@ bhyveConnectDomainXMLFromNative(virConnectPtr conn, const char *nativeConfig, unsigned int flags) { - char *xml =3D NULL; g_autoptr(virDomainDef) def =3D NULL; struct _bhyveConn *privconn =3D conn->privateData; unsigned bhyveCaps =3D bhyveDriverGetBhyveCaps(privconn); @@ -1571,18 +1565,15 @@ bhyveConnectDomainXMLFromNative(virConnectPtr conn, if (STRNEQ(nativeFormat, BHYVE_CONFIG_FORMAT_ARGV)) { virReportError(VIR_ERR_INVALID_ARG, _("unsupported config type %s"), nativeFormat); - goto cleanup; + return NULL; } =20 def =3D bhyveParseCommandLineString(nativeConfig, bhyveCaps, privconn->xmlopt); if (def =3D=3D NULL) - goto cleanup; + return NULL; =20 - xml =3D virDomainDefFormat(def, privconn->xmlopt, 0); - - cleanup: - return xml; + return virDomainDefFormat(def, privconn->xmlopt, 0); } =20 static char * diff --git a/src/ch/ch_conf.c b/src/ch/ch_conf.c index a9cbbca560..98f1e89003 100644 --- a/src/ch/ch_conf.c +++ b/src/ch/ch_conf.c @@ -57,13 +57,13 @@ virCaps *virCHDriverCapsInit(void) =20 if ((caps =3D virCapabilitiesNew(virArchFromHost(), false, false)) =3D=3D NULL) - goto cleanup; + return NULL; =20 if (!(caps->host.numa =3D virCapabilitiesHostNUMANewHost())) - goto cleanup; + return NULL; =20 if (virCapabilitiesInitCaches(caps) < 0) - goto cleanup; + return NULL; =20 guest =3D virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, caps->host.arch, NULL, NULL, 0, NULL); @@ -71,9 +71,6 @@ virCaps *virCHDriverCapsInit(void) virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM, NULL, NULL, 0, NULL); return g_steal_pointer(&caps); - - cleanup: - return NULL; } =20 /** diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 4d938f4d7f..3327f0132e 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -271,7 +271,7 @@ hypervCapsInit(hypervPrivate *priv) return NULL; =20 if (hypervLookupHostSystemBiosUuid(priv, caps->host.host_uuid) < 0) - goto error; + return NULL; =20 /* i686 caps */ guest =3D virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARC= H_I686, @@ -288,9 +288,6 @@ hypervCapsInit(hypervPrivate *priv) NULL, NULL, 0, NULL); =20 return g_steal_pointer(&caps); - - error: - return NULL; } =20 =20 diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c index 9084dacb40..970ad37306 100644 --- a/src/libxl/libxl_capabilities.c +++ b/src/libxl/libxl_capabilities.c @@ -645,18 +645,15 @@ libxlMakeCapabilities(libxl_ctx *ctx) return NULL; =20 if (libxlCapsInitHost(ctx, caps) < 0) - goto error; + return NULL; =20 if (libxlCapsInitNuma(ctx, caps) < 0) - goto error; + return NULL; =20 if (libxlCapsInitGuests(ctx, caps) < 0) - goto error; + return NULL; =20 return g_steal_pointer(&caps); - - error: - return NULL; } =20 /* diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index f37c228139..1ac6253ad7 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1891,7 +1891,6 @@ libxlDriverGetDom0MaxmemConf(libxlDriverConfig *cfg, size_t i; size_t j; libxl_physinfo physinfo; - int ret =3D -1; =20 if (cfg->verInfo->commandline =3D=3D NULL || !(cmd_tokens =3D g_strsplit(cfg->verInfo->commandline, " ", 0))) @@ -1931,8 +1930,7 @@ libxlDriverGetDom0MaxmemConf(libxlDriverConfig *cfg, } } *maxmem =3D *maxmem * multiplier; - ret =3D 0; - goto cleanup; + return 0; } } } @@ -1942,14 +1940,11 @@ libxlDriverGetDom0MaxmemConf(libxlDriverConfig *cfg, libxl_physinfo_init(&physinfo); if (libxl_get_physinfo(cfg->ctx, &physinfo)) { VIR_WARN("libxl_get_physinfo failed"); - goto cleanup; + return -1; } *maxmem =3D (physinfo.total_pages * cfg->verInfo->pagesize) / 1024; libxl_physinfo_dispose(&physinfo); - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index 32c31d240e..e68ca1cde3 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -1575,19 +1575,15 @@ xenMakeIPList(virNetDevIPInfo *guestIP) { size_t i; g_auto(GStrv) address_array =3D NULL; - char *ret =3D NULL; =20 address_array =3D g_new0(char *, guestIP->nips + 1); =20 for (i =3D 0; i < guestIP->nips; i++) { address_array[i] =3D virSocketAddrFormat(&guestIP->ips[i]->address= ); if (!address_array[i]) - goto cleanup; + return NULL; } - ret =3D g_strjoinv(" ", address_array); - - cleanup: - return ret; + return g_strjoinv(" ", address_array); } =20 static int diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 8aba115d96..7604e3d534 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -248,7 +248,6 @@ xenParseXLCPUID(virConf *conf, virDomainDef *def) g_autofree char *cpuid_str =3D NULL; g_auto(GStrv) cpuid_pairs =3D NULL; size_t i; - int ret =3D -1; int policy; =20 if (xenConfigGetString(conf, "cpuid", &cpuid_str, NULL) < 0) @@ -267,29 +266,27 @@ xenParseXLCPUID(virConf *conf, virDomainDef *def) =20 cpuid_pairs =3D g_strsplit(cpuid_str, ",", 0); if (!cpuid_pairs) - goto cleanup; + return -1; =20 - if (!cpuid_pairs[0]) { - ret =3D 0; - goto cleanup; - } + if (!cpuid_pairs[0]) + return 0; =20 if (STRNEQ(cpuid_pairs[0], "host")) { virReportError(VIR_ERR_CONF_SYNTAX, _("cpuid starting with %s is not supported, only li= bxl format is"), cpuid_pairs[0]); - goto cleanup; + return -1; } =20 for (i =3D 1; cpuid_pairs[i]; i++) { g_auto(GStrv) name_and_value =3D g_strsplit(cpuid_pairs[i], "=3D",= 2); if (!name_and_value) - goto cleanup; + return -1; if (!name_and_value[0] || !name_and_value[1]) { virReportError(VIR_ERR_CONF_SYNTAX, _("Invalid libxl cpuid key=3Dvalue element: %s"= ), cpuid_pairs[i]); - goto cleanup; + return -1; } if (STREQ(name_and_value[1], "1")) { policy =3D VIR_CPU_FEATURE_FORCE; @@ -305,19 +302,16 @@ xenParseXLCPUID(virConf *conf, virDomainDef *def) virReportError(VIR_ERR_CONF_SYNTAX, _("Invalid libxl cpuid value: %s"), cpuid_pairs[i]); - goto cleanup; + return -1; } =20 if (virCPUDefAddFeature(def->cpu, xenTranslateCPUFeature(name_and_value[0], = true), policy) < 0) - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -1292,7 +1286,6 @@ xenFormatXLCPUID(virConf *conf, virDomainDef *def) g_auto(GStrv) cpuid_pairs =3D NULL; g_autofree char *cpuid_string =3D NULL; size_t i, j; - int ret =3D -1; =20 if (!def->cpu) return 0; @@ -1341,13 +1334,10 @@ xenFormatXLCPUID(virConf *conf, virDomainDef *def) cpuid_string =3D g_strjoinv(",", cpuid_pairs); =20 if (xenConfigSetString(conf, "cpuid", cpuid_string) < 0) - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index e9186b879e..8955578d54 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -65,14 +65,14 @@ virCaps *virLXCDriverCapsInit(virLXCDriver *driver) =20 if ((caps =3D virCapabilitiesNew(virArchFromHost(), false, false)) =3D=3D NULL) - goto error; + return NULL; =20 /* Some machines have problematic NUMA topology causing * unexpected failures. We don't want to break the lxc * driver in this scenario, so log errors & carry on */ if (!(caps->host.numa =3D virCapabilitiesHostNUMANewHost())) - goto error; + return NULL; =20 if (virCapabilitiesInitCaches(caps) < 0) VIR_WARN("Failed to get host CPU cache info"); @@ -89,13 +89,13 @@ virCaps *virLXCDriverCapsInit(virLXCDriver *driver) if (virGetHostUUID(caps->host.host_uuid)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot get the host uuid")); - goto error; + return NULL; } =20 if (!(lxc_path =3D virFileFindResource("libvirt_lxc", abs_top_builddir "/src", LIBEXECDIR))) - goto error; + return NULL; =20 guest =3D virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE, caps->host.arch, lxc_path, NULL, 0, NU= LL); @@ -130,7 +130,7 @@ virCaps *virLXCDriverCapsInit(virLXCDriver *driver) virCapabilitiesHostSecModelAddBaseLabel(&caps->host.secModels[= 0], type, label) < 0) - goto error; + return NULL; =20 VIR_DEBUG("Initialized caps for security driver \"%s\" with " "DOI \"%s\"", model, doi); @@ -139,9 +139,6 @@ virCaps *virLXCDriverCapsInit(virLXCDriver *driver) } =20 return g_steal_pointer(&caps); - - error: - return NULL; } =20 =20 diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 13f2fd4c29..1d5b9bf429 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -515,13 +515,12 @@ static int lxcContainerUnmountSubtree(const char *pre= fix, size_t i; int saveErrno; const char *failedUmount =3D NULL; - int ret =3D -1; =20 VIR_DEBUG("Unmount subtree from %s", prefix); =20 if (virFileGetMountReverseSubtree("/proc/mounts", prefix, &mounts, &nmounts) < 0) - goto cleanup; + return -1; for (i =3D 0; i < nmounts; i++) { VIR_DEBUG("Umount %s", mounts[i]); if (umount(mounts[i]) < 0) { @@ -540,7 +539,7 @@ static int lxcContainerUnmountSubtree(const char *prefi= x, virReportSystemError(saveErrno, _("Failed to unmount '%s' and could not d= etach subtree '%s'"), failedUmount, mounts[nmounts-1]); - goto cleanup; + return -1; } /* This unmounts the tmpfs on which the old root filesystem was ho= sted */ if (isOldRootFS && @@ -548,14 +547,11 @@ static int lxcContainerUnmountSubtree(const char *pre= fix, virReportSystemError(saveErrno, _("Failed to unmount '%s' and could not u= nmount old root '%s'"), failedUmount, mounts[nmounts-1]); - goto cleanup; + return -1; } } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int lxcContainerResolveSymlinks(virDomainFSDef *fs, bool gentle) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index aa4bdd68ac..fe583ccb76 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -928,7 +928,6 @@ static char *lxcConnectDomainXMLFromNative(virConnectPt= r conn, const char *nativeConfig, unsigned int flags) { - char *xml =3D NULL; g_autoptr(virDomainDef) def =3D NULL; virLXCDriver *driver =3D conn->privateData; g_autoptr(virCaps) caps =3D virLXCDriverGetCapabilities(driver, false); @@ -936,21 +935,18 @@ static char *lxcConnectDomainXMLFromNative(virConnect= Ptr conn, virCheckFlags(0, NULL); =20 if (virConnectDomainXMLFromNativeEnsureACL(conn) < 0) - goto cleanup; + return NULL; =20 if (STRNEQ(nativeFormat, LXC_CONFIG_FORMAT)) { virReportError(VIR_ERR_INVALID_ARG, _("unsupported config type %s"), nativeFormat); - goto cleanup; + return NULL; } =20 if (!(def =3D lxcParseConfigString(nativeConfig, caps, driver->xmlopt)= )) - goto cleanup; + return NULL; =20 - xml =3D virDomainDefFormat(def, driver->xmlopt, 0); - - cleanup: - return xml; + return virDomainDefFormat(def, driver->xmlopt, 0); } =20 /** diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index e9b58cbd1a..84ed33521f 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -119,7 +119,7 @@ static char ** lxcStringSplit(const char *string) } =20 if (!(parts =3D g_strsplit(tmp, " ", 0))) - goto error; + return NULL; =20 /* Append NULL element */ VIR_EXPAND_N(result, ntokens, 1); @@ -133,9 +133,6 @@ static char ** lxcStringSplit(const char *string) } =20 return g_steal_pointer(&result); - - error: - return NULL; } =20 static lxcFstab * @@ -250,7 +247,6 @@ lxcAddFstabLine(virDomainDef *def, lxcFstab *fstab) bool readonly; int type =3D VIR_DOMAIN_FS_TYPE_MOUNT; unsigned long long usage =3D 0; - int ret =3D -1; =20 if (!options) return -1; @@ -262,10 +258,8 @@ lxcAddFstabLine(virDomainDef *def, lxcFstab *fstab) } =20 /* Check that we don't add basic mounts */ - if (lxcIsBasicMountLocation(dst)) { - ret =3D 0; - goto cleanup; - } + if (lxcIsBasicMountLocation(dst)) + return 0; =20 if (STREQ(fstab->type, "tmpfs")) { char *sizeStr =3D NULL; @@ -275,14 +269,14 @@ lxcAddFstabLine(virDomainDef *def, lxcFstab *fstab) for (i =3D 0; options[i]; i++) { if ((sizeStr =3D STRSKIP(options[i], "size=3D"))) { if (lxcConvertSize(sizeStr, &usage) < 0) - goto cleanup; + return -1; break; } } if (!sizeStr) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing tmpfs size, set the size option")); - goto cleanup; + return -1; } } else { src =3D fstab->src; @@ -296,12 +290,9 @@ lxcAddFstabLine(virDomainDef *def, lxcFstab *fstab) readonly =3D g_strv_contains((const char **)options, "ro"); =20 if (lxcAddFSDef(def, type, src, dst, readonly, usage) < 0) - goto cleanup; + return -1; =20 - ret =3D 1; - - cleanup: - return ret; + return 1; } =20 static int @@ -961,7 +952,6 @@ lxcBlkioDeviceWalkCallback(const char *name, virConfVal= ue *value, void *data) virDomainDef *def =3D data; size_t i =3D 0; g_autofree char *path =3D NULL; - int ret =3D -1; =20 if (!STRPREFIX(name, "lxc.cgroup.blkio.") || STREQ(name, "lxc.cgroup.blkio.weight")|| !value->str) @@ -974,7 +964,7 @@ lxcBlkioDeviceWalkCallback(const char *name, virConfVal= ue *value, void *data) virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid %s value: '%s'"), name, value->str); - goto cleanup; + return -1; } =20 path =3D g_strdup_printf("/dev/block/%s", parts[0]); @@ -996,44 +986,41 @@ lxcBlkioDeviceWalkCallback(const char *name, virConfV= alue *value, void *data) if (virStrToLong_ui(parts[1], NULL, 10, &device->weight) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse device weight: '%s'"), parts= [1]); - goto cleanup; + return -1; } } else if (STREQ(name, "lxc.cgroup.blkio.throttle.read_bps_device")) { if (virStrToLong_ull(parts[1], NULL, 10, &device->rbps) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse read_bps_device: '%s'"), parts[1]); - goto cleanup; + return -1; } } else if (STREQ(name, "lxc.cgroup.blkio.throttle.write_bps_device")) { if (virStrToLong_ull(parts[1], NULL, 10, &device->wbps) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse write_bps_device: '%s'"), parts[1]); - goto cleanup; + return -1; } } else if (STREQ(name, "lxc.cgroup.blkio.throttle.read_iops_device")) { if (virStrToLong_ui(parts[1], NULL, 10, &device->riops) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse read_iops_device: '%s'"), parts[1]); - goto cleanup; + return -1; } } else if (STREQ(name, "lxc.cgroup.blkio.throttle.write_iops_device"))= { if (virStrToLong_ui(parts[1], NULL, 10, &device->wiops) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse write_iops_device: '%s'"), parts[1]); - goto cleanup; + return -1; } } else { VIR_WARN("Unhandled blkio tune config: %s", name); } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 9cae025517..625208c86b 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -361,7 +361,6 @@ virLXCProcessSetupInterfaceDirect(virLXCDriver *driver, virDomainDef *def, virDomainNetDef *net) { - char *ret =3D NULL; char *res_ifname =3D NULL; const virNetDevBandwidth *bw; const virNetDevVPortProfile *prof; @@ -407,12 +406,9 @@ virLXCProcessSetupInterfaceDirect(virLXCDriver *driver, cfg->stateDir, NULL, 0, macvlan_create_flags) < 0) - goto cleanup; + return NULL; =20 - ret =3D res_ifname; - - cleanup: - return ret; + return res_ifname; } =20 static const char *nsInfoLocal[VIR_LXC_DOMAIN_NAMESPACE_LAST] =3D { @@ -834,7 +830,7 @@ static virLXCMonitor *virLXCProcessConnectMonitor(virLX= CDriver *driver, g_autoptr(virLXCDriverConfig) cfg =3D virLXCDriverGetConfig(driver); =20 if (virSecurityManagerSetSocketLabel(driver->securityManager, vm->def)= < 0) - goto cleanup; + return NULL; =20 /* Hold an extra reference because we can't allow 'vm' to be * deleted while the monitor is active. This will be unreffed @@ -847,14 +843,11 @@ static virLXCMonitor *virLXCProcessConnectMonitor(vir= LXCDriver *driver, virObjectUnref(vm); =20 if (virSecurityManagerClearSocketLabel(driver->securityManager, vm->de= f) < 0) { - if (monitor) { + if (monitor) virObjectUnref(monitor); - monitor =3D NULL; - } - goto cleanup; + return NULL; } =20 - cleanup: return monitor; } =20 @@ -1015,7 +1008,7 @@ virLXCProcessBuildControllerCmd(virLXCDriver *driver, virCommandRequireHandshake(cmd); =20 cleanup: - return cmd; + return cmd; error: virCommandFree(cmd); cmd =3D NULL; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 020a9e5df0..0e93b79922 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -298,12 +298,12 @@ testBuildCapabilities(virConnectPtr conn) size_t i, j; =20 if ((caps =3D virCapabilitiesNew(VIR_ARCH_I686, false, false)) =3D=3D = NULL) - goto error; + return NULL; =20 if (virCapabilitiesAddHostFeature(caps, "pae") < 0) - goto error; + return NULL; if (virCapabilitiesAddHostFeature(caps, "nonpae") < 0) - goto error; + return NULL; =20 virCapabilitiesHostInitIOMMU(caps); =20 @@ -362,9 +362,6 @@ testBuildCapabilities(virConnectPtr conn) caps->host.secModels[0].doi =3D g_strdup(""); =20 return g_steal_pointer(&caps); - - error: - return NULL; } =20 =20 diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index bf8db47ad4..5cfc20f1ed 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -853,10 +853,9 @@ virCgroupSetPartitionSuffix(const char *path, char **r= es) { g_auto(GStrv) tokens =3D NULL; size_t i; - int ret =3D -1; =20 if (!(tokens =3D g_strsplit(path, "/", 0))) - return ret; + return -1; =20 for (i =3D 0; tokens[i] !=3D NULL; i++) { /* Special case the 3 top level fixed dirs @@ -878,16 +877,13 @@ virCgroupSetPartitionSuffix(const char *path, char **= res) } =20 if (virCgroupPartitionEscape(&(tokens[i])) < 0) - goto cleanup; + return -1; } =20 if (!(*res =3D g_strjoinv("/", tokens))) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 diff --git a/src/util/virfirmware.c b/src/util/virfirmware.c index cc5e315b7a..b2e3491544 100644 --- a/src/util/virfirmware.c +++ b/src/util/virfirmware.c @@ -58,11 +58,10 @@ virFirmwareFreeList(virFirmware **firmwares, size_t nfi= rmwares) int virFirmwareParse(const char *str, virFirmware *firmware) { - int ret =3D -1; g_auto(GStrv) token =3D NULL; =20 if (!(token =3D g_strsplit(str, ":", 0))) - goto cleanup; + return -1; =20 if (token[0]) { virSkipSpaces((const char **) &token[0]); @@ -76,15 +75,13 @@ virFirmwareParse(const char *str, virFirmware *firmware) virReportError(VIR_ERR_CONF_SYNTAX, _("Invalid nvram format: '%s'"), str); - goto cleanup; + return -1; } =20 firmware->name =3D g_strdup(token[0]); firmware->nvram =3D g_strdup(token[1]); =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -93,12 +90,11 @@ virFirmwareParseList(const char *list, virFirmware ***firmwares, size_t *nfirmwares) { - int ret =3D -1; g_auto(GStrv) token =3D NULL; size_t i, j; =20 if (!(token =3D g_strsplit(list, ":", 0))) - goto cleanup; + return -1; =20 for (i =3D 0; token[i]; i +=3D 2) { if (!token[i] || !token[i + 1] || @@ -106,7 +102,7 @@ virFirmwareParseList(const char *list, virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid --with-loader-nvram list: %s"), list); - goto cleanup; + return -1; } } =20 @@ -123,7 +119,5 @@ virFirmwareParseList(const char *list, } } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 1353efa6ab..c16cc2be00 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -115,32 +115,29 @@ vzBuildCapabilities(void) return NULL; =20 if (!(caps->host.numa =3D virCapabilitiesHostNUMANewHost())) - goto error; + return NULL; =20 if (virCapabilitiesInitCaches(caps) < 0) - goto error; + return NULL; =20 for (i =3D 0; i < G_N_ELEMENTS(ostypes); i++) for (j =3D 0; j < G_N_ELEMENTS(archs); j++) for (k =3D 0; k < G_N_ELEMENTS(emulators); k++) if (vzCapsAddGuestDomain(caps, ostypes[i], archs[j], emulators[k], virt_types[k]) < 0) - goto error; + return NULL; =20 if (virCapabilitiesGetNodeInfo(&nodeinfo)) - goto error; + return NULL; =20 if (!(caps->host.cpu =3D virCPUGetHost(caps->host.arch, VIR_CPU_TYPE_H= OST, &nodeinfo, NULL))) - goto error; + return NULL; =20 if (virCapabilitiesAddHostMigrateTransport(caps, "vzmigr") < 0) - goto error; + return NULL; =20 return g_steal_pointer(&caps); - - error: - return NULL; } =20 static void vzDriverDispose(void * obj) diff --git a/tests/qemucaps2xmltest.c b/tests/qemucaps2xmltest.c index aec4647678..942c8e7aa4 100644 --- a/tests/qemucaps2xmltest.c +++ b/tests/qemucaps2xmltest.c @@ -94,12 +94,12 @@ testGetCaps(char *capsData, const testQemuData *data) =20 if ((qemuCaps =3D testQemuGetCaps(capsData)) =3D=3D NULL) { fprintf(stderr, "failed to parse qemu capabilities flags"); - goto error; + return NULL; } =20 if ((caps =3D virCapabilitiesNew(arch, false, false)) =3D=3D NULL) { fprintf(stderr, "failed to create the fake capabilities"); - goto error; + return NULL; } =20 if (virQEMUCapsInitGuestFromBinary(caps, @@ -107,13 +107,10 @@ testGetCaps(char *capsData, const testQemuData *data) qemuCaps, arch) < 0) { fprintf(stderr, "failed to create the capabilities from qemu"); - goto error; + return NULL; } =20 return g_steal_pointer(&caps); - - error: - return NULL; } =20 static int diff --git a/tests/vboxsnapshotxmltest.c b/tests/vboxsnapshotxmltest.c index d69eb3fc24..3ad8298895 100644 --- a/tests/vboxsnapshotxmltest.c +++ b/tests/vboxsnapshotxmltest.c @@ -21,11 +21,10 @@ testFilterXML(char *xml) g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_auto(GStrv) xmlLines =3D NULL; char **xmlLine; - char *ret =3D NULL; =20 if (!(xmlLines =3D g_strsplit(xml, "\n", 0))) { VIR_FREE(xml); - goto cleanup; + return NULL; } VIR_FREE(xml); =20 @@ -36,10 +35,7 @@ testFilterXML(char *xml) virBufferStrcat(&buf, *xmlLine, "\n", NULL); } =20 - ret =3D virBufferContentAndReset(&buf); - - cleanup: - return ret; + return virBufferContentAndReset(&buf); } =20 static int diff --git a/tests/virconftest.c b/tests/virconftest.c index 32d3d8849b..3b203b6ae6 100644 --- a/tests/virconftest.c +++ b/tests/virconftest.c @@ -370,7 +370,6 @@ static int testConfParseStringList(const void *opaque G= _GNUC_UNUSED) "string_list =3D [\"foo\", \"bar\"]\n" \ "string =3D \"foo\"\n"; =20 - int ret =3D -1; g_autoptr(virConf) conf =3D virConfReadString(srcdata, 0); g_auto(GStrv) str =3D NULL; =20 @@ -380,50 +379,47 @@ static int testConfParseStringList(const void *opaque= G_GNUC_UNUSED) if (virConfGetValueType(conf, "string_list") !=3D VIR_CONF_LIST) { fprintf(stderr, "expected a list for 'string_list'\n"); - goto cleanup; + return -1; } =20 if (virConfGetValueStringList(conf, "string_list", false, &str) < 0) - goto cleanup; + return -1; =20 if (!str || g_strv_length(str) !=3D 2) { fprintf(stderr, "expected a 2 element list\n"); - goto cleanup; + return -1; } =20 if (STRNEQ_NULLABLE(str[0], "foo")) { fprintf(stderr, "Expected 'foo' got '%s'\n", str[0]); - goto cleanup; + return -1; } =20 if (STRNEQ_NULLABLE(str[1], "bar")) { fprintf(stderr, "Expected 'bar' got '%s'\n", str[1]); - goto cleanup; + return -1; } =20 =20 if (virConfGetValueStringList(conf, "string", false, &str) !=3D -1) { fprintf(stderr, "Expected error for 'string'\n"); - goto cleanup; + return -1; } =20 if (virConfGetValueStringList(conf, "string", true, &str) < 0) - goto cleanup; + return -1; =20 if (!str || g_strv_length(str) !=3D 1) { fprintf(stderr, "expected a 1 element list\n"); - goto cleanup; + return -1; } =20 if (STRNEQ_NULLABLE(str[0], "foo")) { fprintf(stderr, "Expected 'foo' got '%s'\n", str[0]); - goto cleanup; + return -1; } =20 - - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/virfiletest.c b/tests/virfiletest.c index 2fbece8f63..1e95c77d06 100644 --- a/tests/virfiletest.c +++ b/tests/virfiletest.c @@ -64,7 +64,6 @@ struct testFileGetMountSubtreeData { =20 static int testFileGetMountSubtree(const void *opaque) { - int ret =3D -1; g_auto(GStrv) gotmounts =3D NULL; size_t gotnmounts =3D 0; const struct testFileGetMountSubtreeData *data =3D opaque; @@ -74,21 +73,18 @@ static int testFileGetMountSubtree(const void *opaque) data->prefix, &gotmounts, &gotnmounts) < 0) - goto cleanup; + return -1; } else { if (virFileGetMountSubtree(data->path, data->prefix, &gotmounts, &gotnmounts) < 0) - goto cleanup; + return -1; } =20 - ret =3D testFileCheckMounts(data->prefix, - gotmounts, gotnmounts, - data->mounts, data->nmounts); - - cleanup: - return ret; + return testFileCheckMounts(data->prefix, + gotmounts, gotnmounts, + data->mounts, data->nmounts); } #endif /* ! defined WITH_MNTENT_H && defined WITH_GETMNTENT_R */ =20 diff --git a/tests/virstringtest.c b/tests/virstringtest.c index 77fcec5613..b406076020 100644 --- a/tests/virstringtest.c +++ b/tests/virstringtest.c @@ -129,7 +129,6 @@ testStringSearch(const void *opaque) const struct stringSearchData *data =3D opaque; g_auto(GStrv) matches =3D NULL; ssize_t nmatches; - int ret =3D -1; =20 nmatches =3D virStringSearch(data->str, data->regexp, data->maxMatches, &matches); @@ -138,7 +137,7 @@ testStringSearch(const void *opaque) if (nmatches !=3D -1) { fprintf(stderr, "expected error on %s but got %zd matches\n", data->str, nmatches); - goto cleanup; + return -1; } } else { size_t i; @@ -146,35 +145,32 @@ testStringSearch(const void *opaque) if (nmatches < 0) { fprintf(stderr, "expected %zu matches on %s but got error\n", data->expectNMatches, data->str); - goto cleanup; + return -1; } =20 if (nmatches !=3D data->expectNMatches) { fprintf(stderr, "expected %zu matches on %s but got %zd\n", data->expectNMatches, data->str, nmatches); - goto cleanup; + return -1; } =20 if (g_strv_length(matches) !=3D nmatches) { fprintf(stderr, "expected %zu matches on %s but got %u matches= \n", data->expectNMatches, data->str, g_strv_length(matches)); - goto cleanup; + return -1; } =20 for (i =3D 0; i < nmatches; i++) { if (STRNEQ(matches[i], data->expectMatches[i])) { fprintf(stderr, "match %zu expected '%s' but got '%s'\n", i, data->expectMatches[i], matches[i]); - goto cleanup; + return -1; } } } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 --=20 2.31.1