From nobody Sun Feb 8 21:06:17 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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=1602074171; cv=none; d=zohomail.com; s=zohoarc; b=g9jvsdoqaOfHIG/9T2d0rdgz3JOriBlcla4sxNRWSVoYfcZg02CmwQiUslmMMvfOykw5i0AF8ubp6i5U2WrSCnnnwWljO8+pCdLU32+Smuss2+xizDeKt9hIsIRZoMavF1VdDzAvT3jR/JIbk/nnnupSe2gvLvjjmJMnPBq+E3k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602074171; 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=uYXXk+8gE7PsG6Cj3+I1T0fYhdYanOUPHnMt+cdSSrU=; b=Gh6QzLltn0GYqWIAEnwgq89OASPP/9JLRURhJMdiRiYS/0hsfOYj67SrCdUg/8OXFiKuWn1C32Gbs+LKw+E65vy6WZVdS1AQwBteVekqkC5sVrrJLRtCq/jmdE7ILl7dzZc3+zYFJFl2A0CR6Nx7kwPPHdVCp3q8+ArFngx7wFg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1602074171795675.9144522748827; Wed, 7 Oct 2020 05:36:11 -0700 (PDT) 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-538-zDiuZesbMS6c1euHkSbTFg-1; Wed, 07 Oct 2020 08:36:06 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8992981F000; Wed, 7 Oct 2020 12:35:59 +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 3A2C05C22E; Wed, 7 Oct 2020 12:35:59 +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 ED6108C7AC; Wed, 7 Oct 2020 12:35:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 097CZoVp012498 for ; Wed, 7 Oct 2020 08:35:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id F2A1D702E7; Wed, 7 Oct 2020 12:35:49 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B2157664C for ; Wed, 7 Oct 2020 12:35:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602074170; 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=uYXXk+8gE7PsG6Cj3+I1T0fYhdYanOUPHnMt+cdSSrU=; b=XklybphqfDRcgda0PDdmaAbU+ie99OpJAxPdOyr4OS9lqFz5ZENqawSqiVf1Wbx649GnZq Hl7/pfXD/p5A4wJJy/OuxNTs7jeooXl6YREj+bAXvv85csmS8LSs3yUa0zLE5DJziM+IcM ohVUXhf+0cTUs4Bx29owRPUM581/hQo= X-MC-Unique: zDiuZesbMS6c1euHkSbTFg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCHv2 13/16] qemuAgentGetInterfaceAddresses: turn ifname into char* Date: Wed, 7 Oct 2020 14:35:34 +0200 Message-Id: <6b12c315bca0a39c8e946dcba4326fa7fde70b90.1602074066.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.16 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) We only care about the first part of the 'ifname' string, splitting it is overkill. Instead, just replace the ':' with a '\0' in a copy of the string. This reduces the count of the varaibles containing some form of the interface name to two. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Jonathon Jongsma --- src/qemu/qemu_agent.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 06e143b0b9..5cb6257bfc 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2129,9 +2129,9 @@ qemuAgentGetInterfaceAddresses(virDomainInterfacePtr = **ifaces_ret, virJSONValuePtr tmp_iface) { virJSONValuePtr ip_addr_arr =3D NULL; - const char *hwaddr, *ifname_s, *name =3D NULL; + const char *hwaddr, *name =3D NULL; virDomainInterfacePtr iface =3D NULL; - g_auto(GStrv) ifname =3D NULL; + g_autofree char *ifname =3D NULL; size_t addrs_count =3D 0; size_t j; =20 @@ -2144,10 +2144,9 @@ qemuAgentGetInterfaceAddresses(virDomainInterfacePtr= **ifaces_ret, } =20 /* Handle interface alias (:) */ - ifname =3D virStringSplit(name, ":", 2); - ifname_s =3D ifname[0]; + ifname =3D g_strdelimit(g_strdup(name), ":", '\0'); =20 - iface =3D virHashLookup(ifaces_store, ifname_s); + iface =3D virHashLookup(ifaces_store, ifname); =20 /* If the hash table doesn't contain this iface, add it */ if (!iface) { @@ -2157,11 +2156,11 @@ qemuAgentGetInterfaceAddresses(virDomainInterfacePt= r **ifaces_ret, iface =3D g_new0(virDomainInterface, 1); (*ifaces_ret)[*ifaces_count - 1] =3D iface; =20 - if (virHashAddEntry(ifaces_store, ifname_s, iface) < 0) + if (virHashAddEntry(ifaces_store, ifname, iface) < 0) return -1; =20 iface->naddrs =3D 0; - iface->name =3D g_strdup(ifname_s); + iface->name =3D g_strdup(ifname); =20 hwaddr =3D virJSONValueObjectGetString(tmp_iface, "hardware-addres= s"); iface->hwaddr =3D g_strdup(hwaddr); --=20 2.26.2