From nobody Sun Feb 8 12:32:57 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=1667315001; cv=none; d=zohomail.com; s=zohoarc; b=cmNNhYkVnOjRUhwaRz1DplKlo/uCO7S+X/hV1bEkUWOc6YAGrtquiMQ73vaCSugKOerUD3wbjfruGifLyFlbPukyUgHQ9TSnxLcPSaOVngGNCDTW68fvDKysbu0RSfuj/Syj4Nx+l1MD6KqgaqIvPUX/vzacExJBCm7WUy3RF3Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667315001; 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=cx3prF0xW6ULg6EACbLHt5Bx5A7znQn81dMhBaSxQuA=; b=HYhtoYJeyABIy0V1vgchB8Pk1VgdjedbWnHxZhdGPON4bzHbqdFZAsWGT+gOmUSrm9rkFaWSRG98ZNSgQnrLIeNwrjAxZRabbl3HaqzQSUE2lbSkcCFwykoC1copBOHwFJxrRuv6kerpj19wcH0bplzt11Ch5yCKWq5co7AWIGY= 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 166731500148397.93633972776365; Tue, 1 Nov 2022 08:03:21 -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-589-H9xXc3XvOwioX-VmcW8xLQ-1; Tue, 01 Nov 2022 11:03:06 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D8DD6800B30; Tue, 1 Nov 2022 15:02:38 +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 C568540C94CE; Tue, 1 Nov 2022 15:02:38 +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 A4ACB19465B3; Tue, 1 Nov 2022 15:02:38 +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 E16591946594 for ; Tue, 1 Nov 2022 15:02:36 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D54722166BB6; Tue, 1 Nov 2022 15:02:36 +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 3B3682166B2D for ; Tue, 1 Nov 2022 15:02:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667314999; 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=cx3prF0xW6ULg6EACbLHt5Bx5A7znQn81dMhBaSxQuA=; b=IA+aB4OdJ6B84hZwtq+VO+R+FJtZ7r7MEhnDoM342eWNW0aZZ/IFQik/mcP9DjHl27pF0r AA8DqsfdQ47r2EeYyhjALfHeUKvBLJ4SnWI+8fq0076xcsswl3edTn4VsohoFL2Yp7BSht 0iG5/XcZ893qOEkLiHY4zZe/emO2Szg= X-MC-Unique: H9xXc3XvOwioX-VmcW8xLQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/11] conf: domain: Refactor cleanup in virSysinfoBIOSParseXML Date: Tue, 1 Nov 2022 16:02:15 +0100 Message-Id: <94e773b5eadebe43b291f884bfddfaa2d5010177.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.2 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: 1667315004148100002 Content-Type: text/plain; charset="utf-8" Register automatic cleanup for virSysinfoBIOSDef and use it to refactor the cleanup code paths in virSysinfoBIOSParseXML. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 19 ++++++------------- src/util/virsysinfo.h | 1 + 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7984a15c46..15db12876e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12136,19 +12136,16 @@ virSysinfoBIOSParseXML(xmlNodePtr node, virSysinfoBIOSDef **bios) { VIR_XPATH_NODE_AUTORESTORE(ctxt) - int ret =3D -1; - virSysinfoBIOSDef *def; + g_autoptr(virSysinfoBIOSDef) def =3D g_new0(virSysinfoBIOSDef, 1); ctxt->node =3D node; if (!virXMLNodeNameEqual(node, "bios")) { virReportError(VIR_ERR_XML_ERROR, "%s", _("XML does not contain expected 'bios' element")); - return ret; + return -1; } - def =3D g_new0(virSysinfoBIOSDef, 1); - def->vendor =3D virXPathString("string(entry[@name=3D'vendor'])", ctxt= ); def->version =3D virXPathString("string(entry[@name=3D'version'])", ct= xt); def->date =3D virXPathString("string(entry[@name=3D'date'])", ctxt); @@ -12173,20 +12170,16 @@ virSysinfoBIOSParseXML(xmlNodePtr node, (year < 0 || (year >=3D 100 && year < 1900))) { virReportError(VIR_ERR_XML_DETAIL, "%s", _("Invalid BIOS 'date' format")); - goto cleanup; + return -1; } } if (!def->vendor && !def->version && - !def->date && !def->release) { - g_clear_pointer(&def, virSysinfoBIOSDefFree); - } + !def->date && !def->release) + return 0; *bios =3D g_steal_pointer(&def); - ret =3D 0; - cleanup: - virSysinfoBIOSDefFree(def); - return ret; + return 0; } static int diff --git a/src/util/virsysinfo.h b/src/util/virsysinfo.h index 97e0e18ddf..899193dc81 100644 --- a/src/util/virsysinfo.h +++ b/src/util/virsysinfo.h @@ -142,6 +142,7 @@ struct _virSysinfoDef { virSysinfoDef *virSysinfoRead(void); void virSysinfoBIOSDefFree(virSysinfoBIOSDef *def); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virSysinfoBIOSDef, virSysinfoBIOSDefFree); void virSysinfoSystemDefFree(virSysinfoSystemDef *def); void virSysinfoBaseBoardDefClear(virSysinfoBaseBoardDef *def); void virSysinfoChassisDefFree(virSysinfoChassisDef *def); --=20 2.37.3