From nobody Mon Feb 9 12:29:21 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=1663577898; cv=none; d=zohomail.com; s=zohoarc; b=areeGPHwoEnuaSIpr+izAaKqg5rmZ8D1aVst8BnPkYawMiSuL9NefIU9YAViGj65ohM6oaa8Vq6JSsHf5UUlVkPSuGpS33i9ohSIaFpWDMSrAnhN0MOnF/pphvhWF+cm1KwIjTwcB31Oju5SJ/gGgBvAsziCPWUaP7fR51OkKmM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577898; 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=cTHkfCfs51HXcv6ahsYNfFi7r0piT8P5gKhwV5dE2Ik=; b=n8eKHHpDtD5HeqnJVfXL8MjBBnnfgajtAuc38zW6eicsuRmtg+hSxk+dmsIZNu6lLkK+uvPmIoeoIhvdfUdi6HLE5EPysrZfxPTeoXSafw36a0WnfJP5nbDwVOBxXwGF1xw2DKHTDTHoC++A7t1SdeSEGUhl8gPXz9OZwD1MbfY= 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 166357789892444.75760273794833; Mon, 19 Sep 2022 01:58:18 -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-652-RzixbiLyNMWUC245PLX3Hg-1; Mon, 19 Sep 2022 04:55:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C957E29ABA05; Mon, 19 Sep 2022 08:55:28 +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 B693F2086F60; Mon, 19 Sep 2022 08:55:28 +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 A8B941946594; Mon, 19 Sep 2022 08:55:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A8D401946586 for ; Mon, 19 Sep 2022 08:55:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8B8C440C6EC3; Mon, 19 Sep 2022 08:55:27 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 02EC040C6EC2 for ; Mon, 19 Sep 2022 08:55:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577896; 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=cTHkfCfs51HXcv6ahsYNfFi7r0piT8P5gKhwV5dE2Ik=; b=gk8VljeWbQBi5rkmJ1Q2oj7weM/y9Cd7o0uhTC8paq54fC9f2lDZSWstp0qmIuGFtNANx/ eSMnzdG8O2/wcgJZ8JtZ5jWrtp667wTTffpJTa2tsAVs9BPXiG+5qJk5v0lTCLqFs3DUFS bmUSivfcKCtiN80RR3NRSl0oiEdcX5A= X-MC-Unique: RzixbiLyNMWUC245PLX3Hg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/37] virDomainNetDefParseXML: Remove unnecessary temporary variables Date: Mon, 19 Sep 2022 10:54:49 +0200 Message-Id: <72438bd1b2100138c71425bb3ed6a746fa0ac9ac.1663577577.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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.4 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: 1663577900153100001 Content-Type: text/plain; charset="utf-8" Some values were extracted into a temporary variable and then assigned to the definition later without a modification. Directly assign them instead. One slight modification was done to 'ifname' which was cleared in certain cases. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 45 ++++++++++++------------------------------ 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a544ab6ce4..390263d806 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8855,12 +8855,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *portid =3D NULL; g_autofree char *bridge =3D NULL; g_autofree char *dev =3D NULL; - g_autofree char *ifname =3D NULL; g_autofree char *managed_tap =3D NULL; - g_autofree char *ifname_guest =3D NULL; - g_autofree char *ifname_guest_actual =3D NULL; - g_autofree char *script =3D NULL; - g_autofree char *downscript =3D NULL; g_autofree char *address =3D NULL; g_autofree char *port =3D NULL; g_autofree char *localaddr =3D NULL; @@ -8871,7 +8866,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *mode =3D NULL; g_autofree char *linkstate =3D NULL; g_autofree char *addrtype =3D NULL; - g_autofree char *domain_name =3D NULL; g_autofree char *vhostuser_mode =3D NULL; g_autofree char *vhostuser_path =3D NULL; g_autofree char *vhostuser_type =3D NULL; @@ -9005,16 +8999,16 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, } } - ifname =3D virXPathString("string(./target/@dev)", ctxt); + def->ifname =3D virXPathString("string(./target/@dev)", ctxt); managed_tap =3D virXPathString("string(./target/@managed)", ctxt); - ifname_guest =3D virXPathString("string(./guest/@dev)", ctxt); - ifname_guest_actual =3D virXPathString("string(./guest/@actual)", ctxt= ); + def->ifname_guest =3D virXPathString("string(./guest/@dev)", ctxt); + def->ifname_guest_actual =3D virXPathString("string(./guest/@actual)",= ctxt); linkstate =3D virXPathString("string(./link/@state)", ctxt); - script =3D virXPathString("string(./script/@path)", ctxt); - downscript =3D virXPathString("string(./downscript/@path)", ctxt); - domain_name =3D virXPathString("string(./backenddomain/@name)", ctxt); + def->script =3D virXPathString("string(./script/@path)", ctxt); + def->downscript =3D virXPathString("string(./downscript/@path)", ctxt); + def->domain_name =3D virXPathString("string(./backenddomain/@name)", c= txt); model =3D virXPathString("string(./model/@type)", ctxt); if ((driver_node =3D virXPathNode("./driver", ctxt)) && @@ -9374,28 +9368,15 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, def->managed_tap =3D virTristateBoolFromBool(state); } - if (def->managed_tap !=3D VIR_TRISTATE_BOOL_NO && ifname && + if (def->managed_tap !=3D VIR_TRISTATE_BOOL_NO && def->ifname && (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && - (STRPREFIX(ifname, VIR_NET_GENERATED_VNET_PREFIX) || - STRPREFIX(ifname, VIR_NET_GENERATED_MACVTAP_PREFIX) || - STRPREFIX(ifname, VIR_NET_GENERATED_MACVLAN_PREFIX) || - (prefix && STRPREFIX(ifname, prefix)))) { + (STRPREFIX(def->ifname, VIR_NET_GENERATED_VNET_PREFIX) || + STRPREFIX(def->ifname, VIR_NET_GENERATED_MACVTAP_PREFIX) || + STRPREFIX(def->ifname, VIR_NET_GENERATED_MACVLAN_PREFIX) || + (prefix && STRPREFIX(def->ifname, prefix)))) { /* An auto-generated target name, blank it out */ - VIR_FREE(ifname); - } - - if (script !=3D NULL) - def->script =3D g_steal_pointer(&script); - if (downscript !=3D NULL) - def->downscript =3D g_steal_pointer(&downscript); - if (domain_name !=3D NULL) - def->domain_name =3D g_steal_pointer(&domain_name); - if (ifname !=3D NULL) - def->ifname =3D g_steal_pointer(&ifname); - if (ifname_guest !=3D NULL) - def->ifname_guest =3D g_steal_pointer(&ifname_guest); - if (ifname_guest_actual !=3D NULL) - def->ifname_guest_actual =3D g_steal_pointer(&ifname_guest_actual); + g_clear_pointer(&def->ifname, g_free); + } if (def->type !=3D VIR_DOMAIN_NET_TYPE_HOSTDEV && virDomainNetIsVirtioModel(def)) { --=20 2.37.1