From nobody Mon Feb 9 09:47:20 2026 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=1668589942; cv=none; d=zohomail.com; s=zohoarc; b=m+yECz7PUuQCK2rSyRCVrF6bSjYoGPTImNmx3xn9nG/dB/CVPLna7zM5kDViFZUO1+wctA77Fdp209t73iLcV+p1Xdu2R0Yl96cHp/cXVUHVuDX5kk77XS7SxXiB4OBm2EwEixvcfKKK38V4o04CoB8OEBTuMdTMqrzQnip1nIE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668589942; 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=iVcg0iNsJAsAO6nQqwlImG4yKhlJe/dJH79CxWuAlwU=; b=f2CVOdf/GlzQPT7oR/krt0mX4saQWURL/zT+cwDxrP7BYs/Uj5HYicniCjnmtdhZC4Eozt53ZJGlQIahZrhK3MNGBTKf4iZmbJw0+D5V2E9ftNspAXjH4HXETimoQk4N2E7dS3Uz10Nihyaf9hJocQLyYbP6gq9UjDX94ycr49Q= 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 1668589942026608.081542235217; Wed, 16 Nov 2022 01:12:22 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-103-DbssUCePNby4AnwTT_fC1w-1; Wed, 16 Nov 2022 04:12:00 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B8CDD80600D; Wed, 16 Nov 2022 09:11:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 924C140C845A; Wed, 16 Nov 2022 09:11:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9E38A1946A61; Wed, 16 Nov 2022 09:11:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A548819465B1 for ; Wed, 16 Nov 2022 09:11:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 47933400E577; Wed, 16 Nov 2022 09:11:51 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id E035840C83D9 for ; Wed, 16 Nov 2022 09:11:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668589940; 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=iVcg0iNsJAsAO6nQqwlImG4yKhlJe/dJH79CxWuAlwU=; b=VluzE7G3F/YieQHkv4cIcbJDPXcs2T1HNZvFBoRh6WeLCZ5vc7MuZkk5AVo7r+k/UCTubd SdUy0ya8SRpHJzw0jFqo5nd9lZEZ2LL1l46WAwzgvSWS04ISO/L+tKmCG44VQnsgkrUKsV soF9lSviJqNQ4HOI1itW12uLxwsd3uY= X-MC-Unique: DbssUCePNby4AnwTT_fC1w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 7/7] conf: Declare and use autoptr for virDomainMemoryDef Date: Wed, 16 Nov 2022 10:11:45 +0100 Message-Id: <8135bdcad254fc0712e7ca6c373c52acc820ee0f.1668589451.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1668589942866100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Register virDomainMemoryDefFree() to do the cleanup. Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 24 ++++++++++-------------- src/conf/domain_conf.h | 1 + 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d3b8ef3656..3790121cf7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13245,7 +13245,7 @@ virDomainMemoryDefParseXML(virDomainXMLOption *xmlo= pt, { VIR_XPATH_NODE_AUTORESTORE(ctxt) xmlNodePtr node; - virDomainMemoryDef *def =3D NULL; + g_autoptr(virDomainMemoryDef) def =3D NULL; virDomainMemoryModel model; g_autofree char *tmp =3D NULL; =20 @@ -13254,17 +13254,17 @@ virDomainMemoryDefParseXML(virDomainXMLOption *xm= lopt, if (virXMLPropEnum(memdevNode, "model", virDomainMemoryModelTypeFromSt= ring, VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, &model) < 0) - goto error; + return NULL; =20 def =3D virDomainMemoryDefNew(model); =20 if (virXMLPropEnum(memdevNode, "access", virDomainMemoryAccessTypeFrom= String, VIR_XML_PROP_NONZERO, &def->access) < 0) - goto error; + return NULL; =20 if (virXMLPropTristateBool(memdevNode, "discard", VIR_XML_PROP_NONE, &def->discard) < 0) - goto error; + return NULL; =20 /* Extract NVDIMM UUID. */ if (def->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM && @@ -13274,34 +13274,30 @@ virDomainMemoryDefParseXML(virDomainXMLOption *xm= lopt, if (virUUIDParse(tmp, def->uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed uuid element")); - goto error; + return NULL; } } =20 /* source */ if ((node =3D virXPathNode("./source", ctxt)) && virDomainMemorySourceDefParseXML(node, ctxt, def) < 0) - goto error; + return NULL; =20 /* target */ if (!(node =3D virXPathNode("./target", ctxt))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing element for device")); - goto error; + return NULL; } =20 if (virDomainMemoryTargetDefParseXML(node, ctxt, def) < 0) - goto error; + return NULL; =20 if (virDomainDeviceInfoParseXML(xmlopt, memdevNode, ctxt, &def->info, flags) < 0) - goto error; + return NULL; =20 - return def; - - error: - virDomainMemoryDefFree(def); - return NULL; + return g_steal_pointer(&def); } =20 =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index d29ebf8b8a..a9f7e8d977 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2621,6 +2621,7 @@ struct _virDomainMemoryDef { =20 virDomainMemoryDef *virDomainMemoryDefNew(virDomainMemoryModel model); void virDomainMemoryDefFree(virDomainMemoryDef *def); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainMemoryDef, virDomainMemoryDefFree); =20 struct _virDomainIdMapEntry { unsigned int start; --=20 2.37.4