From nobody Sun Feb 8 14:41:48 2026 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=1685705468; cv=none; d=zohomail.com; s=zohoarc; b=e4SN/yhmIeleH5vbC1hmVRqlgR4hj10cnWrn3w+PTJOpy/ccXjxoJIK3/a8YqfoyN44CrWUkGtfRCVoNTBJwMVjyKlDS+9gPwsg8ATsmYI7NHPWO8oGgsiyNP74dy1FTjg/ZEbUiDM68MBpZddFYKvMS1a1r7A9vwhMUjuX3bRY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685705468; 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=NMR001TXzDM1YtceDELFwqV0rA5uWO6Rc81JminhlLo=; b=UJqr9QNyykGIsA0TuhkoUd78kdOuTxzzxxwC194OhrBtF4Zh4/sGthINbyhSktxEAKxFPyfxCKOOhR3wMHO3ns3KZY8idv8beeEWtcWpGRodoy/IaPFn0J7Gc4TaCNAlXCFyqZEsMWiuBr5z9H/Rf4eySQLBwbQQF3QalTl1juQ= 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 168570546872389.99038266759555; Fri, 2 Jun 2023 04:31:08 -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-144-yKG2cM7UPCKh6H9p1u4_1g-1; Fri, 02 Jun 2023 07:28:36 -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 E43248582BE; Fri, 2 Jun 2023 11:28:32 +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 CE828C154DA; Fri, 2 Jun 2023 11:28:32 +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 D0E0C1946F17; Fri, 2 Jun 2023 11:28:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1857E19465A8 for ; Fri, 2 Jun 2023 11:28:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EE5099E63; Fri, 2 Jun 2023 11:28:30 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E0668162 for ; Fri, 2 Jun 2023 11:28:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685705467; 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=NMR001TXzDM1YtceDELFwqV0rA5uWO6Rc81JminhlLo=; b=bap50zY4nFE084nGyqlIUWLlDI7kJdiZDxbVwWscqUodwm2SOLMsYfBswuJ/SOvTIpjc5Q MhYwkWUUoqVqrhtJfjnBByGUIPqRMbOWxFO/jshzSkJyYrON9wjiq4h0e2MU5DBe7ssRi4 xdtjNgejiKbti8uOZxwSHKOGnlIrdOo= X-MC-Unique: yKG2cM7UPCKh6H9p1u4_1g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/15] virNetworkDHCPDefParseXML: Refactor cleanup Date: Fri, 2 Jun 2023 13:28:15 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1685705470221100001 Content-Type: text/plain; charset="utf-8" There's nothing to clean up in the 'host' local variable on error as the function which fills it makes sure to fill it only on success. In such case it's also directly assigned to the array thus the 'host' variable is cleared. Remove the 'cleanup' label and 'ret' variable as we can now directly return -1 on error. Signed-off-by: Peter Krempa --- src/conf/network_conf.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 73011cb7a2..5add0ef902 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -605,7 +605,6 @@ virNetworkDHCPDefParseXML(const char *networkName, xmlNodePtr node, virNetworkIPDef *def) { - int ret =3D -1; xmlNodePtr cur; virNetworkDHCPRangeDef range; virNetworkDHCPHostDef host; @@ -619,7 +618,7 @@ virNetworkDHCPDefParseXML(const char *networkName, virXMLNodeNameEqual(cur, "range")) { if (virNetworkDHCPRangeDefParseXML(networkName, def, cur, &ran= ge) < 0) - goto cleanup; + return -1; VIR_APPEND_ELEMENT(def->ranges, def->nranges, range); } else if (cur->type =3D=3D XML_ELEMENT_NODE && @@ -627,7 +626,7 @@ virNetworkDHCPDefParseXML(const char *networkName, if (virNetworkDHCPHostDefParseXML(networkName, def, cur, &host, false) < 0) - goto cleanup; + return -1; VIR_APPEND_ELEMENT(def->hosts, def->nhosts, host); } else if (VIR_SOCKET_ADDR_IS_FAMILY(&def->address, AF_INET) && cur->type =3D=3D XML_ELEMENT_NODE && @@ -645,7 +644,7 @@ virNetworkDHCPDefParseXML(const char *networkName, if (server && virSocketAddrParse(&inaddr, server, AF_UNSPEC) < 0) { - goto cleanup; + return -1; } def->bootfile =3D g_steal_pointer(&file); @@ -655,10 +654,7 @@ virNetworkDHCPDefParseXML(const char *networkName, cur =3D cur->next; } - ret =3D 0; - cleanup: - virNetworkDHCPHostDefClear(&host); - return ret; + return 0; } --=20 2.40.1