From nobody Mon Feb 9 06:26:41 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=1571752984; cv=none; d=zoho.com; s=zohoarc; b=db9qwF5PilKBR04Ysk53Tl14U3bi9hAR8+LcnjNBm69V7X7j+GpC6fXMXvdSEsQ7xOG0SuSR7GCPPfbeaaYcAax6H8GcXsZjTbYncHJ/Gbbe5r5lOc77KFYNc0ApESDo0LQKCCFhu2FTNeDeGUhQj/lM7IC1ZTKTX0D0Xl7lHM4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571752984; 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=fx1w0ZVV2oZ/jm9bpsaRXRi0lsFbFBvAgeC9/U2Nzyk=; b=VRZQH4NfITXSDCfk8n+QBeSPa4aO28wBXx0yy0BHhPmbBtOhRJBoTJjdMki5OmfJmEMyEm4L6DKyIeJ14kXZc4kaf24+lQbndV4ObvwdArZBJ1qG29fIiBZwyuNTLKz0gjsrQmOQf0b9OK5Mt+J3a5XeDo0xDmr2hXOPrnWHh/c= 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 1571752984765502.22416687355724; Tue, 22 Oct 2019 07:03: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-356-CdlhiwCNONynTYebOia_CQ-1; Tue, 22 Oct 2019 10:01:13 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 606D5800D56; Tue, 22 Oct 2019 14:01:08 +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 1660F52D1; Tue, 22 Oct 2019 14:01:08 +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 8C5D73FB41; Tue, 22 Oct 2019 14:01:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9ME0sKi002786 for ; Tue, 22 Oct 2019 10:00:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2F1F06012C; Tue, 22 Oct 2019 14:00:54 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id A891E6064B for ; Tue, 22 Oct 2019 14:00:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571752982; 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=fx1w0ZVV2oZ/jm9bpsaRXRi0lsFbFBvAgeC9/U2Nzyk=; b=B7qjTHFzDYLwXjYRCuOLuWDE5k0ioT8+h8/PKs55gijwtQ69CeMy8Exzuf4ZVRvA0O0MAj 5GwO02zGthfBTCXd6BNF4UVhMODdGhHXkMMppcPMY4kGL3PbfKtc33fe2Aa6dbpLFSU3dk XpFN80m/CoWpFaYgxALI1xDqDOSW27k= From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 22 Oct 2019 15:58:02 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 58/75] storage: Use g_strdup_printf() instead of virAsprintf() 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.23 X-MC-Unique: CdlhiwCNONynTYebOia_CQ-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" Signed-off-by: Michal Privoznik --- src/storage/storage_backend_disk.c | 4 +- src/storage/storage_backend_gluster.c | 8 ++-- src/storage/storage_backend_iscsi.c | 16 +++---- src/storage/storage_backend_iscsi_direct.c | 28 ++++++------ src/storage/storage_backend_logical.c | 8 ++-- src/storage/storage_backend_mpath.c | 6 +-- src/storage/storage_backend_rbd.c | 8 ++-- src/storage/storage_backend_scsi.c | 6 +-- src/storage/storage_backend_sheepdog.c | 4 +- src/storage/storage_backend_vstorage.c | 4 +- src/storage/storage_backend_zfs.c | 8 ++-- src/storage/storage_driver.c | 12 ++--- src/storage/storage_file_gluster.c | 10 ++--- src/storage/storage_util.c | 52 +++++++++++----------- 14 files changed, 87 insertions(+), 87 deletions(-) diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backe= nd_disk.c index d4bd526c14..d971530cd8 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -605,14 +605,14 @@ virStorageBackendDiskPartFormat(virStoragePoolObjPtr = pool, /* XXX Only support one extended partition */ switch (virStorageBackendDiskPartTypeToCreate(pool)) { case VIR_STORAGE_VOL_DISK_TYPE_PRIMARY: - virAsprintf(partFormat, "primary %s", partedFormat); + *partFormat =3D g_strdup_printf("primary %s", partedFormat= ); break; case VIR_STORAGE_VOL_DISK_TYPE_LOGICAL: /* make sure we have an extended partition */ if (virStoragePoolObjSearchVolume(pool, virStorageVolPartFindExt= ended, NULL)) { - virAsprintf(partFormat, "logical %s", partedFormat); + *partFormat =3D g_strdup_printf("logical %s", partedFo= rmat); } else { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no extended partition found and no " diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_ba= ckend_gluster.c index 0022ed2f21..4a8ee3870d 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -101,7 +101,7 @@ virStorageBackendGlusterOpen(virStoragePoolObjPtr pool) return NULL; =20 ret->volname =3D g_strdup(name); - virAsprintf(&ret->dir, "%s%s", dir ? dir : "/", trailing_slash ? "" : = "/"); + ret->dir =3D g_strdup_printf("%s%s", dir ? dir : "/", trailing_slash ?= "" : "/"); =20 /* FIXME: Currently hard-coded to tcp transport; XML needs to be * extended to allow alternate transport */ @@ -109,7 +109,7 @@ virStorageBackendGlusterOpen(virStoragePoolObjPtr pool) goto error; ret->uri->scheme =3D g_strdup("gluster"); ret->uri->server =3D g_strdup(def->source.hosts[0].name); - virAsprintf(&ret->uri->path, "/%s%s", ret->volname, ret->dir); + ret->uri->path =3D g_strdup_printf("/%s%s", ret->volname, ret->dir); ret->uri->port =3D def->source.hosts[0].port; =20 /* Actually connect to glfs */ @@ -193,10 +193,10 @@ virStorageBackendGlusterSetMetadata(virStorageBackend= GlusterStatePtr state, vol->name =3D g_strdup(name); } =20 - virAsprintf(&path, "%s%s%s", state->volname, state->dir, vol->name); + path =3D g_strdup_printf("%s%s%s", state->volname, state->dir, vol->na= me); =20 tmp =3D state->uri->path; - virAsprintf(&state->uri->path, "/%s", path); + state->uri->path =3D g_strdup_printf("/%s", path); if (!(vol->target.path =3D virURIFormat(state->uri))) { VIR_FREE(state->uri->path); state->uri->path =3D tmp; diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_back= end_iscsi.c index b61abb7cbd..b85c9078f8 100644 --- a/src/storage/storage_backend_iscsi.c +++ b/src/storage/storage_backend_iscsi.c @@ -63,13 +63,13 @@ virStorageBackendISCSIPortal(virStoragePoolSourcePtr so= urce) source->hosts[0].port =3D ISCSI_DEFAULT_TARGET_PORT; =20 if (strchr(source->hosts[0].name, ':')) { - virAsprintf(&portal, "[%s]:%d,1", - source->hosts[0].name, - source->hosts[0].port); + portal =3D g_strdup_printf("[%s]:%d,1", + source->hosts[0].name, + source->hosts[0].port); } else { - virAsprintf(&portal, "%s:%d,1", - source->hosts[0].name, - source->hosts[0].port); + portal =3D g_strdup_printf("%s:%d,1", + source->hosts[0].name, + source->hosts[0].port); } =20 return portal; @@ -133,8 +133,8 @@ virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool, uint32_t host; g_autofree char *sysfs_path =3D NULL; =20 - virAsprintf(&sysfs_path, "/sys/class/iscsi_session/session%s/device", - session); + sysfs_path =3D g_strdup_printf("/sys/class/iscsi_session/session%s/dev= ice", + session); =20 if (virStorageBackendISCSIGetHostNumber(sysfs_path, &host) < 0) return -1; diff --git a/src/storage/storage_backend_iscsi_direct.c b/src/storage/stora= ge_backend_iscsi_direct.c index f0b27451f0..2afa617cc1 100644 --- a/src/storage/storage_backend_iscsi_direct.c +++ b/src/storage/storage_backend_iscsi_direct.c @@ -68,17 +68,17 @@ virStorageBackendISCSIDirectPortal(virStoragePoolSource= Ptr source) return NULL; } if (source->hosts[0].port =3D=3D 0) { - virAsprintf(&portal, "%s:%d", - source->hosts[0].name, - ISCSI_DEFAULT_TARGET_PORT); + portal =3D g_strdup_printf("%s:%d", + source->hosts[0].name, + ISCSI_DEFAULT_TARGET_PORT); } else if (strchr(source->hosts[0].name, ':')) { - virAsprintf(&portal, "[%s]:%d", - source->hosts[0].name, - source->hosts[0].port); + portal =3D g_strdup_printf("[%s]:%d", + source->hosts[0].name, + source->hosts[0].port); } else { - virAsprintf(&portal, "%s:%d", - source->hosts[0].name, - source->hosts[0].port); + portal =3D g_strdup_printf("%s:%d", + source->hosts[0].name, + source->hosts[0].port); } return portal; } @@ -230,11 +230,11 @@ virISCSIDirectSetVolumeAttributes(virStoragePoolObjPt= r pool, { virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); =20 - virAsprintf(&vol->name, "%s%u", VOL_NAME_PREFIX, lun); - virAsprintf(&vol->key, "ip-%s-iscsi-%s-lun-%u", portal, - def->source.devices[0].path, lun); - virAsprintf(&vol->target.path, "ip-%s-iscsi-%s-lun-%u", portal, - def->source.devices[0].path, lun); + vol->name =3D g_strdup_printf("%s%u", VOL_NAME_PREFIX, lun); + vol->key =3D g_strdup_printf("ip-%s-iscsi-%s-lun-%u", portal, + def->source.devices[0].path, lun); + vol->target.path =3D g_strdup_printf("ip-%s-iscsi-%s-lun-%u", portal, + def->source.devices[0].path, lun); return 0; } =20 diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index 4a5d61e57d..48023abd1a 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -291,7 +291,7 @@ virStorageBackendLogicalMakeVol(char **const groups, } =20 if (vol->target.path =3D=3D NULL) - virAsprintf(&vol->target.path, "%s/%s", def->target.path, vol->nam= e); + vol->target.path =3D g_strdup_printf("%s/%s", def->target.path, vo= l->name); =20 /* Mark the (s) sparse/snapshot lv, e.g. the lv created using * the --virtualsize/-V option. We've already ignored the (t)hin @@ -313,8 +313,8 @@ virStorageBackendLogicalMakeVol(char **const groups, if (!(vol->target.backingStore =3D virStorageSourceNew())) goto cleanup; =20 - virAsprintf(&vol->target.backingStore->path, "%s/%s", - def->target.path, groups[1]); + vol->target.backingStore->path =3D g_strdup_printf("%s/%s", + def->target.path,= groups[1]); =20 vol->target.backingStore->format =3D VIR_STORAGE_POOL_LOGICAL_LVM2; vol->target.backingStore->type =3D VIR_STORAGE_TYPE_BLOCK; @@ -912,7 +912,7 @@ virStorageBackendLogicalCreateVol(virStoragePoolObjPtr = pool, vol->type =3D VIR_STORAGE_VOL_BLOCK; =20 VIR_FREE(vol->target.path); - virAsprintf(&vol->target.path, "%s/%s", def->target.path, vol->name); + vol->target.path =3D g_strdup_printf("%s/%s", def->target.path, vol->n= ame); =20 if (virStorageBackendLogicalLVCreate(vol, def) < 0) return -1; diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_back= end_mpath.c index 6912977657..8843dffc30 100644 --- a/src/storage/storage_backend_mpath.c +++ b/src/storage/storage_backend_mpath.c @@ -53,9 +53,9 @@ virStorageBackendMpathNewVol(virStoragePoolObjPtr pool, =20 vol->type =3D VIR_STORAGE_VOL_BLOCK; =20 - virAsprintf(&(vol->name), "dm-%u", devnum); + (vol->name) =3D g_strdup_printf("dm-%u", devnum); =20 - virAsprintf(&vol->target.path, "/dev/%s", dev); + vol->target.path =3D g_strdup_printf("/dev/%s", dev); =20 if (virStorageBackendUpdateVolInfo(vol, true, VIR_STORAGE_VOL_OPEN_DEFAULT, 0) < = 0) { @@ -163,7 +163,7 @@ virStorageBackendCreateVols(virStoragePoolObjPtr pool, =20 if (is_mpath =3D=3D 1) { =20 - virAsprintf(&map_device, "mapper/%s", names->name); + map_device =3D g_strdup_printf("mapper/%s", names->name); =20 if (virStorageBackendGetMinorNumber(names->name, &minor) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index 491b85e0e0..5cf4acf65f 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -570,10 +570,10 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPt= r vol, vol->target.allocation, info.obj_size, info.num_objs); =20 VIR_FREE(vol->target.path); - virAsprintf(&vol->target.path, "%s/%s", def->source.name, vol->name); + vol->target.path =3D g_strdup_printf("%s/%s", def->source.name, vol->n= ame); =20 VIR_FREE(vol->key); - virAsprintf(&vol->key, "%s/%s", def->source.name, vol->name); + vol->key =3D g_strdup_printf("%s/%s", def->source.name, vol->name); =20 ret =3D 0; =20 @@ -891,10 +891,10 @@ virStorageBackendRBDCreateVol(virStoragePoolObjPtr po= ol, } =20 VIR_FREE(vol->target.path); - virAsprintf(&vol->target.path, "%s/%s", def->source.name, vol->name); + vol->target.path =3D g_strdup_printf("%s/%s", def->source.name, vol->n= ame); =20 VIR_FREE(vol->key); - virAsprintf(&vol->key, "%s/%s", def->source.name, vol->name); + vol->key =3D g_strdup_printf("%s/%s", def->source.name, vol->name); =20 return 0; } diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backe= nd_scsi.c index 80965bc349..9c0f041616 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -60,7 +60,7 @@ virStorageBackendSCSITriggerRescan(uint32_t host) =20 VIR_DEBUG("Triggering rescan of host %d", host); =20 - virAsprintf(&path, "%s/host%u/scan", LINUX_SYSFS_SCSI_HOST_PREFIX, hos= t); + path =3D g_strdup_printf("%s/host%u/scan", LINUX_SYSFS_SCSI_HOST_PREFI= X, host); =20 VIR_DEBUG("Scan trigger path is '%s'", path); =20 @@ -259,7 +259,7 @@ checkParent(const char *name, goto cleanup; } =20 - virAsprintf(&scsi_host_name, "scsi_%s", name); + scsi_host_name =3D g_strdup_printf("scsi_%s", name); =20 if (!(vhba_parent =3D virNodeDeviceGetParentName(conn, scsi_host_name)= )) goto cleanup; @@ -373,7 +373,7 @@ virStorageBackendSCSICheckPool(virStoragePoolObjPtr poo= l, if (virSCSIHostGetNumber(name, &host) < 0) return -1; =20 - virAsprintf(&path, "%s/host%d", LINUX_SYSFS_SCSI_HOST_PREFIX, host); + path =3D g_strdup_printf("%s/host%d", LINUX_SYSFS_SCSI_HOST_PREFIX, ho= st); =20 *isActive =3D virFileExists(path); =20 diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_b= ackend_sheepdog.c index ff13d2d9bd..853a53115f 100644 --- a/src/storage/storage_backend_sheepdog.c +++ b/src/storage/storage_backend_sheepdog.c @@ -226,7 +226,7 @@ virStorageBackendSheepdogCreateVol(virStoragePoolObjPtr= pool, vol->type =3D VIR_STORAGE_VOL_NETWORK; =20 VIR_FREE(vol->key); - virAsprintf(&vol->key, "%s/%s", def->source.name, vol->name); + vol->key =3D g_strdup_printf("%s/%s", def->source.name, vol->name); =20 VIR_FREE(vol->target.path); vol->target.path =3D g_strdup(vol->name); @@ -338,7 +338,7 @@ virStorageBackendSheepdogRefreshVol(virStoragePoolObjPt= r pool, vol->type =3D VIR_STORAGE_VOL_NETWORK; =20 VIR_FREE(vol->key); - virAsprintf(&vol->key, "%s/%s", def->source.name, vol->name); + vol->key =3D g_strdup_printf("%s/%s", def->source.name, vol->name); =20 VIR_FREE(vol->target.path); vol->target.path =3D g_strdup(vol->name); diff --git a/src/storage/storage_backend_vstorage.c b/src/storage/storage_b= ackend_vstorage.c index 9a34d87ec3..85ab8325ce 100644 --- a/src/storage/storage_backend_vstorage.c +++ b/src/storage/storage_backend_vstorage.c @@ -61,7 +61,7 @@ virStorageBackendVzPoolStart(virStoragePoolObjPtr pool) if (!(usr_name =3D virGetUserName(def->target.perms.uid))) return -1; =20 - virAsprintf(&mode, "%o", def->target.perms.mode); + mode =3D g_strdup_printf("%o", def->target.perms.mode); =20 cmd =3D virCommandNewArgList(VSTORAGE_MOUNT, "-c", def->source.name, @@ -90,7 +90,7 @@ virStorageBackendVzIsMounted(virStoragePoolObjPtr pool) char buf[1024]; g_autofree char *cluster =3D NULL; =20 - virAsprintf(&cluster, "vstorage://%s", def->source.name); + cluster =3D g_strdup_printf("vstorage://%s", def->source.name); =20 if ((mtab =3D fopen(_PATH_MOUNTED, "r")) =3D=3D NULL) { virReportSystemError(errno, diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backen= d_zfs.c index 793eb06f5c..b708c7fd4a 100644 --- a/src/storage/storage_backend_zfs.c +++ b/src/storage/storage_backend_zfs.c @@ -87,7 +87,7 @@ virStorageBackendZFSCheckPool(virStoragePoolObjPtr pool G= _GNUC_UNUSED, virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); g_autofree char *devpath =3D NULL; =20 - virAsprintf(&devpath, "/dev/zvol/%s", def->source.name); + devpath =3D g_strdup_printf("/dev/zvol/%s", def->source.name); *isActive =3D virFileIsDir(devpath); =20 return 0; @@ -137,8 +137,8 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool, volume->key =3D g_strdup(tokens[0]); =20 if (volume->target.path =3D=3D NULL) { - virAsprintf(&volume->target.path, "%s/%s", def->target.path, - volume->name); + volume->target.path =3D g_strdup_printf("%s/%s", def->target.path, + volume->name); } =20 if (virStrToLong_ull(tokens[1], NULL, 10, &volume->target.capacity) < = 0) { @@ -305,7 +305,7 @@ virStorageBackendZFSCreateVol(virStoragePoolObjPtr pool, vol->type =3D VIR_STORAGE_VOL_BLOCK; =20 VIR_FREE(vol->target.path); - virAsprintf(&vol->target.path, "%s/%s", def->target.path, vol->name); + vol->target.path =3D g_strdup_printf("%s/%s", def->target.path, vol->n= ame); =20 vol->key =3D g_strdup(vol->target.path); =20 diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index dfe3dd1354..84d76eebd0 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -281,9 +281,9 @@ storageStateInitialize(bool privileged, if (!(configdir && rundir)) goto error; =20 - virAsprintf(&driver->configDir, "%s/storage", configdir); - virAsprintf(&driver->autostartDir, "%s/storage/autostart", configd= ir); - virAsprintf(&driver->stateDir, "%s/storage/run", rundir); + driver->configDir =3D g_strdup_printf("%s/storage", configdir); + driver->autostartDir =3D g_strdup_printf("%s/storage/autostart", c= onfigdir); + driver->stateDir =3D g_strdup_printf("%s/storage/run", rundir); } driver->privileged =3D privileged; =20 @@ -2289,7 +2289,7 @@ virStorageBackendPloopRestoreDesc(char *path) g_autofree char *refresh_tool =3D NULL; g_autofree char *desc =3D NULL; =20 - virAsprintf(&desc, "%s/DiskDescriptor.xml", path); + desc =3D g_strdup_printf("%s/DiskDescriptor.xml", path); =20 if (virFileRemove(desc, 0, 0) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -2851,8 +2851,8 @@ virStoragePoolObjBuildTempFilePath(virStoragePoolObjP= tr obj, virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(obj); char *tmp =3D NULL; =20 - virAsprintf(&tmp, "%s/%s.%s.secret.XXXXXX", - driver->stateDir, def->name, voldef->name); + tmp =3D g_strdup_printf("%s/%s.%s.secret.XXXXXX", + driver->stateDir, def->name, voldef->name); return tmp; } =20 diff --git a/src/storage/storage_file_gluster.c b/src/storage/storage_file_= gluster.c index 1577239431..f389a94437 100644 --- a/src/storage/storage_file_gluster.c +++ b/src/storage/storage_file_gluster.c @@ -311,11 +311,11 @@ virStorageFileBackendGlusterGetUniqueIdentifier(virSt= orageSourcePtr src) priv))) return NULL; =20 - virAsprintf(&priv->canonpath, "gluster://%s:%u/%s/%s", - src->hosts->name, - src->hosts->port, - src->volume, - filePath); + priv->canonpath =3D g_strdup_printf("gluster://%s:%u/%s/%s", + src->hosts->name, + src->hosts->port, + src->volume, + filePath); =20 return priv->canonpath; } diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 88fb8b5223..3427c2e446 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -898,7 +898,7 @@ storageBackendCreateQemuImgSetBacking(virStoragePoolObj= Ptr pool, * validation. */ if (*(info->backingPath) !=3D '/') - virAsprintf(&absolutePath, "%s/%s", def->target.path, info->backin= gPath); + absolutePath =3D g_strdup_printf("%s/%s", def->target.path, info->= backingPath); accessRetCode =3D access(absolutePath ? absolutePath : info->backingPath, R_OK); if (accessRetCode !=3D 0) { @@ -1140,7 +1140,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePo= olObjPtr pool, _("path to secret data file is required")); goto error; } - virAsprintf(&info.secretAlias, "%s_encrypt0", vol->name); + info.secretAlias =3D g_strdup_printf("%s_encrypt0", vol->name); if (storageBackendCreateQemuImgSecretObject(cmd, secretPath, info.secretAlias) < 0) goto error; @@ -1153,7 +1153,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePo= olObjPtr pool, _("path to inputvol secret data file is require= d")); goto error; } - virAsprintf(&inputSecretAlias, "%s_encrypt0", inputvol->name); + inputSecretAlias =3D g_strdup_printf("%s_encrypt0", inputvol->name= ); if (storageBackendCreateQemuImgSecretObject(cmd, inputSecretPath, inputSecretAlias) < 0) goto error; @@ -1678,10 +1678,10 @@ storageBackendIsPloopDir(char *path) g_autofree char *root =3D NULL; g_autofree char *desc =3D NULL; =20 - virAsprintf(&root, "%s/root.hds", path); + root =3D g_strdup_printf("%s/root.hds", path); if (!virFileExists(root)) return false; - virAsprintf(&desc, "%s/DiskDescriptor.xml", path); + desc =3D g_strdup_printf("%s/DiskDescriptor.xml", path); if (!virFileExists(desc)) return false; =20 @@ -1699,7 +1699,7 @@ storageBackendRedoPloopUpdate(virStorageSourcePtr tar= get, struct stat *sb, { g_autofree char *path =3D NULL; =20 - virAsprintf(&path, "%s/root.hds", target->path); + path =3D g_strdup_printf("%s/root.hds", target->path); VIR_FORCE_CLOSE(*fd); if ((*fd =3D virStorageBackendVolOpen(path, sb, flags)) < 0) return -1; @@ -1949,7 +1949,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool, */ retry: while ((direrr =3D virDirRead(dh, &dent, NULL)) > 0) { - virAsprintf(&stablepath, "%s/%s", def->target.path, dent->d_name); + stablepath =3D g_strdup_printf("%s/%s", def->target.path, dent->d_= name); =20 if (virFileLinkPointsTo(stablepath, devpath)) { VIR_DIR_CLOSE(dh); @@ -2045,7 +2045,7 @@ virStorageBackendVolCreateLocal(virStoragePoolObjPtr = pool, } =20 VIR_FREE(vol->target.path); - virAsprintf(&vol->target.path, "%s/%s", def->target.path, vol->name); + vol->target.path =3D g_strdup_printf("%s/%s", def->target.path, vol->n= ame); =20 if (virFileExists(vol->target.path)) { virReportError(VIR_ERR_OPERATION_INVALID, @@ -2282,7 +2282,7 @@ storageBackendResizeQemuImg(virStoragePoolObjPtr pool, storageBackendCreateQemuImgSecretPath(pool, vol))) goto cleanup; =20 - virAsprintf(&secretAlias, "%s_encrypt0", vol->name); + secretAlias =3D g_strdup_printf("%s_encrypt0", vol->name); } =20 /* Round capacity as qemu-img resize errors out on sizes which are not @@ -2419,7 +2419,7 @@ virStorageBackendVolUploadLocal(virStoragePoolObjPtr = pool G_GNUC_UNUSED, return -1; } =20 - virAsprintf(&path, "%s/root.hds", vol->target.path); + path =3D g_strdup_printf("%s/root.hds", vol->target.path); target_path =3D path; } =20 @@ -2453,7 +2453,7 @@ virStorageBackendVolDownloadLocal(virStoragePoolObjPt= r pool G_GNUC_UNUSED, " will be lost")); return -1; } - virAsprintf(&path, "%s/root.hds", vol->target.path); + path =3D g_strdup_printf("%s/root.hds", vol->target.path); target_path =3D path; } =20 @@ -2665,9 +2665,9 @@ storageBackendVolWipePloop(virStorageVolDefPtr vol, return -1; } =20 - virAsprintf(&target_path, "%s/root.hds", vol->target.path); + target_path =3D g_strdup_printf("%s/root.hds", vol->target.path); =20 - virAsprintf(&disk_desc, "%s/DiskDescriptor.xml", vol->target.path); + disk_desc =3D g_strdup_printf("%s/DiskDescriptor.xml", vol->target.pat= h); =20 if (storageBackendVolWipeLocalFile(target_path, algorithm, vol->target.allocation, false) < 0) @@ -3525,7 +3525,7 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr po= ol) vol->name =3D g_strdup(ent->d_name); =20 vol->type =3D VIR_STORAGE_VOL_FILE; - virAsprintf(&vol->target.path, "%s/%s", def->target.path, vol->nam= e); + vol->target.path =3D g_strdup_printf("%s/%s", def->target.path, vo= l->name); =20 vol->key =3D g_strdup(vol->target.path); =20 @@ -3666,9 +3666,9 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool, * in the volume name. We only need uniqueness per-pool, so * just leave 'host' out */ - virAsprintf(&(vol->name), "unit:%u:%u:%u", bus, target, lun); + (vol->name) =3D g_strdup_printf("unit:%u:%u:%u", bus, target, lun); =20 - virAsprintf(&devpath, "/dev/%s", dev); + devpath =3D g_strdup_printf("/dev/%s", dev); =20 VIR_DEBUG("Trying to create volume for '%s'", devpath); =20 @@ -3728,7 +3728,7 @@ getNewStyleBlockDevice(const char *lun_path, int direrr; g_autofree char *block_path =3D NULL; =20 - virAsprintf(&block_path, "%s/block", lun_path); + block_path =3D g_strdup_printf("%s/block", lun_path); =20 VIR_DEBUG("Looking for block device in '%s'", block_path); =20 @@ -3806,8 +3806,8 @@ getBlockDevice(uint32_t host, =20 *block_device =3D NULL; =20 - virAsprintf(&lun_path, "/sys/bus/scsi/devices/%u:%u:%u:%u", host, bus, - target, lun); + lun_path =3D g_strdup_printf("/sys/bus/scsi/devices/%u:%u:%u:%u", host= , bus, + target, lun); =20 if (virDirOpen(&lun_dir, lun_path) < 0) goto cleanup; @@ -3859,8 +3859,8 @@ getDeviceType(uint32_t host, FILE *typefile; g_autofree char *type_path =3D NULL; =20 - virAsprintf(&type_path, "/sys/bus/scsi/devices/%u:%u:%u:%u/type", host, - bus, target, lun); + type_path =3D g_strdup_printf("/sys/bus/scsi/devices/%u:%u:%u:%u/type"= , host, + bus, target, lun); =20 typefile =3D fopen(type_path, "r"); if (typefile =3D=3D NULL) { @@ -4048,11 +4048,11 @@ virStorageBackendFileSystemGetPoolSource(virStorage= PoolObjPtr pool) =20 if (def->type =3D=3D VIR_STORAGE_POOL_NETFS) { if (def->source.format =3D=3D VIR_STORAGE_POOL_NETFS_CIFS) { - virAsprintf(&src, "//%s/%s", def->source.hosts[0].name, - def->source.dir); + src =3D g_strdup_printf("//%s/%s", def->source.hosts[0].name, + def->source.dir); } else { - virAsprintf(&src, "%s:%s", def->source.hosts[0].name, - def->source.dir); + src =3D g_strdup_printf("%s:%s", def->source.hosts[0].name, + def->source.dir); } } else { src =3D g_strdup(def->source.devices[0].path); @@ -4168,7 +4168,7 @@ virStorageBackendFileSystemMountCmd(const char *cmdst= r, g_autofree char *nfsVers =3D NULL; =20 if (def->type =3D=3D VIR_STORAGE_POOL_NETFS && def->source.protocolVer= > 0) - virAsprintf(&nfsVers, "nfsvers=3D%u", def->source.protocolVer); + nfsVers =3D g_strdup_printf("nfsvers=3D%u", def->source.protocolVe= r); =20 cmd =3D virCommandNew(cmdstr); if (netauto) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list