From nobody Sun Feb 8 21:48:07 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=1667314991; cv=none; d=zohomail.com; s=zohoarc; b=mK8j1Pf5ba16W4W4DcDKx9oMCCVkuwYXozafrYlSSctN6hLmARr/d+d8+IW7uT3y1xQUsDnJGllb3vbydO2CpFpFX7QZ1Kb+O8NWd02mzVqSfnp3lWgPObTHqLnmnqtN06VD8oVwYrKqpOisZGQdUwwnQfSdiJD/+Rj/QnGMTUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667314991; 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=dVb/lck+teYa0EoMT76hA8kF+HUmfkAcOhBgUffRMyU=; b=UsstVPN2kp9SlFAJYVvDi0WVStrzMebHzKz1rfkl21GwMIK4ao84cssYtt8oZTd/who57WAo0Yvvgb2o95e9j54jYsYdf7XLUZAxdmiFbhCnHDGzwgi5DDjArVQKktNJi07h6F4Ey/hMyV8uga6KEVX6o/zyAJ3dBWRwfeGbXhc= 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 1667314991699172.1779009240314; Tue, 1 Nov 2022 08:03:11 -0700 (PDT) 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-526-06wc0fHaN8iuKE-LY1nU5A-1; Tue, 01 Nov 2022 11:03:03 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EB8D9185A7AF; Tue, 1 Nov 2022 15:02:53 +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 D782B492B18; Tue, 1 Nov 2022 15:02:53 +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 C4F5019465B3; Tue, 1 Nov 2022 15:02:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7C6E51946594 for ; Tue, 1 Nov 2022 15:02:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 606F52166BB3; Tue, 1 Nov 2022 15:02:52 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-3.brq.redhat.com [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42E262166B2D for ; Tue, 1 Nov 2022 15:02:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667314987; 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=dVb/lck+teYa0EoMT76hA8kF+HUmfkAcOhBgUffRMyU=; b=foUgYqQSBPt0yL2Nng8QI583n6VzGRq8cjvyA5ut6wo0DjhoxLha5cyWl+oHWkZZIawTi7 h7/PJdh+P1o00JKS9qm0uEencKj6NoKcwK85tSX7uECiEZnz7L1scKssBgshEueWBYV0c8 UIwycuzhPJia4m5hh4m2Vfg1Ydoe+NI= X-MC-Unique: 06wc0fHaN8iuKE-LY1nU5A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/11] conf: domain: Refactor cleanup in virSysinfoChassisParseXML Date: Tue, 1 Nov 2022 16:02:21 +0100 Message-Id: <4a5b28ed13bdb8b19eaa08237963270460dcd71a.1667314911.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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.10 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: 1667314994129100002 Content-Type: text/plain; charset="utf-8" Register automatic cleanup for virSysinfoChassisDef and use it to refactor the cleanup code paths in virSysinfoChassisParseXML. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 16 +++++----------- src/util/virsysinfo.h | 1 + 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 90478f2528..e10b4d72f8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12323,19 +12323,16 @@ virSysinfoChassisParseXML(xmlNodePtr node, virSysinfoChassisDef **chassisdef) { VIR_XPATH_NODE_AUTORESTORE(ctxt) - int ret =3D -1; - virSysinfoChassisDef *def; + g_autoptr(virSysinfoChassisDef) def =3D g_new0(virSysinfoChassisDef, 1= ); ctxt->node =3D node; if (!xmlStrEqual(node->name, BAD_CAST "chassis")) { virReportError(VIR_ERR_XML_ERROR, "%s", _("XML does not contain expected 'chassis' element"= )); - return ret; + return -1; } - def =3D g_new0(virSysinfoChassisDef, 1); - def->manufacturer =3D virXPathString("string(entry[@name=3D'manufactur= er'])", ctxt); def->version =3D virXPathString("string(entry[@name=3D'version'])", ct= xt); def->serial =3D virXPathString("string(entry[@name=3D'serial'])", ctxt= ); @@ -12343,14 +12340,11 @@ virSysinfoChassisParseXML(xmlNodePtr node, def->sku =3D virXPathString("string(entry[@name=3D'sku'])", ctxt); if (!def->manufacturer && !def->version && - !def->serial && !def->asset && !def->sku) { - g_clear_pointer(&def, virSysinfoChassisDefFree); - } + !def->serial && !def->asset && !def->sku) + return 0; *chassisdef =3D g_steal_pointer(&def); - ret =3D 0; - virSysinfoChassisDefFree(def); - return ret; + return 0; } diff --git a/src/util/virsysinfo.h b/src/util/virsysinfo.h index d9f15b06e2..5fa91d9611 100644 --- a/src/util/virsysinfo.h +++ b/src/util/virsysinfo.h @@ -147,6 +147,7 @@ void virSysinfoSystemDefFree(virSysinfoSystemDef *def); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virSysinfoSystemDef, virSysinfoSystemDefFree= ); void virSysinfoBaseBoardDefClear(virSysinfoBaseBoardDef *def); void virSysinfoChassisDefFree(virSysinfoChassisDef *def); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virSysinfoChassisDef, virSysinfoChassisDefFr= ee); void virSysinfoOEMStringsDefFree(virSysinfoOEMStringsDef *def); void virSysinfoDefFree(virSysinfoDef *def); --=20 2.37.3