From nobody Sun Feb 8 09:12:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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=1571576208; cv=none; d=zoho.com; s=zohoarc; b=QLxPd/aVytXSbWhLALtA1DFUTaUHJbwRpBda0pLkfe0eeUVHdD6SzYnIQqapEj4tAOj3as1A2/KPTm5nacktnSFQUj56PaYF21tvCgKrd0vZTBeRosFiN7Kd/AGydXjBJ3iAlnYbdO6OIvkkLHsUn+3zQKjh3+jZmIUcWqVlMAs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576208; 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=G2sqoZUiM8OIyVjSMDynZtxkWlOoaccQaGzvES1goUQ=; b=KutZQ19vc9cxRpleUAPY4aIh4rU62A91bNU9Rr4UlgQaMVfE5R8pKrVBjGDL/c5O/RQLzzkbPPsqlv+EKv36k6VNgMrSYHG3+7eFodbI134e36Kt3gG1Td2mWOWgoyMiUq/YStj2zFP++8ZPIxTmCCLJGIRu/ojXJ/7eQVBtulc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1571576208017845.6144334284418; Sun, 20 Oct 2019 05:56:48 -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-148-th02_J51OQ-3q5cRPwZTzg-1; Sun, 20 Oct 2019 08:56:44 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B97001800E10; Sun, 20 Oct 2019 12:56:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8DD4D60619; Sun, 20 Oct 2019 12:56:39 +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 4F8801803B57; Sun, 20 Oct 2019 12:56:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCtuU7023493 for ; Sun, 20 Oct 2019 08:55:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 819BC3CC8; Sun, 20 Oct 2019 12:55:56 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id E530B194B9 for ; Sun, 20 Oct 2019 12:55:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576206; 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=G2sqoZUiM8OIyVjSMDynZtxkWlOoaccQaGzvES1goUQ=; b=Q+wqfGIXJG36VYt2sRNPy7eG+HB/+LlE0ySImLqzArbKphHntk0Gw2K1WW/qQOFwAHaIV5 tgMwtLYmqOWskg9/n0sY2ax/xPikjGK911oC0GkGdsIyBjnVdQivoyq7O7vkTqpflXX+Wp PmHlJdjRaCM9lv9+tHhkWJA1b88k+Nk= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:37 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 19/34] network: use g_strdup instead of VIR_STRDUP 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.13 X-MC-Unique: th02_J51OQ-3q5cRPwZTzg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko --- src/network/bridge_driver.c | 49 ++++++++++++------------------------- src/network/leaseshelper.c | 6 ++--- 2 files changed, 18 insertions(+), 37 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 9dce161937..fcaa6a48ae 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -739,19 +739,12 @@ networkStateInitialize(bool privileged, * /etc/libvirt/... && /var/(run|lib)/libvirt/... (system/privileged). */ if (privileged) { - if (VIR_STRDUP(network_driver->networkConfigDir, - SYSCONFDIR "/libvirt/qemu/networks") < 0 || - VIR_STRDUP(network_driver->networkAutostartDir, - SYSCONFDIR "/libvirt/qemu/networks/autostart") < 0 = || - VIR_STRDUP(network_driver->stateDir, - RUNSTATEDIR "/libvirt/network") < 0 || - VIR_STRDUP(network_driver->pidDir, - RUNSTATEDIR "/libvirt/network") < 0 || - VIR_STRDUP(network_driver->dnsmasqStateDir, - LOCALSTATEDIR "/lib/libvirt/dnsmasq") < 0 || - VIR_STRDUP(network_driver->radvdStateDir, - LOCALSTATEDIR "/lib/libvirt/radvd") < 0) - goto error; + network_driver->networkConfigDir =3D g_strdup(SYSCONFDIR "/libvirt= /qemu/networks"); + network_driver->networkAutostartDir =3D g_strdup(SYSCONFDIR "/libv= irt/qemu/networks/autostart"); + network_driver->stateDir =3D g_strdup(RUNSTATEDIR "/libvirt/networ= k"); + network_driver->pidDir =3D g_strdup(RUNSTATEDIR "/libvirt/network"= ); + network_driver->dnsmasqStateDir =3D g_strdup(LOCALSTATEDIR "/lib/l= ibvirt/dnsmasq"); + network_driver->radvdStateDir =3D g_strdup(LOCALSTATEDIR "/lib/lib= virt/radvd"); } else { configdir =3D virGetUserConfigDirectory(); rundir =3D virGetUserRuntimeDirectory(); @@ -2817,8 +2810,7 @@ networkCreateInterfacePool(virNetworkDefPtr netdef) case VIR_NETWORK_FORWARD_VEPA: case VIR_NETWORK_FORWARD_PASSTHROUGH: if (thisName) { - if (VIR_STRDUP(thisIf->device.dev, thisName) < 0) - goto cleanup; + thisIf->device.dev =3D g_strdup(thisName); thisIf->type =3D VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV; netdef->forward.nifs++; } else { @@ -4437,19 +4429,14 @@ networkGetDHCPLeases(virNetworkPtr net, } } =20 - if ((VIR_STRDUP(lease->mac, mac_tmp) < 0) || - (VIR_STRDUP(lease->ipaddr, ip_tmp) < 0) || - (VIR_STRDUP(lease->iface, def->bridge) < 0)) - goto error; + lease->mac =3D g_strdup(mac_tmp); + lease->ipaddr =3D g_strdup(ip_tmp); + lease->iface =3D g_strdup(def->bridge); =20 /* Fields that can be NULL */ - if ((VIR_STRDUP(lease->iaid, - virJSONValueObjectGetString(lease_tmp, "iaid")= ) < 0) || - (VIR_STRDUP(lease->clientid, - virJSONValueObjectGetString(lease_tmp, "client= -id")) < 0) || - (VIR_STRDUP(lease->hostname, - virJSONValueObjectGetString(lease_tmp, "hostna= me")) < 0)) - goto error; + lease->iaid =3D g_strdup(virJSONValueObjectGetString(lease_tmp= , "iaid")); + lease->clientid =3D g_strdup(virJSONValueObjectGetString(lease= _tmp, "client-id")); + lease->hostname =3D g_strdup(virJSONValueObjectGetString(lease= _tmp, "hostname")); =20 if (VIR_INSERT_ELEMENT(leases_ret, nleases, nleases, lease) < = 0) goto error; @@ -4622,8 +4609,7 @@ networkAllocatePort(virNetworkObjPtr obj, */ port->plugtype =3D VIR_NETWORK_PORT_PLUG_TYPE_NETWORK; =20 - if (VIR_STRDUP(port->plug.bridge.brname, netdef->bridge) < 0) - goto cleanup; + port->plug.bridge.brname =3D g_strdup(netdef->bridge); port->plug.bridge.macTableManager =3D netdef->macTableManager; =20 if (port->virtPortProfile) { @@ -4686,8 +4672,7 @@ networkAllocatePort(virNetworkObjPtr obj, */ =20 port->plugtype =3D VIR_NETWORK_PORT_PLUG_TYPE_BRIDGE; - if (VIR_STRDUP(port->plug.bridge.brname, netdef->bridge) < 0) - goto cleanup; + port->plug.bridge.brname =3D g_strdup(netdef->bridge); port->plug.bridge.macTableManager =3D netdef->macTableManager; =20 if (port->virtPortProfile) { @@ -4791,9 +4776,7 @@ networkAllocatePort(virNetworkObjPtr obj, netdef->name); goto cleanup; } - if (VIR_STRDUP(port->plug.direct.linkdev, - dev->device.dev) < 0) - goto cleanup; + port->plug.direct.linkdev =3D g_strdup(dev->device.dev); } break; =20 diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c index 959162b814..93dd2ca48a 100644 --- a/src/network/leaseshelper.c +++ b/src/network/leaseshelper.c @@ -151,16 +151,14 @@ main(int argc, char **argv) clientid =3D argv[2]; } =20 - if (VIR_STRDUP(server_duid, getenv("DNSMASQ_SERVER_DUID")) < 0) - goto cleanup; + server_duid =3D g_strdup(getenv("DNSMASQ_SERVER_DUID")); =20 if (virAsprintf(&custom_lease_file, LOCALSTATEDIR "/lib/libvirt/dnsmasq/%s.status", interface) < 0) goto cleanup; =20 - if (VIR_STRDUP(pid_file, RUNSTATEDIR "/leaseshelper.pid") < 0) - goto cleanup; + pid_file =3D g_strdup(RUNSTATEDIR "/leaseshelper.pid"); =20 /* Try to claim the pidfile, exiting if we can't */ if ((pid_file_fd =3D virPidFileAcquirePath(pid_file, false, getpid()))= < 0) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list