test: Use g_strdup_printf() instead of virAsprintf()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
Michal Privoznik 2019-10-22 15:26:14 +02:00
parent 930cae510b
commit ad1118ebd2

View File

@ -640,8 +640,7 @@ testDomainGenerateIfname(virDomainDefPtr domdef)
virDomainNetDefPtr net = NULL;
char *ifname;
if (virAsprintf(&ifname, "testnet%d", ifctr) < 0)
return NULL;
ifname = g_strdup_printf("testnet%d", ifctr);
/* Generate network interface names */
if (!(net = virDomainNetFindByName(domdef, ifname)))
@ -1076,8 +1075,7 @@ testOpenVolumesForPool(const char *file,
g_autoptr(virStorageVolDef) volDef = NULL;
/* Find storage volumes */
if (virAsprintf(&vol_xpath, "/node/pool[%d]/volume", objidx) < 0)
return -1;
vol_xpath = g_strdup_printf("/node/pool[%d]/volume", objidx);
num = virXPathNodeSet(vol_xpath, ctxt, &nodes);
if (num < 0)
@ -1093,9 +1091,8 @@ testOpenVolumesForPool(const char *file,
return -1;
if (!volDef->target.path) {
if (virAsprintf(&volDef->target.path, "%s/%s",
def->target.path, volDef->name) < 0)
return -1;
volDef->target.path = g_strdup_printf("%s/%s", def->target.path,
volDef->name);
}
if (!volDef->key)
@ -2046,7 +2043,7 @@ testDomainGetHostname(virDomainPtr domain,
if (virDomainObjCheckActive(vm) < 0)
goto cleanup;
ignore_value(virAsprintf(&ret, "%shost", domain->name));
ret = g_strdup_printf("%shost", domain->name);
cleanup:
virDomainObjEndAPI(&vm);
@ -4735,8 +4732,7 @@ testDomainGetFSInfo(virDomainPtr dom,
info_ret[0]->mountpoint = g_strdup("/");
info_ret[0]->fstype = g_strdup("ext4");
info_ret[0]->devAlias[0] = g_strdup(name);
if (virAsprintf(&info_ret[0]->name, "%s1", name) < 0)
goto cleanup;
info_ret[0]->name = g_strdup_printf("%s1", name);
if (VIR_ALLOC(info_ret[1]) < 0 ||
VIR_ALLOC(info_ret[1]->devAlias) < 0)
@ -4745,8 +4741,7 @@ testDomainGetFSInfo(virDomainPtr dom,
info_ret[1]->mountpoint = g_strdup("/boot");
info_ret[1]->fstype = g_strdup("ext4");
info_ret[1]->devAlias[0] = g_strdup(name);
if (virAsprintf(&info_ret[1]->name, "%s2", name) < 0)
goto cleanup;
info_ret[1]->name = g_strdup_printf("%s2", name);
info_ret[0]->ndevAlias = info_ret[1]->ndevAlias = 1;
@ -5112,8 +5107,7 @@ testDomainInterfaceAddresses(virDomainPtr dom,
} else {
iface->addrs[0].type = VIR_IP_ADDR_TYPE_IPV4;
iface->addrs[0].prefix = 24;
if (virAsprintf(&iface->addrs[0].addr, "192.168.0.%zu", 1 + i) < 0)
goto cleanup;
iface->addrs[0].addr = g_strdup_printf("192.168.0.%zu", 1 + i);
}
@ -6354,8 +6348,7 @@ testConnectFindStoragePoolSources(virConnectPtr conn G_GNUC_UNUSED,
return NULL;
}
ignore_value(virAsprintf(&ret, defaultPoolSourcesNetFSXML,
source->hosts[0].name));
ret = g_strdup_printf(defaultPoolSourcesNetFSXML, source->hosts[0].name);
return ret;
default:
@ -6998,9 +6991,8 @@ testStorageVolCreateXML(virStoragePoolPtr pool,
goto cleanup;
}
if (virAsprintf(&privvol->target.path, "%s/%s",
def->target.path, privvol->name) < 0)
goto cleanup;
privvol->target.path = g_strdup_printf("%s/%s", def->target.path,
privvol->name);
privvol->key = g_strdup(privvol->target.path);
if (virStoragePoolObjAddVol(obj, privvol) < 0)
@ -7066,9 +7058,8 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool,
}
def->available = (def->capacity - def->allocation);
if (virAsprintf(&privvol->target.path, "%s/%s",
def->target.path, privvol->name) < 0)
goto cleanup;
privvol->target.path = g_strdup_printf("%s/%s", def->target.path,
privvol->name);
privvol->key = g_strdup(privvol->target.path);
if (virStoragePoolObjAddVol(obj, privvol) < 0)