From nobody Sun Feb 8 09:22:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 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=1571576203; cv=none; d=zoho.com; s=zohoarc; b=JwPePRcHte07yEZy+lf+WBSoNaeC99VPquwKHQ2hL+02dN9JVP0R78WEapaCfAO+UkS8kzGtIEbb4IYxNuPOMjtE7S2Kozs9tQ35r9Jhoh0cwx5PGzGOK/VNhmEb3J0CN8yrKfa++eR6lGHBdAvDQvH7SHB/DMaAuQix/Z+leqI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576203; 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=LNe/VizNEvCDArv7bQYUsmMGVqACD79BSwNcObKrQeY=; b=g+v7DQPZtbhnLyyHU6W0n2jI+7QLq1jqyYXVqRZ43bsY4Gv31dsPFsQ0IppDgK0IoyJSUz4bx+8A1x80KiOfueBI85WjS6SVTM/4+cgwPSWiBJ1355hZEtmLBbXOf97udhc50cVdZC/2xMlErE+XSIPERtAanmxFbe0cTUnLJxM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1571576203629622.4818587442585; Sun, 20 Oct 2019 05:56:43 -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-5-vxbLEgbnO_qibfcNEt-7YA-1; Sun, 20 Oct 2019 08:56:39 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5D7B560C; Sun, 20 Oct 2019 12:56:33 +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 355815D721; Sun, 20 Oct 2019 12:56:33 +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 E7E5E1803B4F; Sun, 20 Oct 2019 12:56:32 +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 x9KCtqEb023455 for ; Sun, 20 Oct 2019 08:55:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 33C0B1EC; Sun, 20 Oct 2019 12:55:52 +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 72BA4194B9 for ; Sun, 20 Oct 2019 12:55:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576202; 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=LNe/VizNEvCDArv7bQYUsmMGVqACD79BSwNcObKrQeY=; b=SSbd2PFy8Uq6EVwAxtSCyf8XHDD3NUBd3YESzXED/3BQmnj2iyPjAgSy3QkSf/pjajOhe1 OP6KUG8Xc2IJGMdlY+96fpuPz2/odshNFk8BIrbmA5zmsKh/i02W8eeScaU63pRLNoTY0B yyELMiXsfYVHqvOpfBveaUsIO2Gyv38= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:33 +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 15/34] libxl: 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.15 X-MC-Unique: vxbLEgbnO_qibfcNEt-7YA-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/libxl/libxl_capabilities.c | 4 +- src/libxl/libxl_conf.c | 185 +++++++++++---------------------- src/libxl/libxl_driver.c | 18 ++-- src/libxl/libxl_migration.c | 8 +- src/libxl/xen_common.c | 62 ++++------- src/libxl/xen_xl.c | 30 ++---- src/libxl/xen_xm.c | 3 +- 7 files changed, 101 insertions(+), 209 deletions(-) diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c index 54a8c090b0..3b88121dca 100644 --- a/src/libxl/libxl_capabilities.c +++ b/src/libxl/libxl_capabilities.c @@ -615,9 +615,7 @@ libxlMakeDomainOSCaps(const char *machine, return -1; =20 for (i =3D 0; i < nfirmwares; i++) { - if (VIR_STRDUP(capsLoader->values.values[capsLoader->values.nvalue= s], - firmwares[i]->name) < 0) - return -1; + capsLoader->values.values[capsLoader->values.nvalues] =3D g_strdup= (firmwares[i]->name); capsLoader->values.nvalues++; } =20 diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index bbf0f8d8c1..3f08f0f710 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -162,8 +162,7 @@ libxlMakeDomCreateInfo(libxl_ctx *ctx, c_info->type =3D LIBXL_DOMAIN_TYPE_PV; } =20 - if (VIR_STRDUP(c_info->name, def->name) < 0) - goto error; + c_info->name =3D g_strdup(def->name); =20 if (def->nseclabels && def->seclabels[0]->type =3D=3D VIR_DOMAIN_SECLABEL_STATIC) { @@ -208,8 +207,7 @@ libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf) case VIR_DOMAIN_CHR_TYPE_STDIO: case VIR_DOMAIN_CHR_TYPE_VC: case VIR_DOMAIN_CHR_TYPE_PTY: - if (VIR_STRDUP(*buf, type) < 0) - return -1; + *buf =3D g_strdup(type); break; =20 case VIR_DOMAIN_CHR_TYPE_FILE: @@ -219,8 +217,7 @@ libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf) break; =20 case VIR_DOMAIN_CHR_TYPE_DEV: - if (VIR_STRDUP(*buf, srcdef->data.file.path) < 0) - return -1; + *buf =3D g_strdup(srcdef->data.file.path); break; =20 case VIR_DOMAIN_CHR_TYPE_UDP: { @@ -507,9 +504,8 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, VIR_TRISTATE_SWITCH_ON); =20 /* copy SLIC table path to acpi_firmware */ - if (def->os.slic_table && - VIR_STRDUP(b_info->u.hvm.acpi_firmware, def->os.slic_table= ) < 0) - return -1; + if (def->os.slic_table) + b_info->u.hvm.acpi_firmware =3D g_strdup(def->os.slic_table); =20 if (def->nsounds > 0) { /* @@ -518,9 +514,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, */ virDomainSoundDefPtr snd =3D def->sounds[0]; =20 - if (VIR_STRDUP(b_info->u.hvm.soundhw, - virDomainSoundModelTypeToString(snd->model)) < = 0) - return -1; + b_info->u.hvm.soundhw =3D g_strdup(virDomainSoundModelTypeToSt= ring(snd->model)); } =20 for (i =3D 0; i < def->os.nBootDevs; i++) { @@ -546,16 +540,12 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, } else { bootorder[def->os.nBootDevs] =3D '\0'; } - if (VIR_STRDUP(b_info->u.hvm.boot, bootorder) < 0) - return -1; + b_info->u.hvm.boot =3D g_strdup(bootorder); =20 #ifdef LIBXL_HAVE_BUILDINFO_KERNEL - if (VIR_STRDUP(b_info->cmdline, def->os.cmdline) < 0) - return -1; - if (VIR_STRDUP(b_info->kernel, def->os.kernel) < 0) - return -1; - if (VIR_STRDUP(b_info->ramdisk, def->os.initrd) < 0) - return -1; + b_info->cmdline =3D g_strdup(def->os.cmdline); + b_info->kernel =3D g_strdup(def->os.kernel); + b_info->ramdisk =3D g_strdup(def->os.initrd); #endif =20 /* @@ -587,8 +577,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, } =20 VIR_FREE(b_info->device_model); - if (VIR_STRDUP(b_info->device_model, def->emulator) < 0) - return -1; + b_info->device_model =3D g_strdup(def->emulator); =20 b_info->device_model_version =3D libxlDomainGetEmulatorType(de= f); } @@ -658,13 +647,11 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, switch (def->inputs[i]->type) { case VIR_DOMAIN_INPUT_TYPE_MOUSE: VIR_FREE(*usbdevice); - if (VIR_STRDUP(*usbdevice, "mouse") < 0) - return -1; + *usbdevice =3D g_strdup("mouse"); break; case VIR_DOMAIN_INPUT_TYPE_TABLET: VIR_FREE(*usbdevice); - if (VIR_STRDUP(*usbdevice, "tablet") < 0) - return -1; + *usbdevice =3D g_strdup("tablet"); break; default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -682,15 +669,11 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, } #endif } else if (pvh) { - if (VIR_STRDUP(b_info->cmdline, def->os.cmdline) < 0) - return -1; - if (VIR_STRDUP(b_info->kernel, def->os.kernel) < 0) - return -1; - if (VIR_STRDUP(b_info->ramdisk, def->os.initrd) < 0) - return -1; + b_info->cmdline =3D g_strdup(def->os.cmdline); + b_info->kernel =3D g_strdup(def->os.kernel); + b_info->ramdisk =3D g_strdup(def->os.initrd); #ifdef LIBXL_HAVE_BUILDINFO_BOOTLOADER - if (VIR_STRDUP(b_info->bootloader, def->os.bootloader) < 0) - return -1; + b_info->bootloader =3D g_strdup(def->os.bootloader); if (def->os.bootloaderArgs) { if (!(b_info->bootloader_args =3D virStringSplit(def->os.bootloaderArgs, " \t\n", 0))) @@ -703,27 +686,22 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, * if bootloader is not specified AND direct kernel boot is not sp= ecified. */ if (def->os.bootloader) { - if (VIR_STRDUP(b_info->u.pv.bootloader, def->os.bootloader) < = 0) - return -1; + b_info->u.pv.bootloader =3D g_strdup(def->os.bootloader); } else if (def->os.kernel =3D=3D NULL) { - if (VIR_STRDUP(b_info->u.pv.bootloader, LIBXL_BOOTLOADER_PATH)= < 0) - return -1; + b_info->u.pv.bootloader =3D g_strdup(LIBXL_BOOTLOADER_PATH); } if (def->os.bootloaderArgs) { if (!(b_info->u.pv.bootloader_args =3D virStringSplit(def->os.bootloaderArgs, " \t\n", 0))) return -1; } - if (VIR_STRDUP(b_info->u.pv.cmdline, def->os.cmdline) < 0) - return -1; + b_info->u.pv.cmdline =3D g_strdup(def->os.cmdline); if (def->os.kernel) { - /* libxl_init_build_info() sets VIR_STRDUP(kernel.path, "hvmlo= ader") */ + /* libxl_init_build_info() sets kernel.path =3D g_strdup("hvml= oader") */ VIR_FREE(b_info->u.pv.kernel); - if (VIR_STRDUP(b_info->u.pv.kernel, def->os.kernel) < 0) - return -1; + b_info->u.pv.kernel =3D g_strdup(def->os.kernel); } - if (VIR_STRDUP(b_info->u.pv.ramdisk, def->os.initrd) < 0) - return -1; + b_info->u.pv.ramdisk =3D g_strdup(def->os.initrd); } =20 /* only the 'xen' balloon device model is supported */ @@ -1036,12 +1014,10 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_dev= ice_disk *x_disk) if (libxlMakeNetworkDiskSrc(l_disk->src, &x_disk->pdev_path) < 0) return -1; } else { - if (VIR_STRDUP(x_disk->pdev_path, virDomainDiskGetSource(l_disk)) = < 0) - return -1; + x_disk->pdev_path =3D g_strdup(virDomainDiskGetSource(l_disk)); } =20 - if (VIR_STRDUP(x_disk->vdev, l_disk->dst) < 0) - return -1; + x_disk->vdev =3D g_strdup(l_disk->dst); =20 if (driver) { if (STREQ(driver, "tap") || STREQ(driver, "tap2")) { @@ -1159,8 +1135,7 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_devic= e_disk *x_disk) =20 if (l_disk->domain_name) { #ifdef LIBXL_HAVE_DEVICE_BACKEND_DOMNAME - if (VIR_STRDUP(x_disk->backend_domname, l_disk->domain_name) < 0) - return -1; + x_disk->backend_domname =3D g_strdup(l_disk->domain_name); #else virReportError(VIR_ERR_XML_DETAIL, "%s", _("this version of libxenlight does not " @@ -1289,8 +1264,7 @@ libxlMakeNic(virDomainDefPtr def, "Xen PV(H) domains")); return -1; } - if (VIR_STRDUP(x_nic->model, virDomainNetGetModelString(l_nic)) < = 0) - goto cleanup; + x_nic->model =3D g_strdup(virDomainNetGetModelString(l_nic)); if (l_nic->model =3D=3D VIR_DOMAIN_NET_MODEL_NETFRONT) x_nic->nictype =3D LIBXL_NIC_TYPE_VIF; else @@ -1302,8 +1276,7 @@ libxlMakeNic(virDomainDefPtr def, x_nic->nictype =3D LIBXL_NIC_TYPE_VIF; } =20 - if (VIR_STRDUP(x_nic->ifname, l_nic->ifname) < 0) - goto cleanup; + x_nic->ifname =3D g_strdup(l_nic->ifname); =20 port_profile =3D virDomainNetGetActualVirtPortProfile(l_nic); virt_vlan =3D virDomainNetGetActualVlan(l_nic); @@ -1343,13 +1316,10 @@ libxlMakeNic(virDomainDefPtr def, } if (virBufferCheckError(&buf) < 0) goto cleanup; - if (VIR_STRDUP(x_nic->bridge, - virBufferCurrentContent(&buf)) < 0) - goto cleanup; + x_nic->bridge =3D g_strdup(virBufferCurrentContent(&buf)); G_GNUC_FALLTHROUGH; case VIR_DOMAIN_NET_TYPE_ETHERNET: - if (VIR_STRDUP(x_nic->script, script) < 0) - goto cleanup; + x_nic->script =3D g_strdup(script); if (l_nic->guestIP.nips > 0) { x_nic->ip =3D xenMakeIPList(&l_nic->guestIP); if (!x_nic->ip) @@ -1394,8 +1364,7 @@ libxlMakeNic(virDomainDefPtr def, =20 if (l_nic->domain_name) { #ifdef LIBXL_HAVE_DEVICE_BACKEND_DOMNAME - if (VIR_STRDUP(x_nic->backend_domname, l_nic->domain_name) < 0) - goto cleanup; + x_nic->backend_domname =3D g_strdup(l_nic->domain_name); #else virReportError(VIR_ERR_XML_DETAIL, "%s", _("this version of libxenlight does not " @@ -1508,10 +1477,8 @@ libxlMakeVfb(virPortAllocatorRangePtr graphicsports, libxl_defbool_set(&x_vfb->sdl.enable, 1); libxl_defbool_set(&x_vfb->vnc.enable, 0); libxl_defbool_set(&x_vfb->sdl.opengl, 0); - if (VIR_STRDUP(x_vfb->sdl.display, l_vfb->data.sdl.display) < = 0) - return -1; - if (VIR_STRDUP(x_vfb->sdl.xauthority, l_vfb->data.sdl.xauth) <= 0) - return -1; + x_vfb->sdl.display =3D g_strdup(l_vfb->data.sdl.display); + x_vfb->sdl.xauthority =3D g_strdup(l_vfb->data.sdl.xauth); break; case VIR_DOMAIN_GRAPHICS_TYPE_VNC: libxl_defbool_set(&x_vfb->vnc.enable, 1); @@ -1528,20 +1495,16 @@ libxlMakeVfb(virPortAllocatorRangePtr graphicsports, =20 if ((glisten =3D virDomainGraphicsGetListen(l_vfb, 0))) { if (glisten->address) { - /* libxl_device_vfb_init() does VIR_STRDUP("127.0.0.1"= ) */ + /* libxl_device_vfb_init() does g_strdup("127.0.0.1") = */ VIR_FREE(x_vfb->vnc.listen); - if (VIR_STRDUP(x_vfb->vnc.listen, glisten->address) < = 0) - return -1; + x_vfb->vnc.listen =3D g_strdup(glisten->address); } else { - if (VIR_STRDUP(glisten->address, VIR_LOOPBACK_IPV4_ADD= R) < 0) - return -1; + glisten->address =3D g_strdup(VIR_LOOPBACK_IPV4_ADDR); } } =20 - if (VIR_STRDUP(x_vfb->vnc.passwd, l_vfb->data.vnc.auth.passwd)= < 0) - return -1; - if (VIR_STRDUP(x_vfb->keymap, l_vfb->data.vnc.keymap) < 0) - return -1; + x_vfb->vnc.passwd =3D g_strdup(l_vfb->data.vnc.auth.passwd); + x_vfb->keymap =3D g_strdup(l_vfb->data.vnc.keymap); break; =20 case VIR_DOMAIN_GRAPHICS_TYPE_RDP: @@ -1642,22 +1605,17 @@ libxlMakeBuildInfoVfb(virPortAllocatorRangePtr grap= hicsports, =20 if ((glisten =3D virDomainGraphicsGetListen(l_vfb, 0))) { if (glisten->address) { - if (VIR_STRDUP(b_info->u.hvm.spice.host, glisten->address)= < 0) - return -1; + b_info->u.hvm.spice.host =3D g_strdup(glisten->address); } else { - if (VIR_STRDUP(b_info->u.hvm.spice.host, VIR_LOOPBACK_IPV4= _ADDR) < 0 || - VIR_STRDUP(glisten->address, VIR_LOOPBACK_IPV4_ADDR) <= 0) - return -1; + b_info->u.hvm.spice.host =3D g_strdup(VIR_LOOPBACK_IPV4_AD= DR); + glisten->address =3D g_strdup(VIR_LOOPBACK_IPV4_ADDR); } } =20 - if (VIR_STRDUP(b_info->u.hvm.keymap, l_vfb->data.spice.keymap) < 0) - return -1; + b_info->u.hvm.keymap =3D g_strdup(l_vfb->data.spice.keymap); =20 if (l_vfb->data.spice.auth.passwd) { - if (VIR_STRDUP(b_info->u.hvm.spice.passwd, - l_vfb->data.spice.auth.passwd) < 0) - return -1; + b_info->u.hvm.spice.passwd =3D g_strdup(l_vfb->data.spice.auth= .passwd); libxl_defbool_set(&b_info->u.hvm.spice.disable_ticketing, fals= e); } else { libxl_defbool_set(&b_info->u.hvm.spice.disable_ticketing, true= ); @@ -1693,10 +1651,8 @@ libxlMakeBuildInfoVfb(virPortAllocatorRangePtr graph= icsports, =20 if (libxl_defbool_val(x_vfb.vnc.enable)) { libxl_defbool_set(&b_info->u.hvm.vnc.enable, true); - if (VIR_STRDUP(b_info->u.hvm.vnc.listen, x_vfb.vnc.listen) < 0) - return -1; - if (VIR_STRDUP(b_info->u.hvm.vnc.passwd, x_vfb.vnc.passwd) < 0) - return -1; + b_info->u.hvm.vnc.listen =3D g_strdup(x_vfb.vnc.listen); + b_info->u.hvm.vnc.passwd =3D g_strdup(x_vfb.vnc.passwd); b_info->u.hvm.vnc.display =3D x_vfb.vnc.display; libxl_defbool_set(&b_info->u.hvm.vnc.findunused, libxl_defbool_val(x_vfb.vnc.findunused)); @@ -1704,14 +1660,11 @@ libxlMakeBuildInfoVfb(virPortAllocatorRangePtr grap= hicsports, libxl_defbool_set(&b_info->u.hvm.sdl.enable, true); libxl_defbool_set(&b_info->u.hvm.sdl.opengl, libxl_defbool_val(x_vfb.sdl.opengl)); - if (VIR_STRDUP(b_info->u.hvm.sdl.display, x_vfb.sdl.display) < 0) - return -1; - if (VIR_STRDUP(b_info->u.hvm.sdl.xauthority, x_vfb.sdl.xauthority)= < 0) - return -1; + b_info->u.hvm.sdl.display =3D g_strdup(x_vfb.sdl.display); + b_info->u.hvm.sdl.xauthority =3D g_strdup(x_vfb.sdl.xauthority); } =20 - if (VIR_STRDUP(b_info->u.hvm.keymap, x_vfb.keymap) < 0) - return -1; + b_info->u.hvm.keymap =3D g_strdup(x_vfb.keymap); =20 return 0; } @@ -1766,24 +1719,15 @@ libxlDriverConfigNew(void) if (!(cfg =3D virObjectNew(libxlDriverConfigClass))) return NULL; =20 - if (VIR_STRDUP(cfg->configBaseDir, LIBXL_CONFIG_BASE_DIR) < 0) - goto error; - if (VIR_STRDUP(cfg->configDir, LIBXL_CONFIG_DIR) < 0) - goto error; - if (VIR_STRDUP(cfg->autostartDir, LIBXL_AUTOSTART_DIR) < 0) - goto error; - if (VIR_STRDUP(cfg->logDir, LIBXL_LOG_DIR) < 0) - goto error; - if (VIR_STRDUP(cfg->stateDir, LIBXL_STATE_DIR) < 0) - goto error; - if (VIR_STRDUP(cfg->libDir, LIBXL_LIB_DIR) < 0) - goto error; - if (VIR_STRDUP(cfg->saveDir, LIBXL_SAVE_DIR) < 0) - goto error; - if (VIR_STRDUP(cfg->autoDumpDir, LIBXL_DUMP_DIR) < 0) - goto error; - if (VIR_STRDUP(cfg->channelDir, LIBXL_CHANNEL_DIR) < 0) - goto error; + cfg->configBaseDir =3D g_strdup(LIBXL_CONFIG_BASE_DIR); + cfg->configDir =3D g_strdup(LIBXL_CONFIG_DIR); + cfg->autostartDir =3D g_strdup(LIBXL_AUTOSTART_DIR); + cfg->logDir =3D g_strdup(LIBXL_LOG_DIR); + cfg->stateDir =3D g_strdup(LIBXL_STATE_DIR); + cfg->libDir =3D g_strdup(LIBXL_LIB_DIR); + cfg->saveDir =3D g_strdup(LIBXL_SAVE_DIR); + cfg->autoDumpDir =3D g_strdup(LIBXL_DUMP_DIR); + cfg->channelDir =3D g_strdup(LIBXL_CHANNEL_DIR); =20 if (virFileMakePath(cfg->logDir) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1832,9 +1776,7 @@ libxlDriverConfigNew(void) cfg->nfirmwares =3D 1; if (VIR_ALLOC(cfg->firmwares[0]) < 0) goto error; - if (VIR_STRDUP(cfg->firmwares[0]->name, - LIBXL_FIRMWARE_DIR "/ovmf.bin") < 0) - goto error; + cfg->firmwares[0]->name =3D g_strdup(LIBXL_FIRMWARE_DIR "/ovmf.bin"); #endif =20 /* Always add hvmloader to firmwares */ @@ -1843,9 +1785,7 @@ libxlDriverConfigNew(void) cfg->nfirmwares++; if (VIR_ALLOC(cfg->firmwares[cfg->nfirmwares - 1]) < 0) goto error; - if (VIR_STRDUP(cfg->firmwares[cfg->nfirmwares - 1]->name, - LIBXL_FIRMWARE_DIR "/hvmloader") < 0) - goto error; + cfg->firmwares[cfg->nfirmwares - 1]->name =3D g_strdup(LIBXL_FIRMWARE_= DIR "/hvmloader"); =20 return cfg; =20 @@ -2027,9 +1967,7 @@ libxlMakeChannel(virDomainChrDefPtr l_channel, break; case VIR_DOMAIN_CHR_TYPE_UNIX: x_channel->connection =3D LIBXL_CHANNEL_CONNECTION_SOCKET; - if (VIR_STRDUP(x_channel->u.socket.path, - l_channel->source->data.nix.path) < 0) - return -1; + x_channel->u.socket.path =3D g_strdup(l_channel->source->data.nix.= path); break; default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -2043,8 +1981,7 @@ libxlMakeChannel(virDomainChrDefPtr l_channel, return -1; } =20 - if (VIR_STRDUP(x_channel->name, l_channel->target.name) < 0) - return -1; + x_channel->name =3D g_strdup(l_channel->target.name); =20 return 0; } diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index eaa35481ed..ceedeb3795 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -610,8 +610,7 @@ libxlAddDom0(libxlDriverPrivatePtr driver) =20 def->id =3D 0; def->virtType =3D VIR_DOMAIN_VIRT_XEN; - if (VIR_STRDUP(def->name, "Domain-0") < 0) - goto cleanup; + def->name =3D g_strdup("Domain-0"); =20 def->os.type =3D VIR_DOMAIN_OSTYPE_XEN; =20 @@ -1577,8 +1576,7 @@ libxlDomainGetOSType(virDomainPtr dom) if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (VIR_STRDUP(type, virDomainOSTypeToString(vm->def->os.type)) < 0) - goto cleanup; + type =3D g_strdup(virDomainOSTypeToString(vm->def->os.type)); =20 cleanup: virDomainObjEndAPI(&vm); @@ -5438,8 +5436,7 @@ libxlDomainBlockStatsVBD(virDomainObjPtr vm, =20 size =3D libxlDiskSectorSize(vm->def->id, devno); =20 - if (VIR_STRDUP(stats->backend, "vbd") < 0) - return ret; + stats->backend =3D g_strdup("vbd"); =20 if (virAsprintf(&path, "/sys/bus/xen-backend/devices/vbd-%d-%d/statist= ics", vm->def->id, devno) < 0) @@ -6306,19 +6303,16 @@ libxlGetDHCPInterfaces(virDomainPtr dom, if (VIR_ALLOC_N(iface->addrs, iface->naddrs) < 0) goto error; =20 - if (VIR_STRDUP(iface->name, vm->def->nets[i]->ifname) < 0) - goto cleanup; + iface->name =3D g_strdup(vm->def->nets[i]->ifname); =20 - if (VIR_STRDUP(iface->hwaddr, macaddr) < 0) - goto cleanup; + iface->hwaddr =3D g_strdup(macaddr); } =20 for (j =3D 0; j < n_leases; j++) { virNetworkDHCPLeasePtr lease =3D leases[j]; virDomainIPAddressPtr ip_addr =3D &iface->addrs[j]; =20 - if (VIR_STRDUP(ip_addr->addr, lease->ipaddr) < 0) - goto cleanup; + ip_addr->addr =3D g_strdup(lease->ipaddr); =20 ip_addr->type =3D lease->type; ip_addr->prefix =3D lease->prefix; diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 770a300316..0a57b6fcb0 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -94,8 +94,7 @@ libxlMigrationCookieNew(virDomainObjPtr dom) if (VIR_ALLOC(mig) < 0) goto error; =20 - if (VIR_STRDUP(mig->name, dom->def->name) < 0) - goto error; + mig->name =3D g_strdup(dom->def->name); =20 memcpy(mig->uuid, dom->def->uuid, VIR_UUID_BUFLEN); =20 @@ -462,10 +461,7 @@ libxlDomainMigrationDstPrepareDef(libxlDriverPrivatePt= r driver, =20 if (dname) { name =3D def->name; - if (VIR_STRDUP(def->name, dname) < 0) { - virDomainDefFree(def); - def =3D NULL; - } + def->name =3D g_strdup(dname); } =20 cleanup: diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index 1a36a632aa..cc9039a0cf 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -236,8 +236,7 @@ xenConfigGetString(virConfPtr conf, return -1; =20 if (rc =3D=3D 0 || !string) { - if (VIR_STRDUP(*value, def) < 0) - return -1; + *value =3D g_strdup(def); } else { *value =3D string; } @@ -277,10 +276,7 @@ xenConfigSetString(virConfPtr conf, const char *settin= g, const char *str) =20 value->type =3D VIR_CONF_STRING; value->next =3D NULL; - if (VIR_STRDUP(value->str, str) < 0) { - VIR_FREE(value); - return -1; - } + value->str =3D g_strdup(str); =20 return virConfSetValue(conf, setting, value); } @@ -702,14 +698,11 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def) if (STREQ(key + 10, "1")) graphics->data.vnc.autoport =3D true; } else if (STRPREFIX(key, "vnclisten=3D")) { - if (VIR_STRDUP(listenAddr, key+10) < 0) - goto cleanup; + listenAddr =3D g_strdup(key + 10); } else if (STRPREFIX(key, "vncpasswd=3D")) { - if (VIR_STRDUP(graphics->data.vnc.auth.passwd, key= + 10) < 0) - goto cleanup; + graphics->data.vnc.auth.passwd =3D g_strdup(key + = 10); } else if (STRPREFIX(key, "keymap=3D")) { - if (VIR_STRDUP(graphics->data.vnc.keymap, key + 7)= < 0) - goto cleanup; + graphics->data.vnc.keymap =3D g_strdup(key + 7); } else if (STRPREFIX(key, "vncdisplay=3D")) { if (virStrToLong_i(key + 11, NULL, 10, &graphics->data.vnc.port) < 0) { @@ -722,11 +715,9 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def) } } else { if (STRPREFIX(key, "display=3D")) { - if (VIR_STRDUP(graphics->data.sdl.display, key + 8= ) < 0) - goto cleanup; + graphics->data.sdl.display =3D g_strdup(key + 8); } else if (STRPREFIX(key, "xauthority=3D")) { - if (VIR_STRDUP(graphics->data.sdl.xauth, key + 11)= < 0) - goto cleanup; + graphics->data.sdl.xauth =3D g_strdup(key + 11); } } =20 @@ -786,8 +777,7 @@ xenParseSxprChar(const char *value, =20 if (value[0] =3D=3D '/') { def->source->type =3D VIR_DOMAIN_CHR_TYPE_DEV; - if (VIR_STRDUP(def->source->data.file.path, value) < 0) - goto error; + def->source->data.file.path =3D g_strdup(value); } else { if ((tmp =3D strchr(value, ':')) !=3D NULL) { *tmp =3D '\0'; @@ -808,14 +798,12 @@ xenParseSxprChar(const char *value, =20 switch (def->source->type) { case VIR_DOMAIN_CHR_TYPE_PTY: - if (VIR_STRDUP(def->source->data.file.path, tty) < 0) - goto error; + def->source->data.file.path =3D g_strdup(tty); break; =20 case VIR_DOMAIN_CHR_TYPE_FILE: case VIR_DOMAIN_CHR_TYPE_PIPE: - if (VIR_STRDUP(def->source->data.file.path, value) < 0) - goto error; + def->source->data.file.path =3D g_strdup(value); break; =20 case VIR_DOMAIN_CHR_TYPE_TCP: @@ -877,11 +865,9 @@ xenParseSxprChar(const char *value, offset2 + 1, offset3 - offset2 - 1) < 0) goto error; =20 - if (VIR_STRDUP(def->source->data.udp.bindService, offset3 + 1)= < 0) - goto error; + def->source->data.udp.bindService =3D g_strdup(offset3 + 1); } else { - if (VIR_STRDUP(def->source->data.udp.connectService, offset + = 1) < 0) - goto error; + def->source->data.udp.connectService =3D g_strdup(offset + 1); } } break; @@ -1034,10 +1020,7 @@ xenParseVifBridge(virDomainNetDefPtr net, char *brid= ge) if (!vlanstr_list) return -1; =20 - if (VIR_STRDUP(net->data.bridge.brname, vlanstr_list[0]) < 0) { - virStringListFree(vlanstr_list); - return -1; - } + net->data.bridge.brname =3D g_strdup(vlanstr_list[0]); =20 for (i =3D 1; vlanstr_list[i]; i++) nvlans++; @@ -1065,8 +1048,7 @@ xenParseVifBridge(virDomainNetDefPtr net, char *bridg= e) return 0; } else { /* 'bridge' string only contains the bridge name */ - if (VIR_STRDUP(net->data.bridge.brname, bridge) < 0) - return -1; + net->data.bridge.brname =3D g_strdup(bridge); } =20 return 0; @@ -1086,8 +1068,7 @@ xenParseSxprVifRate(const char *rate, unsigned long l= ong *kbytes_per_sec) unsigned long long tmp; int ret =3D -1; =20 - if (VIR_STRDUP(trate, rate) < 0) - return -1; + trate =3D g_strdup(rate); =20 p =3D strchr(trate, '@'); if (p !=3D NULL) @@ -1271,9 +1252,8 @@ xenParseVif(char *entry, const char *vif_typename) virStringListFree(ip_list); } =20 - if (script && script[0] && - VIR_STRDUP(net->script, script) < 0) - goto cleanup; + if (script && script[0]) + net->script =3D g_strdup(script); =20 if (model[0]) { if (virDomainNetSetModelString(net, model) < 0) @@ -1283,9 +1263,8 @@ xenParseVif(char *entry, const char *vif_typename) net->model =3D VIR_DOMAIN_NET_MODEL_NETFRONT; } =20 - if (vifname[0] && - VIR_STRDUP(net->ifname, vifname) < 0) - goto cleanup; + if (vifname[0]) + net->ifname =3D g_strdup(vifname); =20 if (rate[0]) { virNetDevBandwidthPtr bandwidth; @@ -1482,8 +1461,7 @@ xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr = def, virCapsPtr caps) goto out; =20 def->os.arch =3D capsdata->arch; - if (VIR_STRDUP(def->os.machine, capsdata->machinetype) < 0) - goto out; + def->os.machine =3D g_strdup(capsdata->machinetype); =20 ret =3D 0; out: diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index cbd3364fe9..6bdad2a59d 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -78,8 +78,7 @@ static int xenParseCmdline(virConfPtr conf, char **r_cmdl= ine) return -1; =20 if (buf) { - if (VIR_STRDUP(cmdline, buf) < 0) - return -1; + cmdline =3D g_strdup(buf); if (root || extra) VIR_WARN("ignoring root=3D and extra=3D in favour of cmdline= =3D"); } else { @@ -90,8 +89,7 @@ static int xenParseCmdline(virConfPtr conf, char **r_cmdl= ine) if (virAsprintf(&cmdline, "root=3D%s", root) < 0) return -1; } else if (extra) { - if (VIR_STRDUP(cmdline, extra) < 0) - return -1; + cmdline =3D g_strdup(extra); } } =20 @@ -119,17 +117,14 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def, vi= rCapsPtr caps) def->os.loader->type =3D VIR_DOMAIN_LOADER_TYPE_PFLASH; def->os.loader->readonly =3D VIR_TRISTATE_BOOL_YES; =20 - if (VIR_STRDUP(def->os.loader->path, - LIBXL_FIRMWARE_DIR "/ovmf.bin") < 0) - return -1; + def->os.loader->path =3D g_strdup(LIBXL_FIRMWARE_DIR "/ovmf.bi= n"); } else { for (i =3D 0; i < caps->nguests; i++) { if (caps->guests[i]->ostype =3D=3D VIR_DOMAIN_OSTYPE_HVM && caps->guests[i]->arch.id =3D=3D def->os.arch) { - if (VIR_ALLOC(def->os.loader) < 0 || - VIR_STRDUP(def->os.loader->path, - caps->guests[i]->arch.defaultInfo.loade= r) < 0) + if (VIR_ALLOC(def->os.loader) < 0) return -1; + def->os.loader->path =3D g_strdup(caps->guests[i]->arc= h.defaultInfo.loader); } } } @@ -538,8 +533,7 @@ xenParseXLVnuma(virConfPtr conf, } =20 VIR_FREE(tmp); - if (VIR_STRDUP(tmp, vtoken) < 0) - goto cleanup; + tmp =3D g_strdup(vtoken); =20 virStringListFree(token); if (!(token =3D virStringSplitCount(tmp, ",", 0, &= ndistances))) @@ -736,8 +730,7 @@ xenParseXLDisk(virConfPtr conf, virDomainDefPtr def) if (xenParseXLDiskSrc(disk, libxldisk->pdev_path) < 0) goto fail; =20 - if (VIR_STRDUP(disk->dst, libxldisk->vdev) < 0) - goto fail; + disk->dst =3D g_strdup(libxldisk->vdev); =20 disk->src->readonly =3D !libxldisk->readwrite; disk->removable =3D libxldisk->removable; @@ -1376,8 +1369,7 @@ xenFormatXLCPUID(virConfPtr conf, virDomainDefPtr def) if (VIR_ALLOC_N(cpuid_pairs, def->cpu->nfeatures + 2) < 0) return -1; =20 - if (VIR_STRDUP(cpuid_pairs[0], "host") < 0) - goto cleanup; + cpuid_pairs[0] =3D g_strdup("host"); =20 j =3D 1; for (i =3D 0; i < def->cpu->nfeatures; i++) { @@ -1659,8 +1651,7 @@ xenFormatXLDiskSrc(virStorageSourcePtr src, char **sr= cstr) case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: case VIR_STORAGE_TYPE_DIR: - if (VIR_STRDUP(*srcstr, src->path) < 0) - return -1; + *srcstr =3D g_strdup(src->path); break; =20 case VIR_STORAGE_TYPE_NETWORK: @@ -1947,8 +1938,7 @@ xenFormatXLInputDevs(virConfPtr conf, virDomainDefPtr= def) lastdev =3D lastdev->next; } lastdev->type =3D VIR_CONF_STRING; - if (VIR_STRDUP(lastdev->str, devtype) < 0) - goto error; + lastdev->str =3D g_strdup(devtype); } } if (usbdevices->list !=3D NULL) { diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c index e368482cac..fdf4e1cd29 100644 --- a/src/libxl/xen_xm.c +++ b/src/libxl/xen_xm.c @@ -96,8 +96,7 @@ xenParseXMOS(virConfPtr conf, virDomainDefPtr def) if (virAsprintf(&def->os.cmdline, "root=3D%s", root) < 0) return -1; } else if (extra) { - if (VIR_STRDUP(def->os.cmdline, extra) < 0) - return -1; + def->os.cmdline =3D g_strdup(extra); } } =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list