From nobody Sun Feb 8 12:19:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1606245705; cv=none; d=zohomail.com; s=zohoarc; b=aYpBg63Xbs3EdLHqy/67528Q2/OvoiaELgwZd+OesG7dSbB/vDJ0j5Y8uTl4cDQGibC72/G9csTjmmvQtu6k7YjgpUQ59KRFxV3yrhWRQfBuvHchmOHEK3qaomaYaJoaW7p19xLGjl6INEoYoKmrbs2DyzsnWpPtaCet3FXXhO8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606245705; h=Content-Type:Content-Transfer-Encoding:Cc: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=/GPAm1L/gjnSUjpeKkvUX+h+a59V50TVYAVulNZmGds=; b=J3EjQFFEJKcG4iqeCsb72BtfMMYnGV8zeMlUARYjq5asyw92rJXWyfBANNoL49iFoZIsFr5INgyGuyWOMu7FYs4ZU385s9pJepkHaJGWgHjhfkMfc7p4EdBC5wIw6c/o3qmuJps8rFaY4RRmlWl6SJYa9Spwxg+7mqo7ZbYJ/0k= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1606245705095514.7810528557263; Tue, 24 Nov 2020 11:21:45 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-14-WdqeGokMNxStMUqrApJIOw-1; Tue, 24 Nov 2020 14:21:41 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 913BA805BF0; Tue, 24 Nov 2020 19:21:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6961619C46; Tue, 24 Nov 2020 19:21:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 33CA65003F; Tue, 24 Nov 2020 19:21:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AOJLVWx004539 for ; Tue, 24 Nov 2020 14:21:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id 084E9110F0D2; Tue, 24 Nov 2020 19:21:31 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0466B110F0CE for ; Tue, 24 Nov 2020 19:21:31 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E6081857D17 for ; Tue, 24 Nov 2020 19:21:30 +0000 (UTC) Received: from mail-qv1-f65.google.com (mail-qv1-f65.google.com [209.85.219.65]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-449-qW9wi-EmMe2cp8zhTzQ0iQ-1; Tue, 24 Nov 2020 14:21:27 -0500 Received: by mail-qv1-f65.google.com with SMTP id y11so11146859qvu.10 for ; Tue, 24 Nov 2020 11:21:27 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:d88a:482:7c39:5cca:96f6]) by smtp.gmail.com with ESMTPSA id l79sm88837qke.1.2020.11.24.11.21.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2020 11:21:26 -0800 (PST) X-MC-Unique: WdqeGokMNxStMUqrApJIOw-1 X-MC-Unique: qW9wi-EmMe2cp8zhTzQ0iQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/GPAm1L/gjnSUjpeKkvUX+h+a59V50TVYAVulNZmGds=; b=F3/LD7pxVWtWfGUG/KUc8Yl4evSCujHDx7oFk2mTmb58DT7e/YVJUNUeO1aI2k+Yf6 EHja9Yio1zaEZ9OK32JZXs4j1wHsgDLnYZ5RnFKpcCtEddn/R5VKsA7P21Qo4rdBhI7I 96858z/kfbLCFzvtHdKApHDjHkgpwlD3nv54N69RPB65smidN264bVF6f6LzEK6Wc0oG kvpk58kwFjEDavvpLxz7c0zlydGvNvG4633LsO6+zBKDLnhpelreo69PdUiBZIsGoaRQ bjR3SAfGIioshi4JRX+wxIFdOankG3nfZzfrWow/zbFz4Kpvk8R07QXABL9Ou/y2y7RP 9wLQ== X-Gm-Message-State: AOAM530gw87gIGjtxG1XBjTwCPI3oto0jJJn/jwjMtXeS+q2zPtPlx1s c92J7viafgrgYs6KL9NlZF77I46rmT8= X-Google-Smtp-Source: ABdhPJzkcObUXzLhpU4pgahbpO43fV2RsV2te4yH1LoONvYkP/9dxf/161W1qRuaj7Jb6Ll12Ltm7Q== X-Received: by 2002:a05:6214:b83:: with SMTP id fe3mr115741qvb.24.1606245686981; Tue, 24 Nov 2020 11:21:26 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 19/21] domain_conf.c: modernize virDomainDefControllersParse() Date: Tue, 24 Nov 2020 16:20:33 -0300 Message-Id: <20201124192035.2343063-20-danielhb413@gmail.com> In-Reply-To: <20201124192035.2343063-1-danielhb413@gmail.com> References: <20201124192035.2343063-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The 'error' label is just returning -1, so let's 'return -1' directly. Use g_autoptr() with virDomainControllerDefPtr to remove the need to call virDomainControllerDefFree() in the error path. There is no need to VIR_FREE(nodes) explictly since 'nodes' is using g_autofree. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5630f72096..b794611b1e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21819,38 +21819,36 @@ virDomainDefControllersParse(virDomainDefPtr def, int n; =20 if ((n =3D virXPathNodeSet("./devices/controller", ctxt, &nodes)) < 0) - goto error; + return -1; =20 if (n) def->controllers =3D g_new0(virDomainControllerDefPtr, n); =20 for (i =3D 0; i < n; i++) { - virDomainControllerDefPtr controller =3D virDomainControllerDefPar= seXML(xmlopt, - = nodes[i], - = ctxt, - = flags); + g_autoptr(virDomainControllerDef) controller =3D NULL; + + controller =3D virDomainControllerDefParseXML(xmlopt, nodes[i], + ctxt, flags); =20 if (!controller) - goto error; + return -1; =20 /* sanitize handling of "none" usb controller */ if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_USB) { if (controller->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_USB_N= ONE) { if (usb_other || *usb_none) { - virDomainControllerDefFree(controller); virReportError(VIR_ERR_XML_DETAIL, "%s", _("Can't add another USB controller: " "USB is disabled for this domain")); - goto error; + return -1; } *usb_none =3D true; } else { if (*usb_none) { - virDomainControllerDefFree(controller); virReportError(VIR_ERR_XML_DETAIL, "%s", _("Can't add another USB controller: " "USB is disabled for this domain")); - goto error; + return -1; } usb_other =3D true; } @@ -21859,20 +21857,16 @@ virDomainDefControllersParse(virDomainDefPtr def, usb_master =3D true; } =20 - virDomainControllerInsertPreAlloced(def, controller); + virDomainControllerInsertPreAlloced(def, g_steal_pointer(&controll= er)); } - VIR_FREE(nodes); =20 if (usb_other && !usb_master) { virReportError(VIR_ERR_XML_DETAIL, "%s", _("No master USB controller specified")); - goto error; + return -1; } =20 return 0; - - error: - return -1; } =20 static virDomainDefPtr --=20 2.26.2