From nobody Mon Feb 9 05:41:09 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=1571576298; cv=none; d=zoho.com; s=zohoarc; b=RlxgIjRmIHg1ByZq39L4UobAJVgAhyuzX3aeee1sQQoUm0mZa/K16aFTnQ9MwtNh5SJEP/YgQjUO7+jVpEv5ur0pgMqDK2qjPG/smkilKz507RGYvNLu40ipgwzEaMW0BvV7R+8Nb3BlEr9trYF6Lvm6eNiRH4llELAqsMJMw5U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576298; 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=ZS3c7NR/Tg7zg1+BRu3831nhuFU5Zar900tXYtZB1bU=; b=laeui6axJqwvDlxzFXTdVynWJNleV7x15deEI3fTA7zomLj9gSwABKUGG8g8udtfSrNjcyC6x3KEpBf1N4XkKoO+QuQaZbeVCfKYUUJvUHIbnScQd9kWPM6+LlrzT4fcSXL65scI34zroZ0kvcozdywkKFplC8r4OZ/CuhduQWQ= 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 1571576298534137.53235497862556; Sun, 20 Oct 2019 05:58:18 -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-344-mGEPCY1rPRWR0VvE4lCTDg-1; Sun, 20 Oct 2019 08:56:35 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 89DC4835BFE; Sun, 20 Oct 2019 12:56:29 +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 5F9B260C63; Sun, 20 Oct 2019 12:56:29 +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 214853FC60; Sun, 20 Oct 2019 12:56:29 +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 x9KCu8an023592 for ; Sun, 20 Oct 2019 08:56:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8C8AD90B3; Sun, 20 Oct 2019 12:56:08 +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 DF7533DA3 for ; Sun, 20 Oct 2019 12:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576297; 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=ZS3c7NR/Tg7zg1+BRu3831nhuFU5Zar900tXYtZB1bU=; b=dYmrN5MH8qwgcWY/nYccjr1konXs4Jfa5WYVHKyaK4BscVfV+wbBJZWzr90Ws8bxJNV3Pi XFs8mK/KCDgTI4JyFTu6/LoTnBw9N1XJm95coS67A7ZcqbJOvep+ZsyrDKkOP3aGEN0QQO jX0nmBm62CKOMA0fe9hJ3H+AsmqXR9w= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:45 +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 27/34] test: 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.12 X-MC-Unique: mGEPCY1rPRWR0VvE4lCTDg-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/test/test_driver.c | 111 +++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 70 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 6af40ee35c..e00a65d8bb 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -359,11 +359,9 @@ testBuildCapabilities(virConnectPtr conn) caps->host.nsecModels =3D 1; if (VIR_ALLOC_N(caps->host.secModels, caps->host.nsecModels) < 0) goto error; - if (VIR_STRDUP(caps->host.secModels[0].model, "testSecurity") < 0) - goto error; + caps->host.secModels[0].model =3D g_strdup("testSecurity"); =20 - if (VIR_STRDUP(caps->host.secModels[0].doi, "") < 0) - goto error; + caps->host.secModels[0].doi =3D g_strdup(""); =20 return caps; =20 @@ -3105,8 +3103,7 @@ testDomainRenameCallback(virDomainObjPtr privdom, return -1; } =20 - if (VIR_STRDUP(new_dom_name, new_name) < 0) - goto cleanup; + new_dom_name =3D g_strdup(new_name); =20 event_old =3D virDomainEventLifecycleNewFromObj(privdom, VIR_DOMAIN_EVENT_UNDEFIN= ED, @@ -3121,7 +3118,6 @@ testDomainRenameCallback(virDomainObjPtr privdom, VIR_DOMAIN_EVENT_DEFINED= _RENAMED); ret =3D 0; =20 - cleanup: virObjectEventStateQueue(driver->eventState, event_old); virObjectEventStateQueue(driver->eventState, event_new); return ret; @@ -3692,8 +3688,7 @@ testDomainSetBlockIoTune(virDomainPtr dom, } =20 info =3D conf_disk->blkdeviotune; - if (VIR_STRDUP(info.group_name, conf_disk->blkdeviotune.group_name) < = 0) - goto cleanup; + info.group_name =3D g_strdup(conf_disk->blkdeviotune.group_name); =20 if (virTypedParamsAddString(&eventParams, &eventNparams, &eventMaxpara= ms, VIR_DOMAIN_TUNABLE_BLKDEV_DISK, path) < 0) @@ -3763,8 +3758,7 @@ testDomainSetBlockIoTune(virDomainPtr dom, =20 if (STREQ(param->field, VIR_DOMAIN_BLOCK_IOTUNE_GROUP_NAME)) { VIR_FREE(info.group_name); - if (VIR_STRDUP(info.group_name, param->value.s) < 0) - goto cleanup; + info.group_name =3D g_strdup(param->value.s); if (virTypedParamsAddString(&eventParams, &eventNparams, &eventMaxparams, @@ -3899,8 +3893,7 @@ testDomainGetBlockIoTune(virDomainPtr dom, } =20 reply =3D disk->blkdeviotune; - if (VIR_STRDUP(reply.group_name, disk->blkdeviotune.group_name) < 0) - goto cleanup; + reply.group_name =3D g_strdup(disk->blkdeviotune.group_name); =20 TEST_SET_PARAM(0, VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC, VIR_TYPED_PARAM_ULLONG, reply.total_bytes_sec); @@ -4689,8 +4682,7 @@ static int testDomainGetDiskErrors(virDomainPtr dom, memset(errors, 0, sizeof(virDomainDiskError) * nerrors); =20 for (i =3D 0; i < nerrors; i++) { - if (VIR_STRDUP(errors[i].disk, vm->def->disks[i]->dst) < 0) - goto cleanup; + errors[i].disk =3D g_strdup(vm->def->disks[i]->dst); errors[i].error =3D (i % (VIR_DOMAIN_DISK_ERROR_LAST - 1)) + 1; } ret =3D i; @@ -4737,19 +4729,23 @@ testDomainGetFSInfo(virDomainPtr dom, goto cleanup; =20 if (VIR_ALLOC(info_ret[0]) < 0 || - VIR_ALLOC(info_ret[0]->devAlias) < 0 || - VIR_STRDUP(info_ret[0]->mountpoint, "/") < 0 || - VIR_STRDUP(info_ret[0]->fstype, "ext4") < 0 || - VIR_STRDUP(info_ret[0]->devAlias[0], name) < 0 || - virAsprintf(&info_ret[0]->name, "%s1", name) < 0) + VIR_ALLOC(info_ret[0]->devAlias) < 0) + goto cleanup; + + info_ret[0]->mountpoint =3D g_strdup("/"); + info_ret[0]->fstype =3D g_strdup("ext4"); + info_ret[0]->devAlias[0] =3D g_strdup(name); + if (virAsprintf(&info_ret[0]->name, "%s1", name) < 0) goto cleanup; =20 if (VIR_ALLOC(info_ret[1]) < 0 || - VIR_ALLOC(info_ret[1]->devAlias) < 0 || - VIR_STRDUP(info_ret[1]->mountpoint, "/boot") < 0 || - VIR_STRDUP(info_ret[1]->fstype, "ext4") < 0 || - VIR_STRDUP(info_ret[1]->devAlias[0], name) < 0 || - virAsprintf(&info_ret[1]->name, "%s2", name) < 0) + VIR_ALLOC(info_ret[1]->devAlias) < 0) + goto cleanup; + + info_ret[1]->mountpoint =3D g_strdup("/boot"); + info_ret[1]->fstype =3D g_strdup("ext4"); + info_ret[1]->devAlias[0] =3D g_strdup(name); + if (virAsprintf(&info_ret[1]->name, "%s2", name) < 0) goto cleanup; =20 info_ret[0]->ndevAlias =3D info_ret[1]->ndevAlias =3D 1; @@ -5101,12 +5097,10 @@ testDomainInterfaceAddresses(virDomainPtr dom, if (VIR_ALLOC(iface) < 0) goto cleanup; =20 - if (VIR_STRDUP(iface->name, net->ifname) < 0) - goto cleanup; + iface->name =3D g_strdup(net->ifname); =20 virMacAddrFormat(&net->mac, macaddr); - if (VIR_STRDUP(iface->hwaddr, macaddr) < 0) - goto cleanup; + iface->hwaddr =3D g_strdup(macaddr); =20 if (VIR_ALLOC(iface->addrs) < 0) goto cleanup; @@ -6059,8 +6053,7 @@ testStoragePoolObjSetDefaults(virStoragePoolObjPtr ob= j) def->allocation =3D defaultPoolAlloc; def->available =3D defaultPoolCap - defaultPoolAlloc; =20 - if (VIR_STRDUP(configFile, "") < 0) - return -1; + configFile =3D g_strdup(""); =20 virStoragePoolObjSetConfigFile(obj, configFile); return 0; @@ -7025,8 +7018,8 @@ testStorageVolCreateXML(virStoragePoolPtr pool, def->target.path, privvol->name) < 0) goto cleanup; =20 - if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 || - virStoragePoolObjAddVol(obj, privvol) < 0) + privvol->key =3D g_strdup(privvol->target.path); + if (virStoragePoolObjAddVol(obj, privvol) < 0) goto cleanup; =20 def->allocation +=3D privvol->target.allocation; @@ -7093,8 +7086,8 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool, def->target.path, privvol->name) < 0) goto cleanup; =20 - if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 || - virStoragePoolObjAddVol(obj, privvol) < 0) + privvol->key =3D g_strdup(privvol->target.path); + if (virStoragePoolObjAddVol(obj, privvol) < 0) goto cleanup; =20 def->allocation +=3D privvol->target.allocation; @@ -7319,12 +7312,8 @@ testNodeDeviceLookupByName(virConnectPtr conn, const= char *name) return NULL; def =3D virNodeDeviceObjGetDef(obj); =20 - if ((ret =3D virGetNodeDevice(conn, name))) { - if (VIR_STRDUP(ret->parentName, def->parent) < 0) { - virObjectUnref(ret); - ret =3D NULL; - } - } + if ((ret =3D virGetNodeDevice(conn, name))) + ret->parentName =3D g_strdup(def->parent); =20 virNodeDeviceObjEndAPI(&obj); return ret; @@ -7408,20 +7397,12 @@ testNodeDeviceListCaps(virNodeDevicePtr dev, char *= *const names, int maxnames) def =3D virNodeDeviceObjGetDef(obj); =20 for (caps =3D def->caps; caps && ncaps < maxnames; caps =3D caps->next= ) { - if (VIR_STRDUP(names[ncaps], - virNodeDevCapTypeToString(caps->data.type)) < 0) - goto error; + names[ncaps] =3D g_strdup(virNodeDevCapTypeToString(caps->data.typ= e)); ncaps++; } =20 virNodeDeviceObjEndAPI(&obj); return ncaps; - - error: - while (--ncaps >=3D 0) - VIR_FREE(names[ncaps]); - virNodeDeviceObjEndAPI(&obj); - return -1; } =20 =20 @@ -7459,8 +7440,7 @@ testNodeDeviceMockCreateVport(testDriverPtr driver, goto cleanup; =20 VIR_FREE(def->name); - if (VIR_STRDUP(def->name, "scsi_host12") < 0) - goto cleanup; + def->name =3D g_strdup("scsi_host12"); =20 /* Find the 'scsi_host' cap and alter the host # and unique_id and * then for the 'fc_host' capability modify the wwnn/wwpn to be that @@ -7474,9 +7454,8 @@ testNodeDeviceMockCreateVport(testDriverPtr driver, if (caps->data.scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST= ) { VIR_FREE(caps->data.scsi_host.wwnn); VIR_FREE(caps->data.scsi_host.wwpn); - if (VIR_STRDUP(caps->data.scsi_host.wwnn, wwnn) < 0 || - VIR_STRDUP(caps->data.scsi_host.wwpn, wwpn) < 0) - goto cleanup; + caps->data.scsi_host.wwnn =3D g_strdup(wwnn); + caps->data.scsi_host.wwpn =3D g_strdup(wwpn); } else { /* For the "scsi_host" cap, increment our host and unique_id to * give the appearance that something new was created - then a= dd @@ -7547,8 +7526,7 @@ testNodeDeviceCreateXML(virConnectPtr conn, goto cleanup; =20 VIR_FREE(dev->parentName); - if (VIR_STRDUP(dev->parentName, def->parent) < 0) - goto cleanup; + dev->parentName =3D g_strdup(def->parent); =20 ret =3D g_steal_pointer(&dev); =20 @@ -7819,8 +7797,7 @@ testDomainScreenshot(virDomainPtr dom G_GNUC_UNUSED, =20 virCheckFlags(0, NULL); =20 - if (VIR_STRDUP(ret, "image/png") < 0) - return NULL; + ret =3D g_strdup("image/png"); =20 if (virFDStreamOpenFile(st, PKGDATADIR "/test-screenshot.png", 0, 0, O= _RDONLY) < 0) VIR_FREE(ret); @@ -8635,9 +8612,7 @@ testDomainSnapshotCreateXML(virDomainPtr domain, } =20 if (!redefine) { - if (VIR_STRDUP(snap->def->parent_name, - virDomainSnapshotGetCurrentName(vm->snapshots)) < 0) - goto cleanup; + snap->def->parent_name =3D g_strdup(virDomainSnapshotGetCurrentNam= e(vm->snapshots)); =20 if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_HALT) && virDomainObjIsActive(vm)) { @@ -8703,11 +8678,8 @@ testDomainMomentReparentChildren(void *payload, =20 VIR_FREE(moment->def->parent_name); =20 - if (rep->parent->def && - VIR_STRDUP(moment->def->parent_name, rep->parent->def->name) < 0) { - rep->err =3D -1; - return 0; - } + if (rep->parent->def) + moment->def->parent_name =3D g_strdup(rep->parent->def->name); =20 return 0; } @@ -9098,9 +9070,8 @@ testDomainCheckpointCreateXML(virDomainPtr domain, =20 current =3D virDomainCheckpointGetCurrent(vm->checkpoints); if (current) { - if (!redefine && - VIR_STRDUP(chk->def->parent_name, current->def->name) < 0) - goto cleanup; + if (!redefine) + chk->def->parent_name =3D g_strdup(current->def->name); if (update_current) virDomainCheckpointSetCurrent(vm->checkpoints, NULL); } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list