From nobody Sun Feb 8 19:25:57 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.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 205.139.110.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=1571576284; cv=none; d=zoho.com; s=zohoarc; b=ohIGJ9aA3kY2j50vqzVkakNZkg6vDkKXuXboE1EIdWI0wOD9UvomI3Vn/O1zJstuMROBUBIv+DgyiTW0o9iVzRVH+HiBkbOh56HjCjziF2RxSww0f1Uepctq3hW8RUKizZJvHj33VXTKFolJ77CWYuBmbTGIrUNtZ9EegTLbAJo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576284; 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=zzw80SUyY5mGrN1Eclrwy2VqkSuCAwGF34fZV16atDk=; b=gQbJcbfkKVJ5w83yzZXylDTmxX2X6CVtuwFyy3L1IuTqPmNYKw0QNtQZ+TJ0+7XQiixwzGpRd4VZaXltAtdwgxkpT7pmzVmOmcU5MzwZVCnEqLSRJm5gIpb6FFPB5KROyAJ6yNCcy1D8TwCHc8EnYg2Gylo2s6WlqWTFuCTmiU8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.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 [205.139.110.120]) by mx.zohomail.com with SMTPS id 1571576284461157.52507535574364; Sun, 20 Oct 2019 05:58:04 -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-60-3nm8WswJOre7rHgvVcixJg-1; Sun, 20 Oct 2019 08:56:29 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3AA581005533; Sun, 20 Oct 2019 12:56:22 +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 10C31100EBD7; Sun, 20 Oct 2019 12:56:22 +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 C6433180BAA6; Sun, 20 Oct 2019 12:56:21 +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 x9KCtvbx023502 for ; Sun, 20 Oct 2019 08:55:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9CD293CC8; Sun, 20 Oct 2019 12:55:57 +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 F3046194B9 for ; Sun, 20 Oct 2019 12:55:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576283; 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=zzw80SUyY5mGrN1Eclrwy2VqkSuCAwGF34fZV16atDk=; b=A4EpwR3XpIkxY0TSA/y2oSiUZkj0ea/fgOxIsmgMzy8rnDHby7kso7Ns+W1V6p4SmXZEvt nOyglO7N0/4OyhsMaBm67GDr9YMPSPnoVMtvEzYt/GT8drZCJfU3fujD+hYCmzrXEY+nWn e0918HB0957d3ZI1XSQ07axSncNlkJY= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:38 +0200 Message-Id: <1f36cef44381218d138d9af31b9669f1e9f6d45a.1571575889.git.jtomko@redhat.com> 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 20/34] node_device: 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.84 on 10.5.11.22 X-MC-Unique: 3nm8WswJOre7rHgvVcixJg-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/node_device/node_device_driver.c | 32 ++++++----------- src/node_device/node_device_hal.c | 8 ++--- src/node_device/node_device_udev.c | 51 ++++++++++------------------ 3 files changed, 29 insertions(+), 62 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index f95eacf6a2..7ef55f45e9 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -130,8 +130,8 @@ nodeDeviceUpdateDriverName(virNodeDeviceDefPtr def) } =20 p =3D strrchr(devpath, '/'); - if (p && VIR_STRDUP(def->driver, p + 1) < 0) - goto cleanup; + if (p) + def->driver =3D g_strdup(p + 1); ret =3D 0; =20 cleanup: @@ -242,12 +242,8 @@ nodeDeviceLookupByName(virConnectPtr conn, if (virNodeDeviceLookupByNameEnsureACL(conn, def) < 0) goto cleanup; =20 - if ((device =3D virGetNodeDevice(conn, name))) { - if (VIR_STRDUP(device->parentName, def->parent) < 0) { - virObjectUnref(device); - device =3D NULL; - } - } + if ((device =3D virGetNodeDevice(conn, name))) + device->parentName =3D g_strdup(def->parent); =20 cleanup: virNodeDeviceObjEndAPI(&obj); @@ -276,12 +272,8 @@ nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn, if (virNodeDeviceLookupSCSIHostByWWNEnsureACL(conn, def) < 0) goto cleanup; =20 - if ((device =3D virGetNodeDevice(conn, def->name))) { - if (VIR_STRDUP(device->parentName, def->parent) < 0) { - virObjectUnref(device); - device =3D NULL; - } - } + if ((device =3D virGetNodeDevice(conn, def->name))) + device->parentName =3D g_strdup(def->parent); =20 cleanup: virNodeDeviceObjEndAPI(&obj); @@ -335,8 +327,7 @@ nodeDeviceGetParent(virNodeDevicePtr device) goto cleanup; =20 if (def->parent) { - if (VIR_STRDUP(ret, def->parent) < 0) - goto cleanup; + ret =3D g_strdup(def->parent); } else { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no parent for this device")); @@ -396,10 +387,8 @@ nodeDeviceListCaps(virNodeDevicePtr device, if (ncaps > maxnames) ncaps =3D maxnames; =20 - for (i =3D 0; i < ncaps; i++) { - if (VIR_STRDUP(names[i], virNodeDevCapTypeToString(list[i])) < 0) - goto cleanup; - } + for (i =3D 0; i < ncaps; i++) + names[i] =3D g_strdup(virNodeDevCapTypeToString(list[i])); =20 ret =3D ncaps; =20 @@ -546,8 +535,7 @@ nodeDeviceDestroy(virNodeDevicePtr device) * event which would essentially free the existing @def (obj->def) and * replace it with something new, we need to grab the parent field * and then find the parent obj in order to manage the vport */ - if (VIR_STRDUP(parent, def->parent) < 0) - goto cleanup; + parent =3D g_strdup(def->parent); =20 virNodeDeviceObjEndAPI(&obj); =20 diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_devic= e_hal.c index 4b5d806fa6..688a0e0f06 100644 --- a/src/node_device/node_device_hal.c +++ b/src/node_device/node_device_hal.c @@ -461,14 +461,10 @@ dev_create(const char *udi) if (VIR_ALLOC(def) < 0) goto failure; =20 - if (VIR_STRDUP(def->name, name) < 0) - goto failure; + def->name =3D g_strdup(name); =20 if (get_str_prop(ctx, udi, "info.parent", &parent_key) =3D=3D 0) { - if (VIR_STRDUP(def->parent, hal_name(parent_key)) < 0) { - VIR_FREE(parent_key); - goto failure; - } + def->parent =3D g_strdup(hal_name(parent_key)); VIR_FREE(parent_key); } =20 diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 84f69da8de..525e71f80c 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -154,9 +154,7 @@ udevGetStringProperty(struct udev_device *udev_device, const char *property_key, char **value) { - if (VIR_STRDUP(*value, - udevGetDeviceProperty(udev_device, property_key)) < 0) - return -1; + *value =3D g_strdup(udevGetDeviceProperty(udev_device, property_key)); =20 return 0; } @@ -221,8 +219,7 @@ udevGetStringSysfsAttr(struct udev_device *udev_device, const char *attr_name, char **value) { - if (VIR_STRDUP(*value, udevGetDeviceSysfsAttr(udev_device, attr_name))= < 0) - return -1; + *value =3D g_strdup(udevGetDeviceSysfsAttr(udev_device, attr_name)); =20 virStringStripControlChars(*value); =20 @@ -345,9 +342,8 @@ udevTranslatePCIIds(unsigned int vendor, NULL, NULL); =20 - if (VIR_STRDUP(*vendor_string, vendor_name) < 0 || - VIR_STRDUP(*product_string, device_name) < 0) - return -1; + *vendor_string =3D g_strdup(vendor_name); + *product_string =3D g_strdup(device_name); =20 return 0; } @@ -641,8 +637,7 @@ udevProcessSCSITarget(struct udev_device *device, =20 sysname =3D udev_device_get_sysname(device); =20 - if (VIR_STRDUP(scsi_target->name, sysname) < 0) - return -1; + scsi_target->name =3D g_strdup(sysname); =20 virNodeDeviceGetSCSITargetCaps(def->sysfs_path, &def->caps->data.scsi_= target); =20 @@ -830,8 +825,7 @@ udevProcessCDROM(struct udev_device *device, * change it to cdrom to preserve compatibility with earlier * versions of libvirt. */ VIR_FREE(def->caps->data.storage.drive_type); - if (VIR_STRDUP(def->caps->data.storage.drive_type, "cdrom") < 0) - return -1; + def->caps->data.storage.drive_type =3D g_strdup("cdrom"); =20 if (udevHasDeviceProperty(device, "ID_CDROM_MEDIA") && udevGetIntProperty(device, "ID_CDROM_MEDIA", &has_media, 0) < 0) @@ -892,8 +886,8 @@ udevKludgeStorageType(virNodeDeviceDefPtr def) def->sysfs_path); =20 /* virtio disk */ - if (STRPREFIX(def->caps->data.storage.block, "/dev/vd") && - VIR_STRDUP(def->caps->data.storage.drive_type, "disk") > 0) { + if (STRPREFIX(def->caps->data.storage.block, "/dev/vd")) { + def->caps->data.storage.drive_type =3D g_strdup("disk"); VIR_DEBUG("Found storage type '%s' for device " "with sysfs path '%s'", def->caps->data.storage.drive_type, @@ -920,8 +914,7 @@ udevProcessStorage(struct udev_device *device, goto cleanup; } =20 - if (VIR_STRDUP(storage->block, devnode) < 0) - goto cleanup; + storage->block =3D g_strdup(devnode); =20 if (udevGetStringProperty(device, "ID_BUS", &storage->bus) < 0) goto cleanup; @@ -972,8 +965,7 @@ udevProcessStorage(struct udev_device *device, } =20 if (str) { - if (VIR_STRDUP(storage->drive_type, str) < 0) - goto cleanup; + storage->drive_type =3D g_strdup(str); } else { /* If udev doesn't have it, perhaps we can guess it. */ if (udevKludgeStorageType(def) !=3D 0) @@ -1052,8 +1044,7 @@ udevProcessMediatedDevice(struct udev_device *dev, goto cleanup; } =20 - if (VIR_STRDUP(data->type, last_component(canonicalpath)) < 0) - goto cleanup; + data->type =3D g_strdup(last_component(canonicalpath)); =20 uuidstr =3D udev_device_get_sysname(dev); if ((iommugrp =3D virMediatedDeviceGetIOMMUGroupNum(uuidstr)) < 0) @@ -1111,8 +1102,7 @@ udevGetDeviceNodes(struct udev_device *device, =20 devnode =3D udev_device_get_devnode(device); =20 - if (VIR_STRDUP(def->devnode, devnode) < 0) - return -1; + def->devnode =3D g_strdup(devnode); =20 udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entr= y(device)) n++; @@ -1122,8 +1112,7 @@ udevGetDeviceNodes(struct udev_device *device, =20 n =3D 0; udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entr= y(device)) { - if (VIR_STRDUP(def->devlinks[n++], udev_list_entry_get_name(list_e= ntry)) < 0) - return -1; + def->devlinks[n++] =3D g_strdup(udev_list_entry_get_name(list_entr= y)); } =20 return 0; @@ -1295,14 +1284,10 @@ udevSetParent(struct udev_device *device, if ((obj =3D virNodeDeviceObjListFindBySysfsPath(driver->devs, parent_sysfs_path))= ) { objdef =3D virNodeDeviceObjGetDef(obj); - if (VIR_STRDUP(def->parent, objdef->name) < 0) { - virNodeDeviceObjEndAPI(&obj); - goto cleanup; - } + def->parent =3D g_strdup(objdef->name); virNodeDeviceObjEndAPI(&obj); =20 - if (VIR_STRDUP(def->parent_sysfs_path, parent_sysfs_path) < 0) - goto cleanup; + def->parent_sysfs_path =3D g_strdup(parent_sysfs_path); } =20 } while (def->parent =3D=3D NULL && parent_device !=3D NULL); @@ -1330,8 +1315,7 @@ udevAddOneDevice(struct udev_device *device) if (VIR_ALLOC(def) !=3D 0) goto cleanup; =20 - if (VIR_STRDUP(def->sysfs_path, udev_device_get_syspath(device)) < 0) - goto cleanup; + def->sysfs_path =3D g_strdup(udev_device_get_syspath(device)); =20 if (udevGetStringProperty(device, "DRIVER", &def->driver) < 0) goto cleanup; @@ -1735,8 +1719,7 @@ udevSetupSystemDev(void) if (VIR_ALLOC(def) < 0) return -1; =20 - if (VIR_STRDUP(def->name, "computer") < 0) - goto cleanup; + def->name =3D g_strdup("computer"); =20 if (VIR_ALLOC(def->caps) !=3D 0) goto cleanup; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list