From nobody Fri Oct 18 08:32:02 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=1683632760; cv=none; d=zohomail.com; s=zohoarc; b=dNiwEnBPuRNI6/71pyah7gNZunCVkxxZ1YywXjQH9kLaSYiUTEVxzQwzwu1eQ6L9W1Q0NThzv87SVcb5uBnMhI7sO3Vu/Bx/uo1lCChat19Q1t3iRSVYB8iY22rRoRwpkiHC/ggPfa6HXsrUNZW0LLXO6Emcw1OvJC65kMEV+9s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683632760; 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=zvsi7GqaEbOFrgsP7C53dnSaDIfhzXiLE2cESQUEp+M=; b=TAlVmTG0HTE3BgWO2day/3TuRzM/MRQxtAPjrvlP8sJbjz1/Jqqyz8UcpKWm86GkLbHVXUyIL+6WhD3H8Mr6dI5U/Va/STaK7XFtspUXnCcb1OpCxXjFZO4jxGEOFCIp0uInBWYD1S1OsJCrBCFnGgcmbPn7/BybUQpnouiEFbo= 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 1683632760307686.5522630006195; Tue, 9 May 2023 04:46:00 -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-509-fDfMhPgVPSS6zvOCalit5Q-1; Tue, 09 May 2023 07:45:56 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AA9FF1C0950D; Tue, 9 May 2023 11:45:52 +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 96095C084BB; Tue, 9 May 2023 11:45:52 +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 89FB119465BD; Tue, 9 May 2023 11:45:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 38CD119465BD for ; Tue, 9 May 2023 11:45:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2F0B3492C3F; Tue, 9 May 2023 11:45:51 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id A772C492C13 for ; Tue, 9 May 2023 11:45:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683632759; 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=zvsi7GqaEbOFrgsP7C53dnSaDIfhzXiLE2cESQUEp+M=; b=Lj4Kl8XVRAzsb92AHPeS4aN7nGj3D07ehnatUx3TO2icIzMzdTeG5lzmNf8bnRoZ4EyzLF 3d2NY09ImWKERlnpaDniOSP/KktInUGXHw5qKlHDEjPBvOR+PO4tFjCsx+e1hu3IXKs69E HgFYu0hRtqdgM332VMJuhLQv3PVbPdI= X-MC-Unique: fDfMhPgVPSS6zvOCalit5Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/5] conf: Register autoptr cleanup for 'virDomainSoundDef' and refactor virDomainSoundDefParseXML Date: Tue, 9 May 2023 13:45:45 +0200 Message-Id: <54a86f6c967a1ec76728d339f1ea543f169a0791.1683632707.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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.8 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: 1683632761792100009 Content-Type: text/plain; charset="utf-8" Use our modern cleanup path pattern. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 19 +++++++------------ src/conf/domain_conf.h | 1 + 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ac7165bad4..204b6a85e1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11654,16 +11654,15 @@ virDomainSoundDefParseXML(virDomainXMLOption *xml= opt, xmlXPathContextPtr ctxt, unsigned int flags) { - virDomainSoundDef *def; + g_autoptr(virDomainSoundDef) def =3D g_new0(virDomainSoundDef, 1); VIR_XPATH_NODE_AUTORESTORE(ctxt) xmlNodePtr audioNode; - def =3D g_new0(virDomainSoundDef, 1); ctxt->node =3D node; if (virXMLPropEnum(node, "model", virDomainSoundModelTypeFromString, VIR_XML_PROP_REQUIRED, &def->model) < 0) - goto error; + return NULL; if (virDomainSoundModelSupportsCodecs(def)) { int ncodecs; @@ -11672,7 +11671,7 @@ virDomainSoundDefParseXML(virDomainXMLOption *xmlop= t, /* parse the subelements for sound models that support it = */ ncodecs =3D virXPathNodeSet("./codec", ctxt, &codecNodes); if (ncodecs < 0) - goto error; + return NULL; if (ncodecs > 0) { size_t i; @@ -11682,7 +11681,7 @@ virDomainSoundDefParseXML(virDomainXMLOption *xmlop= t, for (i =3D 0; i < ncodecs; i++) { virDomainSoundCodecDef *codec =3D virDomainSoundCodecDefPa= rseXML(codecNodes[i]); if (codec =3D=3D NULL) - goto error; + return NULL; codec->cad =3D def->ncodecs; /* that will do for now */ def->codecs[def->ncodecs++] =3D codec; @@ -11695,17 +11694,13 @@ virDomainSoundDefParseXML(virDomainXMLOption *xml= opt, if (virXMLPropUInt(audioNode, "id", 10, VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, &def->audioId) < 0) - goto error; + return NULL; } if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags)= < 0) - goto error; - - return def; + return NULL; - error: - virDomainSoundDefFree(def); - return NULL; + return g_steal_pointer(&def); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 88aef29912..a04f7decc6 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3569,6 +3569,7 @@ void virDomainSoundCodecDefFree(virDomainSoundCodecDe= f *def); ssize_t virDomainSoundDefFind(const virDomainDef *def, const virDomainSoundDef *sound); void virDomainSoundDefFree(virDomainSoundDef *def); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainSoundDef, virDomainSoundDefFree); virDomainSoundDef *virDomainSoundDefRemove(virDomainDef *def, size_t idx); void virDomainAudioDefFree(virDomainAudioDef *def); void virDomainMemballoonDefFree(virDomainMemballoonDef *def); --=20 2.40.0