From nobody Sun Feb 8 07:48:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; 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 207.211.31.81 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=1571576189; cv=none; d=zoho.com; s=zohoarc; b=PATDTKEbmtUQnF1G6y5XdHjVZv/QnA8KkiQLt4shLaWrP3NTcztAqQ0Ljr+UKpCmbN9/MJRXEDrxkStRvWbG2XdnGOkiRwaclheogezcJMjNOaxWfUcuWlZLZcnDJlkPl6XYZAjqeeJymzkNmFw8gN9e/TRA0+GTkiHzzg4CaFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576189; 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=Onnu2gu6CWtV6oW4+8u0L6aTw6Sj4CUByUUlfbPNZiQ=; b=AMjcM3JGXPoMWg6U7IHk3qtXrPRL3CaBwnrzQXj6qGBW6zouS+LlYJ1l+FJzF0km7PNSeP2xoOCiA/N2qP6PkmLs072A5QcCAHGZcjHpa3C+XcBVPwQlRz1XjjhJEAwEgw9BGOyan6b0ExuCS8AWZBRqHUZ8TF+/D+XhVvChSMs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1571576189355806.6568945234361; Sun, 20 Oct 2019 05:56:29 -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-67-XM2zcIfSMWifP4qs_VD_0Q-1; Sun, 20 Oct 2019 08:56:21 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0916E100552E; Sun, 20 Oct 2019 12:56:16 +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 D846D6012D; Sun, 20 Oct 2019 12:56:15 +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 9AF06180BA9C; Sun, 20 Oct 2019 12:56:15 +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 x9KCtd48023357 for ; Sun, 20 Oct 2019 08:55:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 03C34196AE; Sun, 20 Oct 2019 12:55:39 +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 671001EC for ; Sun, 20 Oct 2019 12:55:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576188; 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=Onnu2gu6CWtV6oW4+8u0L6aTw6Sj4CUByUUlfbPNZiQ=; b=bbVgCKEaEIEVsFo6g4bWFlWKr9hdbmqz3GhpXG7lSnYXs5ivFtfmea02AdZH8sn3RtxZmb NIda+EtC4R+iwFwjKhOF0RPMtNQM+dd0hGKnulKQ6a1n+g4u2EN1c2FKAkyRqw9NxHVurn CnSq6fHHtt3+z6N3gD/g7hA0F7YiWSE= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:25 +0200 Message-Id: <9a14fc54264a5737d37eda7a7977a2d43f36e9b7.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 07/34] Use g_strdup where VIR_STRDUP's return value was propagated 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.11 X-MC-Unique: XM2zcIfSMWifP4qs_VD_0Q-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" All the callers of these functions only check for a negative return value. However, virNetDevOpenvswitchGetVhostuserIfname is documented as returning 1 for openvswitch interfaces so preserve that. Signed-off-by: J=C3=A1n Tomko --- src/esx/esx_vi.c | 3 ++- src/esx/esx_vi_types.c | 6 ++---- src/qemu/qemu_alias.c | 21 ++++++++++++++------- src/qemu/qemu_monitor_json.c | 3 ++- src/storage/storage_util.c | 3 ++- src/util/vircgroupv2.c | 6 ++++-- src/util/viriscsi.c | 6 ++++-- src/util/virnuma.c | 3 ++- src/util/virresctrl.c | 3 ++- src/util/virstoragefile.c | 3 ++- src/util/viruri.c | 3 ++- tests/qemuxml2argvmock.c | 6 ++++-- tests/securityselinuxhelper.c | 6 ++++-- 13 files changed, 46 insertions(+), 26 deletions(-) diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index 004434c454..ef37bbf88d 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -2388,7 +2388,8 @@ esxVI_GetVirtualMachineMORef(esxVI_ObjectContent *vir= tualMachine, if (virtualMachine->obj && STREQ(virtualMachine->obj->type, "VirtualMachine") && virtualMachine->obj->value) { - return VIR_STRDUP(*moref, virtualMachine->obj->value); + *moref =3D g_strdup(virtualMachine->obj->value); + return 0; } } return -1; diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index deb6ebd09f..29b1b01b9b 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -1206,10 +1206,8 @@ esxVI_String_DeepCopyValue(char **dest, const char *= src) { ESX_VI_CHECK_ARG_LIST(dest); =20 - if (!src) - return 0; - - return VIR_STRDUP(*dest, src); + *dest =3D g_strdup(src); + return 0; } =20 /* esxVI_String_CastFromAnyType */ diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 5af3725bf5..d4d8eb4252 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -134,7 +134,8 @@ qemuAssignDeviceControllerAlias(virDomainDefPtr domainD= ef, * hardcoded the name of their single PCI controller as * "pci". */ - return VIR_STRDUP(controller->info.alias, "pci"); + controller->info.alias =3D g_strdup("pci"); + return 0; } else if (controller->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PC= IE_ROOT) { /* The pcie-root controller on Q35 machinetypes uses a * different naming convention ("pcie.0"), because it is @@ -153,18 +154,24 @@ qemuAssignDeviceControllerAlias(virDomainDefPtr domai= nDef, * controller hardcoded with id "ide" */ if (qemuDomainHasBuiltinIDE(domainDef) && - controller->idx =3D=3D 0) - return VIR_STRDUP(controller->info.alias, "ide"); + controller->idx =3D=3D 0) { + controller->info.alias =3D g_strdup("ide"); + return 0; + } } else if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SATA) { /* for any Q35 machine, the first SATA controller is the * integrated one, and it too is hardcoded with id "ide" */ - if (qemuDomainIsQ35(domainDef) && controller->idx =3D=3D 0) - return VIR_STRDUP(controller->info.alias, "ide"); + if (qemuDomainIsQ35(domainDef) && controller->idx =3D=3D 0) { + controller->info.alias =3D g_strdup("ide"); + return 0; + } } else if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_USB) { /* first USB device is "usb", others are normal "usb%d" */ - if (controller->idx =3D=3D 0) - return VIR_STRDUP(controller->info.alias, "usb"); + if (controller->idx =3D=3D 0) { + controller->info.alias =3D g_strdup("usb"); + return 0; + } } /* all other controllers use the default ${type}${index} naming * scheme for alias/id. diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 4b765da0b1..602a0380d7 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5957,7 +5957,8 @@ qemuMonitorJSONGetCPUModelComparison(qemuMonitorPtr m= on, return -1; } =20 - return VIR_STRDUP(*result, data_result); + *result =3D g_strdup(data_result); + return 0; } =20 =20 diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index a4c8a5e971..692b3e7a9d 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -2072,7 +2072,8 @@ virStorageBackendVolCreateLocal(virStoragePoolObjPtr = pool, } =20 VIR_FREE(vol->key); - return VIR_STRDUP(vol->key, vol->target.path); + vol->key =3D g_strdup(vol->target.path); + return 0; } =20 =20 diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 621ab71eb5..7a64e74c3a 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -146,7 +146,8 @@ static int virCgroupV2CopyMounts(virCgroupPtr group, virCgroupPtr parent) { - return VIR_STRDUP(group->unified.mountPoint, parent->unified.mountPoin= t); + group->unified.mountPoint =3D g_strdup(parent->unified.mountPoint); + return 0; } =20 =20 @@ -189,7 +190,8 @@ virCgroupV2DetectMounts(virCgroupPtr group, =20 VIR_FREE(group->unified.mountPoint); =20 - return VIR_STRDUP(group->unified.mountPoint, mntDir); + group->unified.mountPoint =3D g_strdup(mntDir); + return 0; } =20 =20 diff --git a/src/util/viriscsi.c b/src/util/viriscsi.c index dc553e7752..1b143ec61f 100644 --- a/src/util/viriscsi.c +++ b/src/util/viriscsi.c @@ -60,8 +60,10 @@ virISCSIExtractSession(char **const groups, struct virISCSISessionData *data =3D opaque; =20 if (!data->session && - STREQ(groups[1], data->devpath)) - return VIR_STRDUP(data->session, groups[0]); + STREQ(groups[1], data->devpath)) { + data->session =3D g_strdup(groups[0]); + return 0; + } return 0; } =20 diff --git a/src/util/virnuma.c b/src/util/virnuma.c index 8f50634c2a..448833d8d1 100644 --- a/src/util/virnuma.c +++ b/src/util/virnuma.c @@ -579,7 +579,8 @@ static int virNumaGetHugePageInfoDir(char **path, int node) { if (node =3D=3D -1) { - return VIR_STRDUP(*path, HUGEPAGES_SYSTEM_PREFIX); + *path =3D g_strdup(HUGEPAGES_SYSTEM_PREFIX); + return 0; } else { return virAsprintf(path, HUGEPAGES_NUMA_PREFIX "node%d/hugepages/", diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index ab650b59b9..e52408ed06 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -1388,7 +1388,8 @@ virResctrlSetID(char **resctrlid, return -1; } =20 - return VIR_STRDUP(*resctrlid, id); + *resctrlid =3D g_strdup(id); + return 0; } =20 =20 diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 64e09d7951..c13ed9fee5 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -4468,7 +4468,8 @@ int virStorageSourceInitiatorCopy(virStorageSourceInitiatorDefPtr dest, const virStorageSourceInitiatorDef *src) { - return VIR_STRDUP(dest->iqn, src->iqn); + dest->iqn =3D g_strdup(src->iqn); + return 0; } =20 void diff --git a/src/util/viruri.c b/src/util/viruri.c index a43fe2afd4..af2e828c28 100644 --- a/src/util/viruri.c +++ b/src/util/viruri.c @@ -350,7 +350,8 @@ virURIFindAliasMatch(char *const*aliases, const char *a= lias, STREQLEN(*aliases, alias, alias_len)) { VIR_DEBUG("Resolved alias '%s' to '%s'", alias, offset+1); - return VIR_STRDUP(*uri, offset+1); + *uri =3D g_strdup(offset + 1); + return 0; } =20 aliases++; diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 2b9e5e7a49..34e0eb91a6 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -153,7 +153,8 @@ virNetDevTapCreate(char **ifname, return 0; } else { VIR_FREE(*ifname); - return VIR_STRDUP(*ifname, "vnet0"); + *ifname =3D g_strdup("vnet0"); + return 0; } } =20 @@ -229,7 +230,8 @@ int virNetDevOpenvswitchGetVhostuserIfname(const char *path G_GNUC_UNUSED, char **ifname) { - return VIR_STRDUP(*ifname, "vhost-user0"); + *ifname =3D g_strdup("vhost-user0"); + return 1; } =20 int diff --git a/tests/securityselinuxhelper.c b/tests/securityselinuxhelper.c index 6391f67360..814250b731 100644 --- a/tests/securityselinuxhelper.c +++ b/tests/securityselinuxhelper.c @@ -111,7 +111,8 @@ int getcon_raw(security_context_t *context) errno =3D EINVAL; return -1; } - return VIR_STRDUP_QUIET(*context, getenv("FAKE_SELINUX_CONTEXT")); + *context =3D g_strdup(getenv("FAKE_SELINUX_CONTEXT")); + return 0; } =20 int getcon(security_context_t *context) @@ -135,7 +136,8 @@ int getpidcon_raw(pid_t pid, security_context_t *contex= t) errno =3D EINVAL; return -1; } - return VIR_STRDUP_QUIET(*context, getenv("FAKE_SELINUX_CONTEXT")); + *context =3D g_strdup(getenv("FAKE_SELINUX_CONTEXT")); + return 0; } =20 int getpidcon(pid_t pid, security_context_t *context) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list