From nobody Mon Feb 9 07:26:52 2026 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=1666621005; cv=none; d=zohomail.com; s=zohoarc; b=bt9UdfdGFMeCl6yyqq7tTWqcc5N6lit5QiFcrmtpqJ4iSS+Sbbfwt+twXMgzG6zt+TCGHW+UvwRhrUUOPPr9e6w4SaTbFoAarMbxC/ibnyKFGb/gQ/Dm63rVdOcXQ8qLXKsVogaAk1s7jBaiRanN0zIGjZWYZSjPqATPkbj0fSo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621005; 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=xi/svI7douv8A82OQCEPOc3mmCDU/Ml8qkFMTBwT/Bc=; b=PLIe5Csa01w3EN4tsOdTksyL4YkA0OSMicxD6GKYLoTVYU4X0CM2AG/QavzvGwv/DflkZFCEVG+C6ip3YPlS+bsAF8w+ZKxCcvlK45L/HlUQAgJEuQi/wKO+2Djo70o7Y/XTfvD0pz7X7iD2G/mrFIZS2lJ25A5P//VNMvQe/Zs= 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 1666621005005111.38097036919964; Mon, 24 Oct 2022 07:16:45 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-556-JMdMUgK4MRqgA0L2no07gQ-1; Mon, 24 Oct 2022 10:16:35 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5BC9F3803914; Mon, 24 Oct 2022 14:15:43 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47C0C2028E94; Mon, 24 Oct 2022 14:15:43 +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 3267519465A2; Mon, 24 Oct 2022 14:15:43 +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 77FC81946594 for ; Mon, 24 Oct 2022 14:15:42 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 66A5440C2088; Mon, 24 Oct 2022 14:15:42 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id B064040C83AD for ; Mon, 24 Oct 2022 14:15:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621004; 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=xi/svI7douv8A82OQCEPOc3mmCDU/Ml8qkFMTBwT/Bc=; b=XIoaorv9+pD/1IbiH5QU4Ce8LUcVR0b301Y/+AlNzuEZoskZWrbNdU3lU3niIIE+G6kRFy zjB9LkdQ4a9EfSRsZ4QuW793UrP61Bh8jpwTsyfwZ5CPNXHxaKjv+N8mkMbbWcsQiajJrD NELceWOFmtwMe1saEDAeR1pAYK6Wiig= X-MC-Unique: JMdMUgK4MRqgA0L2no07gQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 31/43] virDomainTimerDefParseXML: Refactor cleanup Date: Mon, 24 Oct 2022 16:14:36 +0200 Message-Id: <29de36013849f76616728e7f0b45576d82c31646.1666619795.git.pkrempa@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.4 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: 1666621006680100001 Content-Type: text/plain; charset="utf-8" Automatically free the 'def' variable and remove the 'cleanup' label. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ee9eb6bcc4..7c718ce799 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10542,7 +10542,7 @@ static virDomainTimerDef * virDomainTimerDefParseXML(xmlNodePtr node, xmlXPathContextPtr ctxt) { - virDomainTimerDef *def; + g_autofree virDomainTimerDef *def =3D g_new0(virDomainTimerDef, 1); VIR_XPATH_NODE_AUTORESTORE(ctxt) xmlNodePtr catchup; int ret; @@ -10551,33 +10551,31 @@ virDomainTimerDefParseXML(xmlNodePtr node, g_autofree char *track =3D NULL; g_autofree char *mode =3D NULL; - def =3D g_new0(virDomainTimerDef, 1); - ctxt->node =3D node; name =3D virXMLPropString(node, "name"); if (name =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing timer name")); - goto error; + return NULL; } if ((def->name =3D virDomainTimerNameTypeFromString(name)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown timer name '%s'"), name); - goto error; + return NULL; } if (virXMLPropTristateBool(node, "present", VIR_XML_PROP_NONE, &def->present) < 0) - goto error; + return NULL; tickpolicy =3D virXMLPropString(node, "tickpolicy"); if (tickpolicy !=3D NULL) { if ((def->tickpolicy =3D virDomainTimerTickpolicyTypeFromString(ti= ckpolicy)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown timer tickpolicy '%s'"), tickpolicy); - goto error; + return NULL; } } @@ -10586,7 +10584,7 @@ virDomainTimerDefParseXML(xmlNodePtr node, if ((def->track =3D virDomainTimerTrackTypeFromString(track)) <=3D= 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown timer track '%s'"), track); - goto error; + return NULL; } } @@ -10596,7 +10594,7 @@ virDomainTimerDefParseXML(xmlNodePtr node, } else if (ret < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("invalid timer frequency")); - goto error; + return NULL; } mode =3D virXMLPropString(node, "mode"); @@ -10604,7 +10602,7 @@ virDomainTimerDefParseXML(xmlNodePtr node, if ((def->mode =3D virDomainTimerModeTypeFromString(mode)) <=3D 0)= { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown timer mode '%s'"), mode); - goto error; + return NULL; } } @@ -10612,22 +10610,18 @@ virDomainTimerDefParseXML(xmlNodePtr node, if (catchup !=3D NULL) { if (virXMLPropULongLong(catchup, "threshold", 10, VIR_XML_PROP_NON= E, &def->catchup.threshold) < 0) - goto error; + return NULL; if (virXMLPropULongLong(catchup, "slew", 10, VIR_XML_PROP_NONE, &def->catchup.slew) < 0) - goto error; + return NULL; if (virXMLPropULongLong(catchup, "limit", 10, VIR_XML_PROP_NONE, &def->catchup.limit) < 0) - goto error; + return NULL; } - return def; - - error: - VIR_FREE(def); - return def; + return g_steal_pointer(&def); } --=20 2.37.3