On 10/22/19 10:58 AM, Michal Privoznik wrote:
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tests/bhyveargv2xmltest.c | 10 ++--
tests/bhyvexml2argvtest.c | 18 +++----
tests/bhyvexml2xmltest.c | 10 ++--
tests/commandtest.c | 18 +++----
tests/cputest.c | 60 ++++++++++-----------
tests/domaincapstest.c | 16 +++---
tests/domainconftest.c | 4 +-
tests/fchosttest.c | 2 +-
tests/fdstreamtest.c | 4 +-
tests/genericxml2xmltest.c | 8 +--
tests/interfacexml2xmltest.c | 4 +-
tests/libxlxml2domconfigtest.c | 4 +-
tests/lxcconf2xmltest.c | 16 +++---
tests/lxcxml2xmltest.c | 8 +--
tests/networkxml2conftest.c | 4 +-
tests/networkxml2firewalltest.c | 10 ++--
tests/networkxml2xmltest.c | 4 +-
tests/networkxml2xmlupdatetest.c | 12 ++---
tests/nodedevxml2xmltest.c | 4 +-
tests/nssmock.c | 6 +--
tests/nwfilterxml2firewalltest.c | 12 ++---
tests/nwfilterxml2xmltest.c | 4 +-
tests/openvzutilstest.c | 4 +-
tests/qemuagenttest.c | 2 +-
tests/qemublocktest.c | 22 ++++----
tests/qemucapabilitiestest.c | 16 +++---
tests/qemucaps2xmltest.c | 10 ++--
tests/qemudomaincheckpointxml2xmltest.c | 2 +-
tests/qemudomainsnapshotxml2xmltest.c | 2 +-
tests/qemufirmwaretest.c | 2 +-
tests/qemuhotplugtest.c | 26 ++++-----
tests/qemumemlocktest.c | 4 +-
tests/qemumigparamstest.c | 20 +++----
tests/qemumonitorjsontest.c | 50 +++++++++---------
tests/qemumonitortestutils.c | 24 ++++-----
tests/qemusecuritymock.c | 2 +-
tests/qemusecuritytest.c | 2 +-
tests/qemuvhostusertest.c | 2 +-
tests/qemuxml2argvtest.c | 18 +++----
tests/qemuxml2xmltest.c | 18 +++----
tests/scsihosttest.c | 14 ++---
tests/secretxml2xmltest.c | 10 ++--
tests/securityselinuxlabeltest.c | 16 +++---
tests/storagebackendsheepdogtest.c | 8 +--
tests/storagepoolcapstest.c | 4 +-
tests/storagepoolxml2argvtest.c | 8 +--
tests/storagepoolxml2xmltest.c | 8 +--
tests/storagevolxml2argvtest.c | 22 ++++----
tests/storagevolxml2xmltest.c | 12 ++---
tests/sysinfotest.c | 8 +--
tests/testutils.c | 10 ++--
tests/testutils.h | 2 +-
tests/testutilsqemu.c | 8 +--
tests/vboxsnapshotxmltest.c | 4 +-
tests/virbuftest.c | 2 +-
tests/vircaps2xmltest.c | 12 ++---
tests/vircgroupmock.c | 8 +--
tests/vircgrouptest.c | 2 +-
tests/virconftest.c | 4 +-
tests/virfilemock.c | 2 +-
tests/virfiletest.c | 2 +-
tests/virfilewrapper.c | 2 +-
tests/virhostcputest.c | 32 +++++------
tests/virjsontest.c | 24 ++++-----
tests/virmacmaptest.c | 6 +--
tests/virnetdaemontest.c | 8 +--
tests/virnetdevmock.c | 4 +-
tests/virnetdevopenvswitchtest.c | 4 +-
tests/virnetsockettest.c | 4 +-
tests/virnetworkportxml2xmltest.c | 4 +-
tests/virnumamock.c | 2 +-
tests/virnwfilterbindingxml2xmltest.c | 4 +-
tests/virpcimock.c | 70 ++++++++++++-------------
tests/virpcitest.c | 10 ++--
tests/virrandommock.c | 4 +-
tests/virresctrltest.c | 12 ++---
tests/virschematest.c | 10 ++--
tests/virscsitest.c | 6 +--
tests/virshtest.c | 4 +-
tests/virstoragetest.c | 58 ++++++++++----------
tests/virtestmock.c | 2 +-
tests/virusbmock.c | 2 +-
tests/virusbtest.c | 4 +-
tests/vmwarevertest.c | 2 +-
tests/vmx2xmltest.c | 12 ++---
tests/xlconfigtest.c | 4 +-
tests/xmconfigtest.c | 4 +-
tests/xml2vmxtest.c | 12 ++---
88 files changed, 467 insertions(+), 473 deletions(-)
[...]
diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index 04dc347fd8..a78f97d2ae 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -245,14 +245,14 @@ testQemuHotplug(const void *data)
qemuMonitorTestPtr test_mon = NULL;
qemuDomainObjPrivatePtr priv = NULL;
- virAsprintf(&domain_filename,
"%s/qemuhotplugtestdomains/qemuhotplug-%s.xml",
- abs_srcdir, test->domain_filename);
- virAsprintf(&device_filename,
"%s/qemuhotplugtestdevices/qemuhotplug-%s.xml",
- abs_srcdir, test->device_filename);
- virAsprintf(&result_filename,
- "%s/qemuhotplugtestdomains/qemuhotplug-%s+%s.xml",
- abs_srcdir, test->domain_filename,
- test->device_filename);
+ domain_filename =
g_strdup_printf("%s/qemuhotplugtestdomains/qemuhotplug-%s.xml",
+ abs_srcdir, test->domain_filename);
+ device_filename =
g_strdup_printf("%s/qemuhotplugtestdevices/qemuhotplug-%s.xml",
+ abs_srcdir, test->device_filename);
+ result_filename = g_strdup_printf(
+
"%s/qemuhotplugtestdomains/qemuhotplug-%s+%s.xml",
+ abs_srcdir, test->domain_filename,
+ test->device_filename);
Extra newline after the '('.
if (virTestLoadFile(domain_filename, &domain_xml) < 0 ||
virTestLoadFile(device_filename, &device_xml) < 0)
@@ -408,17 +408,17 @@ testQemuHotplugCpuPrepare(const char *test,
char *prefix = NULL;
struct testQemuHotplugCpuData *data = NULL;
- virAsprintf(&prefix, "%s/qemuhotplugtestcpus/%s", abs_srcdir, test);
+ prefix = g_strdup_printf("%s/qemuhotplugtestcpus/%s", abs_srcdir, test);
if (VIR_ALLOC(data) < 0)
goto error;
data->modern = modern;
- virAsprintf(&data->file_xml_dom, "%s-domain.xml", prefix);
- virAsprintf(&data->file_xml_res_live, "%s-result-live.xml",
prefix);
- virAsprintf(&data->file_xml_res_conf, "%s-result-conf.xml",
prefix);
- virAsprintf(&data->file_json_monitor, "%s-monitor.json", prefix);
+ data->file_xml_dom = g_strdup_printf("%s-domain.xml", prefix);
+ data->file_xml_res_live = g_strdup_printf("%s-result-live.xml",
prefix);
+ data->file_xml_res_conf = g_strdup_printf("%s-result-conf.xml",
prefix);
+ data->file_json_monitor = g_strdup_printf("%s-monitor.json", prefix);
if (virTestLoadFile(data->file_xml_dom, &data->xml_dom) < 0)
goto error;
diff --git a/tests/qemumemlocktest.c b/tests/qemumemlocktest.c
index 8e395759e1..d5a4fb1268 100644
--- a/tests/qemumemlocktest.c
+++ b/tests/qemumemlocktest.c
@@ -34,8 +34,8 @@ testCompareMemLock(const void *data)
char *xml = NULL;
int ret = -1;
- virAsprintf(&xml, "%s/qemumemlockdata/qemumemlock-%s.xml",
abs_srcdir,
- info->name);
+ xml = g_strdup_printf("%s/qemumemlockdata/qemumemlock-%s.xml",
abs_srcdir,
+ info->name);
if (!(def = virDomainDefParseFile(xml, driver.caps, driver.xmlopt, NULL,
VIR_DOMAIN_DEF_PARSE_INACTIVE))) {
diff --git a/tests/qemumigparamstest.c b/tests/qemumigparamstest.c
index ded3a8ef64..b36aa60302 100644
--- a/tests/qemumigparamstest.c
+++ b/tests/qemumigparamstest.c
@@ -66,8 +66,8 @@ qemuMigParamsTestXML2XML(const void *opaque)
char *actualXML = NULL;
int ret = -1;
- virAsprintf(&xmlFile, "%s/qemumigparamsdata/%s.xml", abs_srcdir,
- data->name);
+ xmlFile = g_strdup_printf("%s/qemumigparamsdata/%s.xml", abs_srcdir,
+ data->name);
if (!(doc = virXMLParseFileCtxt(xmlFile, &ctxt)))
goto cleanup;
@@ -109,10 +109,10 @@ qemuMigParamsTestXML(const void *opaque)
char *actualXML = NULL;
int ret = -1;
- virAsprintf(&replyFile, "%s/qemumigparamsdata/%s.reply",
- abs_srcdir, data->name);
- virAsprintf(&xmlFile, "%s/qemumigparamsdata/%s.xml",
- abs_srcdir, data->name);
+ replyFile = g_strdup_printf("%s/qemumigparamsdata/%s.reply",
+ abs_srcdir, data->name);
+ xmlFile = g_strdup_printf("%s/qemumigparamsdata/%s.xml",
+ abs_srcdir, data->name);
if (!(mon = qemuMonitorTestNewFromFile(replyFile, data->xmlopt, true)))
goto cleanup;
@@ -159,10 +159,10 @@ qemuMigParamsTestJSON(const void *opaque)
char *actualJSON = NULL;
int ret = -1;
- virAsprintf(&replyFile, "%s/qemumigparamsdata/%s.reply",
- abs_srcdir, data->name);
- virAsprintf(&jsonFile, "%s/qemumigparamsdata/%s.json",
- abs_srcdir, data->name);
+ replyFile = g_strdup_printf("%s/qemumigparamsdata/%s.reply",
+ abs_srcdir, data->name);
+ jsonFile = g_strdup_printf("%s/qemumigparamsdata/%s.json",
+ abs_srcdir, data->name);
if (!(mon = qemuMonitorTestNewFromFile(replyFile, data->xmlopt, true)))
goto cleanup;
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index c87f7db2e0..2420ac8e18 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -796,9 +796,9 @@ qemuMonitorJSONTestAttachOneChardev(virDomainXMLOptionPtr xmlopt,
if (!reply)
reply = "";
- virAsprintf(&jsonreply, "{\"return\": {%s}}", reply);
+ jsonreply = g_strdup_printf("{\"return\": {%s}}", reply);
- virAsprintf(&fulllabel, "qemuMonitorJSONTestAttachChardev(%s)",
label);
+ fulllabel = g_strdup_printf("qemuMonitorJSONTestAttachChardev(%s)",
label);
data.chr = chr;
data.fail = fail;
@@ -2457,12 +2457,12 @@ testQemuMonitorJSONGetCPUData(const void *opaque)
if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
return -1;
- virAsprintf(&jsonFile,
- "%s/qemumonitorjsondata/qemumonitorjson-getcpu-%s.json",
- abs_srcdir, data->name);
- virAsprintf(&dataFile,
- "%s/qemumonitorjsondata/qemumonitorjson-getcpu-%s.data",
- abs_srcdir, data->name);
+ jsonFile = g_strdup_printf(
+
"%s/qemumonitorjsondata/qemumonitorjson-getcpu-%s.json",
+ abs_srcdir, data->name);
+ dataFile = g_strdup_printf(
+
"%s/qemumonitorjsondata/qemumonitorjson-getcpu-%s.data",
+ abs_srcdir, data->name);
if (virTestLoadFile(jsonFile, &jsonStr) < 0)
goto cleanup;
@@ -2709,15 +2709,15 @@ testQemuMonitorCPUInfo(const void *opaque)
if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
return -1;
- virAsprintf(&queryCpusFile,
-
"%s/qemumonitorjsondata/qemumonitorjson-cpuinfo-%s-cpus.json",
- abs_srcdir, data->name);
- virAsprintf(&queryHotpluggableFile,
-
"%s/qemumonitorjsondata/qemumonitorjson-cpuinfo-%s-hotplug.json",
- abs_srcdir, data->name);
- virAsprintf(&dataFile,
- "%s/qemumonitorjsondata/qemumonitorjson-cpuinfo-%s.data",
- abs_srcdir, data->name);
+ queryCpusFile = g_strdup_printf(
+
"%s/qemumonitorjsondata/qemumonitorjson-cpuinfo-%s-cpus.json",
+ abs_srcdir, data->name);
Extra newline after the '('.
+ queryHotpluggableFile = g_strdup_printf(
+
"%s/qemumonitorjsondata/qemumonitorjson-cpuinfo-%s-hotplug.json",
+ abs_srcdir, data->name);
+ dataFile = g_strdup_printf(
+
"%s/qemumonitorjsondata/qemumonitorjson-cpuinfo-%s.data",
+ abs_srcdir, data->name);
Extra newline after the '('.
if (virTestLoadFile(queryCpusFile, &queryCpusStr) < 0)
goto cleanup;
@@ -2812,8 +2812,8 @@ testBlockNodeNameDetect(const void *opaque)
virBuffer buf = VIR_BUFFER_INITIALIZER;
int ret = -1;
- virAsprintf(&resultFile, "%s/%s%s.result", abs_srcdir, pathprefix,
- testname);
+ resultFile = g_strdup_printf("%s/%s%s.result", abs_srcdir, pathprefix,
+ testname);
if (!(namedNodesJson = virTestLoadFileJSON(pathprefix, testname,
"-named-nodes.json", NULL)))
@@ -2956,12 +2956,12 @@ testQueryJobs(const void *opaque)
if (!test)
return -1;
- virAsprintf(&filenameJSON,
- abs_srcdir "/qemumonitorjsondata/query-jobs-%s.json",
- data->name);
- virAsprintf(&filenameResult,
- abs_srcdir "/qemumonitorjsondata/query-jobs-%s.result",
- data->name);
+ filenameJSON = g_strdup_printf(
+ abs_srcdir
"/qemumonitorjsondata/query-jobs-%s.json",
+ data->name);
Extra newline after the '('.
+ filenameResult = g_strdup_printf(
+ abs_srcdir
"/qemumonitorjsondata/query-jobs-%s.result",
+ data->name);
Extra newline after the '('.
if (virTestLoadFile(filenameJSON, &fileJSON) < 0)
goto cleanup;
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index b7625bb157..3c93468a4e 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -145,8 +145,8 @@ qemuMonitorTestAddErrorResponse(qemuMonitorTestPtr test,
}
/* format the JSON error message */
- virAsprintf(&jsonmsg, "{ \"error\": " " {
\"desc\": \"%s\", "
- " \"class\": \"UnexpectedCommand\" } }",
escapemsg);
+ jsonmsg = g_strdup_printf("{ \"error\": " " {
\"desc\": \"%s\", "
+ " \"class\":
\"UnexpectedCommand\" } }", escapemsg);
return qemuMonitorTestAddResponse(test, jsonmsg);
}
@@ -158,7 +158,7 @@ qemuMonitorTestAddUnexpectedErrorResponse(qemuMonitorTestPtr test,
{
g_autofree char *msg = NULL;
- virAsprintf(&msg, "unexpected command: '%s'", command);
+ msg = g_strdup_printf("unexpected command: '%s'", command);
return qemuMonitorTestAddErrorResponse(test, msg);
}
@@ -171,8 +171,8 @@ qemuMonitorTestAddInvalidCommandResponse(qemuMonitorTestPtr test,
{
g_autofree char *msg = NULL;
- virAsprintf(&msg, "expected command '%s' got '%s'",
expectedcommand,
- actualcommand);
+ msg = g_strdup_printf("expected command '%s' got '%s'",
expectedcommand,
+ actualcommand);
return qemuMonitorTestAddErrorResponse(test, msg);
}
@@ -191,8 +191,8 @@ qemuMonitorReportError(qemuMonitorTestPtr test, const char *errmsg,
...)
if (virVasprintf(&msg, errmsg, msgargs) < 0)
goto cleanup;
- virAsprintf(&jsonmsg, "{ \"error\": " " {
\"desc\": \"%s\", "
- " \"class\": \"UnexpectedCommand\" } }",
msg);
+ jsonmsg = g_strdup_printf("{ \"error\": " " {
\"desc\": \"%s\", "
+ " \"class\":
\"UnexpectedCommand\" } }", msg);
ret = qemuMonitorTestAddResponse(test, jsonmsg);
@@ -522,7 +522,7 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr
test,
if (STREQ(cmdname, "device_add"))
return 0;
- virAsprintf(&schemapath, "%s/arg-type", cmdname);
+ schemapath = g_strdup_printf("%s/arg-type", cmdname);
if (virQEMUQAPISchemaPathGet(schemapath, test->qapischema, &schemaroot) <
0 ||
!schemaroot) {
@@ -640,7 +640,7 @@ qemuMonitorTestProcessCommandVerbatim(qemuMonitorTestPtr test,
ret = qemuMonitorTestAddResponse(test, data->response);
} else {
if (data->cmderr) {
- virAsprintf(&errmsg, "%s: %s", data->cmderr, cmdstr);
+ errmsg = g_strdup_printf("%s: %s", data->cmderr, cmdstr);
ret = qemuMonitorTestAddErrorResponse(test, errmsg);
} else {
@@ -731,7 +731,7 @@ qemuMonitorTestProcessGuestAgentSync(qemuMonitorTestPtr test,
goto cleanup;
}
- virAsprintf(&retmsg, "{\"return\":%llu}", id);
+ retmsg = g_strdup_printf("{\"return\":%llu}", id);
ret = qemuMonitorTestAddResponse(test, retmsg);
@@ -1057,7 +1057,7 @@ qemuMonitorCommonTestNew(virDomainXMLOptionPtr xmlopt,
tmpdir_template = NULL;
- virAsprintf(&path, "%s/qemumonitorjsontest.sock", test->tmpdir);
+ path = g_strdup_printf("%s/qemumonitorjsontest.sock", test->tmpdir);
if (vm) {
test->vm = virObjectRef(vm);
@@ -1285,7 +1285,7 @@ qemuMonitorTestFullAddItem(qemuMonitorTestPtr test,
char *cmderr;
int ret;
- virAsprintf(&cmderr, "wrong expected command in %s:%zu: ", filename,
line);
+ cmderr = g_strdup_printf("wrong expected command in %s:%zu: ", filename,
line);
ret = qemuMonitorTestAddItemVerbatim(test, command, cmderr, response);
diff --git a/tests/qemusecuritymock.c b/tests/qemusecuritymock.c
index 63bcae0f27..ad182c7bf7 100644
--- a/tests/qemusecuritymock.c
+++ b/tests/qemusecuritymock.c
@@ -117,7 +117,7 @@ get_key(const char *path,
{
char *ret;
- virAsprintf(&ret, "%s:%s", path, name);
+ ret = g_strdup_printf("%s:%s", path, name);
return ret;
}
diff --git a/tests/qemusecuritytest.c b/tests/qemusecuritytest.c
index e8ebbf36d8..685ac4dca2 100644
--- a/tests/qemusecuritytest.c
+++ b/tests/qemusecuritytest.c
@@ -45,7 +45,7 @@ prepareObjects(virQEMUDriverPtr driver,
g_autofree char *domxml = NULL;
g_autofree char *latestCapsFile = NULL;
- virAsprintf(&filename, "%s/qemuxml2argvdata/%s.xml", abs_srcdir,
xmlname);
+ filename = g_strdup_printf("%s/qemuxml2argvdata/%s.xml", abs_srcdir,
xmlname);
if (virTestLoadFile(filename, &domxml) < 0)
return -1;
diff --git a/tests/qemuvhostusertest.c b/tests/qemuvhostusertest.c
index 903e6631dc..cc1e523841 100644
--- a/tests/qemuvhostusertest.c
+++ b/tests/qemuvhostusertest.c
@@ -24,7 +24,7 @@ testParseFormatVU(const void *opaque)
g_autofree char *expected = NULL;
g_autofree char *actual = NULL;
- virAsprintf(&path, "%s/qemuvhostuserdata/%s", abs_srcdir, filename);
+ path = g_strdup_printf("%s/qemuvhostuserdata/%s", abs_srcdir, filename);
if (!(vu = qemuVhostUserParse(path)))
return -1;
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 39bc3b0aef..1aca59a3e3 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -106,8 +106,8 @@ fakeStoragePoolLookupByName(virConnectPtr conn,
virStoragePoolPtr ret = NULL;
if (STRNEQ(name, "inactive")) {
- virAsprintf(&xmlpath, "%s/%s%s.xml", abs_srcdir,
- STORAGE_POOL_XML_PATH, name);
+ xmlpath = g_strdup_printf("%s/%s%s.xml", abs_srcdir,
+ STORAGE_POOL_XML_PATH, name);
if (!virFileExists(xmlpath)) {
virReportError(VIR_ERR_NO_STORAGE_POOL,
@@ -187,7 +187,7 @@ fakeStorageVolGetPath(virStorageVolPtr vol)
{
char *ret = NULL;
- virAsprintf(&ret, "/some/%s/device/%s", vol->key, vol->name);
+ ret = g_strdup_printf("/some/%s/device/%s", vol->key, vol->name);
return ret;
}
@@ -205,8 +205,8 @@ fakeStoragePoolGetXMLDesc(virStoragePoolPtr pool,
return NULL;
}
- virAsprintf(&xmlpath, "%s/%s%s.xml", abs_srcdir,
STORAGE_POOL_XML_PATH,
- pool->name);
+ xmlpath = g_strdup_printf("%s/%s%s.xml", abs_srcdir,
STORAGE_POOL_XML_PATH,
+ pool->name);
if (virTestLoadFile(xmlpath, &xmlbuf) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -592,10 +592,10 @@ static void
testInfoSetPaths(struct testQemuInfo *info,
const char *suffix)
{
- virAsprintf(&info->infile, "%s/qemuxml2argvdata/%s.xml",
- abs_srcdir, info->name);
- virAsprintf(&info->outfile, "%s/qemuxml2argvdata/%s%s.args",
- abs_srcdir, info->name, suffix ? suffix : "");
+ info->infile = g_strdup_printf("%s/qemuxml2argvdata/%s.xml",
+ abs_srcdir, info->name);
+ info->outfile = g_strdup_printf("%s/qemuxml2argvdata/%s%s.args",
+ abs_srcdir, info->name, suffix ? suffix :
"");
}
# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 679b882704..02bbc504ae 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -98,18 +98,18 @@ testInfoSetPaths(struct testQemuInfo *info,
VIR_FREE(info->infile);
VIR_FREE(info->outfile);
- virAsprintf(&info->infile, "%s/qemuxml2argvdata/%s.xml",
abs_srcdir,
- info->name);
+ info->infile = g_strdup_printf("%s/qemuxml2argvdata/%s.xml",
abs_srcdir,
+ info->name);
- virAsprintf(&info->outfile, "%s/qemuxml2xmloutdata/%s-%s%s.xml",
- abs_srcdir, info->name,
- when == WHEN_ACTIVE ? "active" : "inactive",
suffix);
+ info->outfile = g_strdup_printf("%s/qemuxml2xmloutdata/%s-%s%s.xml",
+ abs_srcdir, info->name,
+ when == WHEN_ACTIVE ? "active" :
"inactive", suffix);
if (!virFileExists(info->outfile)) {
VIR_FREE(info->outfile);
- virAsprintf(&info->outfile, "%s/qemuxml2xmloutdata/%s%s.xml",
- abs_srcdir, info->name, suffix);
+ info->outfile = g_strdup_printf("%s/qemuxml2xmloutdata/%s%s.xml",
+ abs_srcdir, info->name, suffix);
}
return 0;
@@ -121,8 +121,8 @@ static const char *statusPath = abs_srcdir
"/qemustatusxml2xmldata/";
static void
testInfoSetStatusPaths(struct testQemuInfo *info)
{
- virAsprintf(&info->infile, "%s%s-in.xml", statusPath,
info->name);
- virAsprintf(&info->outfile, "%s%s-out.xml", statusPath,
info->name);
+ info->infile = g_strdup_printf("%s%s-in.xml", statusPath,
info->name);
+ info->outfile = g_strdup_printf("%s%s-out.xml", statusPath,
info->name);
}
diff --git a/tests/scsihosttest.c b/tests/scsihosttest.c
index 947a81560a..b35ec6980a 100644
--- a/tests/scsihosttest.c
+++ b/tests/scsihosttest.c
@@ -72,10 +72,10 @@ create_scsihost(const char *fakesysfsdir, const char *devicepath,
int ret = -1;
int fd = -1;
- virAsprintf(&unique_id_path, "%s/devices/pci0000:00/%s/unique_id",
- fakesysfsdir, devicepath);
- virAsprintf(&link_path, "%s/class/scsi_host/%s",
- fakesysfsdir, hostname);
+ unique_id_path = g_strdup_printf("%s/devices/pci0000:00/%s/unique_id",
+ fakesysfsdir, devicepath);
+ link_path = g_strdup_printf("%s/class/scsi_host/%s",
+ fakesysfsdir, hostname);
/* Rather than create path & file, temporarily snip off the file to
* create the path
@@ -205,7 +205,7 @@ testVirFindSCSIHostByPCI(const void *data G_GNUC_UNUSED)
char *ret_host = NULL;
int ret = -1;
- virAsprintf(&path_addr, "%s/%s", abs_srcdir,
"sysfs/class/scsi_host");
+ path_addr = g_strdup_printf("%s/%s", abs_srcdir,
"sysfs/class/scsi_host");
if (!(ret_host = virSCSIHostFindByPCI(TEST_SCSIHOST_CLASS_PATH,
pci_addr1, unique_id1)) ||
@@ -255,14 +255,14 @@ mymain(void)
goto cleanup;
}
- virAsprintf(&fakesysfsdir, "%s/sys", fakerootdir);
+ fakesysfsdir = g_strdup_printf("%s/sys", fakerootdir);
if (init_scsihost_sysfs(fakesysfsdir) < 0) {
fprintf(stderr, "Failed to create fakesysfs='%s'\n",
fakesysfsdir);
goto cleanup;
}
- virAsprintf(&scsihost_class_path, "%s/class/scsi_host",
fakesysfsdir);
+ scsihost_class_path = g_strdup_printf("%s/class/scsi_host",
fakesysfsdir);
VIR_DEBUG("Reading from '%s'", scsihost_class_path);
if (virTestRun("testVirReadSCSIUniqueId",
diff --git a/tests/secretxml2xmltest.c b/tests/secretxml2xmltest.c
index 44f4615be8..9eb3c460e7 100644
--- a/tests/secretxml2xmltest.c
+++ b/tests/secretxml2xmltest.c
@@ -44,11 +44,11 @@ testCompareXMLToXMLHelper(const void *data)
char *outxml = NULL;
const struct testInfo *info = data;
- virAsprintf(&inxml, "%s/secretxml2xmlin/%s.xml", abs_srcdir,
info->name);
- virAsprintf(&outxml, "%s/secretxml2xml%s/%s.xml",
- abs_srcdir,
- info->different ? "out" : "in",
- info->name);
+ inxml = g_strdup_printf("%s/secretxml2xmlin/%s.xml", abs_srcdir,
info->name);
+ outxml = g_strdup_printf("%s/secretxml2xml%s/%s.xml",
+ abs_srcdir,
+ info->different ? "out" : "in",
+ info->name);
result = testCompareXMLToXMLFiles(inxml, outxml);
diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c
index cc0de456cd..703052418c 100644
--- a/tests/securityselinuxlabeltest.c
+++ b/tests/securityselinuxlabeltest.c
@@ -60,7 +60,7 @@ testUserXattrEnabled(void)
ssize_t len;
const char *con_value = "system_u:object_r:svirt_image_t:s0:c41,c264";
char *path = NULL;
- virAsprintf(&path, "%s/securityselinuxlabeldata/testxattr",
abs_builddir);
+ path = g_strdup_printf("%s/securityselinuxlabeldata/testxattr",
abs_builddir);
if (virFileMakePath(abs_builddir "/securityselinuxlabeldata") < 0 ||
virFileTouch(path, 0600) < 0)
@@ -88,7 +88,7 @@ testSELinuxMungePath(char **path)
{
char *tmp;
- virAsprintf(&tmp, "%s/securityselinuxlabeldata%s", abs_builddir,
*path);
+ tmp = g_strdup_printf("%s/securityselinuxlabeldata%s", abs_builddir,
*path);
VIR_FREE(*path);
*path = tmp;
@@ -108,8 +108,8 @@ testSELinuxLoadFileList(const char *testname,
*files = NULL;
*nfiles = 0;
- virAsprintf(&path, "%s/securityselinuxlabeldata/%s.txt", abs_srcdir,
- testname);
+ path = g_strdup_printf("%s/securityselinuxlabeldata/%s.txt", abs_srcdir,
+ testname);
if (!(fp = fopen(path, "r")))
goto cleanup;
@@ -135,8 +135,8 @@ testSELinuxLoadFileList(const char *testname,
*tmp = '\0';
tmp++;
- virAsprintf(&file, "%s/securityselinuxlabeldata%s", abs_builddir,
- line);
+ file = g_strdup_printf("%s/securityselinuxlabeldata%s", abs_builddir,
+ line);
if (*tmp != '\0' && *tmp != '\n') {
context = g_strdup(tmp);
@@ -172,8 +172,8 @@ testSELinuxLoadDef(const char *testname)
virDomainDefPtr def = NULL;
size_t i;
- virAsprintf(&xmlfile, "%s/securityselinuxlabeldata/%s.xml",
abs_srcdir,
- testname);
+ xmlfile = g_strdup_printf("%s/securityselinuxlabeldata/%s.xml",
abs_srcdir,
+ testname);
if (!(def = virDomainDefParseFile(xmlfile, driver.caps, driver.xmlopt,
NULL, 0)))
diff --git a/tests/storagebackendsheepdogtest.c b/tests/storagebackendsheepdogtest.c
index 7d50b1a303..c7dabd976b 100644
--- a/tests/storagebackendsheepdogtest.c
+++ b/tests/storagebackendsheepdogtest.c
@@ -158,11 +158,11 @@ mymain(void)
collie_test *test = node_info_tests;
- virAsprintf(&poolxml, "%s/storagepoolxml2xmlin/pool-sheepdog.xml",
- abs_srcdir);
+ poolxml = g_strdup_printf("%s/storagepoolxml2xmlin/pool-sheepdog.xml",
+ abs_srcdir);
- virAsprintf(&volxml, "%s/storagevolxml2xmlin/vol-sheepdog.xml",
- abs_srcdir);
+ volxml = g_strdup_printf("%s/storagevolxml2xmlin/vol-sheepdog.xml",
+ abs_srcdir);
#define DO_TEST_NODE(collie) \
do { \
diff --git a/tests/storagepoolcapstest.c b/tests/storagepoolcapstest.c
index 5f66a67da6..28b9f7d90a 100644
--- a/tests/storagepoolcapstest.c
+++ b/tests/storagepoolcapstest.c
@@ -62,8 +62,8 @@ test_virStoragePoolCapsFormat(const void *opaque)
if (!(poolCaps = virStoragePoolCapsNew(driverCaps)))
return -1;
- virAsprintf(&path, "%s/storagepoolcapsschemadata/poolcaps-%s.xml",
- abs_srcdir, data->filename);
+ path = g_strdup_printf("%s/storagepoolcapsschemadata/poolcaps-%s.xml",
+ abs_srcdir, data->filename);
if (!(poolCapsXML = virStoragePoolCapsFormat(poolCaps)))
return -1;
diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtest.c
index 50b79b4625..967d1f21a8 100644
--- a/tests/storagepoolxml2argvtest.c
+++ b/tests/storagepoolxml2argvtest.c
@@ -108,11 +108,11 @@ testCompareXMLToArgvHelper(const void *data)
g_autofree char *poolxml = NULL;
g_autofree char *cmdline = NULL;
- virAsprintf(&poolxml, "%s/storagepoolxml2xmlin/%s.xml", abs_srcdir,
- info->pool);
+ poolxml = g_strdup_printf("%s/storagepoolxml2xmlin/%s.xml", abs_srcdir,
+ info->pool);
- virAsprintf(&cmdline, "%s/storagepoolxml2argvdata/%s%s.argv",
- abs_srcdir, info->pool, info->platformSuffix);
+ cmdline = g_strdup_printf("%s/storagepoolxml2argvdata/%s%s.argv",
+ abs_srcdir, info->pool, info->platformSuffix);
return testCompareXMLToArgvFiles(info->shouldFail, poolxml, cmdline);
}
diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c
index e4c78d3fd5..382a7c659f 100644
--- a/tests/storagepoolxml2xmltest.c
+++ b/tests/storagepoolxml2xmltest.c
@@ -39,10 +39,10 @@ testCompareXMLToXMLHelper(const void *data)
g_autofree char *inxml = NULL;
g_autofree char *outxml = NULL;
- virAsprintf(&inxml, "%s/storagepoolxml2xmlin/%s.xml",
- abs_srcdir, (const char*)data);
- virAsprintf(&outxml, "%s/storagepoolxml2xmlout/%s.xml",
- abs_srcdir, (const char*)data);
+ inxml = g_strdup_printf("%s/storagepoolxml2xmlin/%s.xml",
+ abs_srcdir, (const char*)data);
+ outxml = g_strdup_printf("%s/storagepoolxml2xmlout/%s.xml",
+ abs_srcdir, (const char*)data);
return testCompareXMLToXMLFiles(inxml, outxml);
}
diff --git a/tests/storagevolxml2argvtest.c b/tests/storagevolxml2argvtest.c
index 833000a636..1832690e29 100644
--- a/tests/storagevolxml2argvtest.c
+++ b/tests/storagevolxml2argvtest.c
@@ -113,7 +113,7 @@ testCompareXMLToArgvFiles(bool shouldFail,
if (!(cvtCmdline = virCommandToString(cmd, false)))
goto cleanup;
- virAsprintf(&actualCmdline, "%s\n%s", createCmdline,
cvtCmdline);
+ actualCmdline = g_strdup_printf("%s\n%s", createCmdline,
cvtCmdline);
VIR_FREE(createCmdline);
}
@@ -159,17 +159,17 @@ testCompareXMLToArgvHelper(const void *data)
g_autofree char *cmdline = NULL;
if (info->inputvol)
- virAsprintf(&inputvolxml, "%s/storagevolxml2xmlin/%s.xml",
- abs_srcdir, info->inputvol);
+ inputvolxml = g_strdup_printf("%s/storagevolxml2xmlin/%s.xml",
+ abs_srcdir, info->inputvol);
if (info->inputpool)
- virAsprintf(&inputpoolxml, "%s/storagepoolxml2xmlin/%s.xml",
- abs_srcdir, info->inputpool);
- virAsprintf(&poolxml, "%s/storagepoolxml2xmlin/%s.xml",
- abs_srcdir, info->pool);
- virAsprintf(&volxml, "%s/storagevolxml2xmlin/%s.xml",
- abs_srcdir, info->vol);
- virAsprintf(&cmdline, "%s/storagevolxml2argvdata/%s.argv",
- abs_srcdir, info->cmdline);
+ inputpoolxml = g_strdup_printf("%s/storagepoolxml2xmlin/%s.xml",
+ abs_srcdir, info->inputpool);
+ poolxml = g_strdup_printf("%s/storagepoolxml2xmlin/%s.xml",
+ abs_srcdir, info->pool);
+ volxml = g_strdup_printf("%s/storagevolxml2xmlin/%s.xml",
+ abs_srcdir, info->vol);
+ cmdline = g_strdup_printf("%s/storagevolxml2argvdata/%s.argv",
+ abs_srcdir, info->cmdline);
return testCompareXMLToArgvFiles(info->shouldFail, poolxml, volxml,
inputpoolxml, inputvolxml,
diff --git a/tests/storagevolxml2xmltest.c b/tests/storagevolxml2xmltest.c
index 4e92d2818c..c65296c7eb 100644
--- a/tests/storagevolxml2xmltest.c
+++ b/tests/storagevolxml2xmltest.c
@@ -50,12 +50,12 @@ testCompareXMLToXMLHelper(const void *data)
g_autofree char *inxml = NULL;
g_autofree char *outxml = NULL;
- virAsprintf(&poolxml, "%s/storagepoolxml2xmlin/%s.xml",
- abs_srcdir, info->pool);
- virAsprintf(&inxml, "%s/storagevolxml2xmlin/%s.xml",
- abs_srcdir, info->name);
- virAsprintf(&outxml, "%s/storagevolxml2xmlout/%s.xml",
- abs_srcdir, info->name);
+ poolxml = g_strdup_printf("%s/storagepoolxml2xmlin/%s.xml",
+ abs_srcdir, info->pool);
+ inxml = g_strdup_printf("%s/storagevolxml2xmlin/%s.xml",
+ abs_srcdir, info->name);
+ outxml = g_strdup_printf("%s/storagevolxml2xmlout/%s.xml",
+ abs_srcdir, info->name);
return testCompareXMLToXMLFiles(poolxml, inxml, outxml, info->flags);
}
diff --git a/tests/sysinfotest.c b/tests/sysinfotest.c
index 4167d4baee..a8a0d0869e 100644
--- a/tests/sysinfotest.c
+++ b/tests/sysinfotest.c
@@ -91,13 +91,13 @@ sysinfotest_run(const char *test,
testdata.func = func;
if (decoder)
- virAsprintf(&testdata.decoder, "%s/%s", abs_srcdir, decoder);
+ testdata.decoder = g_strdup_printf("%s/%s", abs_srcdir, decoder);
if (sysinfo)
- virAsprintf(&testdata.sysinfo, "%s/%s", abs_srcdir, sysinfo);
+ testdata.sysinfo = g_strdup_printf("%s/%s", abs_srcdir, sysinfo);
if (cpuinfo)
- virAsprintf(&testdata.cpuinfo, "%s/%s", abs_srcdir, cpuinfo);
+ testdata.cpuinfo = g_strdup_printf("%s/%s", abs_srcdir, cpuinfo);
if (expected)
- virAsprintf(&testdata.expected, "%s/%s", abs_srcdir, expected);
+ testdata.expected = g_strdup_printf("%s/%s", abs_srcdir, expected);
if (virTestRun(test, testSysinfo, &testdata) < 0)
goto error;
diff --git a/tests/testutils.c b/tests/testutils.c
index 3ae66d3007..3116b1c5b9 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -404,7 +404,7 @@ virTestRewrapFile(const char *filename)
return -1;
}
- virAsprintf(&script, "%s/test-wrap-argv.pl", abs_srcdir);
+ script = g_strdup_printf("%s/test-wrap-argv.pl", abs_srcdir);
cmd = virCommandNewArgList(perl, script, "--in-place", filename, NULL);
if (virCommandRun(cmd, NULL) < 0)
@@ -663,7 +663,7 @@ virTestCompareToFile(const char *actual,
if (filecontentLen > 0 &&
filecontent[filecontentLen - 1] == '\n' &&
(cmpcontentLen == 0 || cmpcontent[cmpcontentLen - 1] != '\n')) {
- virAsprintf(&fixedcontent, "%s\n", cmpcontent);
+ fixedcontent = g_strdup_printf("%s\n", cmpcontent);
cmpcontent = fixedcontent;
}
}
@@ -689,9 +689,9 @@ virTestCompareToULL(unsigned long long expect,
g_autofree char *expectStr = NULL;
g_autofree char *actualStr = NULL;
- virAsprintf(&expectStr, "%llu", expect);
+ expectStr = g_strdup_printf("%llu", expect);
- virAsprintf(&actualStr, "%llu", actual);
+ actualStr = g_strdup_printf("%llu", actual);
return virTestCompareToString(expectStr, actualStr);
}
@@ -809,7 +809,7 @@ virTestSetEnvPath(void)
if (path) {
if (strstr(path, abs_builddir) != path)
- virAsprintf(&new_path, "%s:%s", abs_builddir, path);
+ new_path = g_strdup_printf("%s:%s", abs_builddir, path);
} else {
new_path = g_strdup(abs_builddir);
}
diff --git a/tests/testutils.h b/tests/testutils.h
index 36d2d5ba04..0088251dca 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -138,7 +138,7 @@ int virTestMain(int argc,
if (!preload) { \
newenv = (char *) lib; \
} else { \
- virAsprintf(&newenv, "%s:%s", lib, preload); \
+ newenv = g_strdup_printf("%s:%s", lib, preload); \
} \
setenv(PRELOAD_VAR, newenv, 1); \
FORCE_FLAT_NAMESPACE \
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 3b656cdd1e..fa73e18cb5 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -809,7 +809,7 @@ testQemuGetLatestCapsForArch(const char *arch,
const char *maxname = NULL;
char *ret = NULL;
- virAsprintf(&fullsuffix, "%s.%s", arch, suffix);
+ fullsuffix = g_strdup_printf("%s.%s", arch, suffix);
if (virDirOpen(&dir, TEST_QEMU_CAPS_PATH) < 0)
goto cleanup;
@@ -845,7 +845,7 @@ testQemuGetLatestCapsForArch(const char *arch,
goto cleanup;
}
- virAsprintf(&ret, "%s/%s", TEST_QEMU_CAPS_PATH, maxname);
+ ret = g_strdup_printf("%s/%s", TEST_QEMU_CAPS_PATH, maxname);
cleanup:
VIR_FREE(tmp);
@@ -1042,8 +1042,8 @@ testQemuInfoSetArgs(struct testQemuInfo *info,
if (STREQ(capsver, "latest")) {
capsfile = g_strdup(virHashLookup(capslatest, capsarch));
stripmachinealiases = true;
- } else virAsprintf(&capsfile, "%s/caps_%s.%s.xml",
- TEST_QEMU_CAPS_PATH, capsver, capsarch);
+ } else capsfile = g_strdup_printf("%s/caps_%s.%s.xml",
+ TEST_QEMU_CAPS_PATH, capsver, capsarch);
if (!(qemuCaps = qemuTestParseCapabilitiesArch(virArchFromString(capsarch),
capsfile))) {
diff --git a/tests/vboxsnapshotxmltest.c b/tests/vboxsnapshotxmltest.c
index fdc2c92719..db3ef3d550 100644
--- a/tests/vboxsnapshotxmltest.c
+++ b/tests/vboxsnapshotxmltest.c
@@ -104,8 +104,8 @@ testCompareXMLToXMLHelper(const void *data)
int result = -1;
char *xml = NULL;
- virAsprintf(&xml, "%s/vboxsnapshotxmldata/%s.vbox", abs_srcdir,
- (const char *)data);
+ xml = g_strdup_printf("%s/vboxsnapshotxmldata/%s.vbox", abs_srcdir,
+ (const char *)data);
result = testCompareXMLtoXMLFiles(xml);
diff --git a/tests/virbuftest.c b/tests/virbuftest.c
index 6bbd6545ac..9d69809268 100644
--- a/tests/virbuftest.c
+++ b/tests/virbuftest.c
@@ -31,7 +31,7 @@ static int testBufInfiniteLoop(const void *data)
* This test is a bit fragile, since it relies on virBuffer internals.
*/
len = buf->size - buf->use - 1;
- virAsprintf(&addstr, "%*s", len, "a");
+ addstr = g_strdup_printf("%*s", len, "a");
if (info->doEscape)
virBufferEscapeString(buf, "%s", addstr);
diff --git a/tests/vircaps2xmltest.c b/tests/vircaps2xmltest.c
index c0a1ef2e2b..32c8f95303 100644
--- a/tests/vircaps2xmltest.c
+++ b/tests/vircaps2xmltest.c
@@ -45,11 +45,11 @@ test_virCapabilities(const void *opaque)
char *resctrl = NULL;
int ret = -1;
- virAsprintf(&system, "%s/vircaps2xmldata/linux-%s/system",
abs_srcdir,
- data->filename);
+ system = g_strdup_printf("%s/vircaps2xmldata/linux-%s/system",
abs_srcdir,
+ data->filename);
- virAsprintf(&resctrl, "%s/vircaps2xmldata/linux-%s/resctrl",
abs_srcdir,
- data->filename);
+ resctrl = g_strdup_printf("%s/vircaps2xmldata/linux-%s/resctrl",
abs_srcdir,
+ data->filename);
virFileWrapperAddPrefix("/sys/devices/system", system);
virFileWrapperAddPrefix("/sys/fs/resctrl", resctrl);
@@ -67,8 +67,8 @@ test_virCapabilities(const void *opaque)
if (!(capsXML = virCapabilitiesFormatXML(caps)))
goto cleanup;
- virAsprintf(&path, "%s/vircaps2xmldata/vircaps-%s-%s.xml",
abs_srcdir,
- archStr, data->filename);
+ path = g_strdup_printf("%s/vircaps2xmldata/vircaps-%s-%s.xml",
abs_srcdir,
+ archStr, data->filename);
if (virTestCompareToFile(capsXML, path) < 0)
goto cleanup;
diff --git a/tests/vircgroupmock.c b/tests/vircgroupmock.c
index 1735852f39..3168b689f2 100644
--- a/tests/vircgroupmock.c
+++ b/tests/vircgroupmock.c
@@ -376,8 +376,8 @@ static void init_sysfs(void)
VIR_FREE(fakesysfscgroupdir);
- virAsprintf(&fakesysfscgroupdir, "%s%s",
- fakerootdir, SYSFS_CGROUP_PREFIX);
+ fakesysfscgroupdir = g_strdup_printf("%s%s",
+ fakerootdir, SYSFS_CGROUP_PREFIX);
if (virFileMakePath(fakesysfscgroupdir) < 0) {
fprintf(stderr, "Cannot create %s\n", fakesysfscgroupdir);
@@ -458,8 +458,8 @@ FILE *fopen(const char *path, const char *mode)
errno = EACCES;
return NULL;
}
- virAsprintf(&filepath, "%s/vircgroupdata/%s.%s",
- abs_srcdir, filename, type);
+ filepath = g_strdup_printf("%s/vircgroupdata/%s.%s",
+ abs_srcdir, filename, type);
rc = real_fopen(filepath, mode);
free(filepath);
return rc;
diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c
index 224e8116dd..07f53f1857 100644
--- a/tests/vircgrouptest.c
+++ b/tests/vircgrouptest.c
@@ -189,7 +189,7 @@ testCgroupDetectMounts(const void *args)
setenv("VIR_CGROUP_MOCK_FILENAME", data->file, 1);
- virAsprintf(&parsed, "%s/vircgroupdata/%s.parsed", abs_srcdir,
data->file);
+ parsed = g_strdup_printf("%s/vircgroupdata/%s.parsed", abs_srcdir,
data->file);
if (virCgroupNewSelf(&group) < 0) {
if (data->fail)
diff --git a/tests/virconftest.c b/tests/virconftest.c
index c6d8ff2272..83077342a9 100644
--- a/tests/virconftest.c
+++ b/tests/virconftest.c
@@ -39,8 +39,8 @@ static int testConfRoundTrip(const void *opaque)
char *srcfile = NULL;
char *dstfile = NULL;
- virAsprintf(&srcfile, "%s/virconfdata/%s.conf", abs_srcdir, name);
- virAsprintf(&dstfile, "%s/virconfdata/%s.out", abs_srcdir, name);
+ srcfile = g_strdup_printf("%s/virconfdata/%s.conf", abs_srcdir, name);
+ dstfile = g_strdup_printf("%s/virconfdata/%s.out", abs_srcdir, name);
if (VIR_ALLOC_N_QUIET(buffer, len) < 0) {
fprintf(stderr, "out of memory\n");
diff --git a/tests/virfilemock.c b/tests/virfilemock.c
index bb5fcc2ed8..65685c6d26 100644
--- a/tests/virfilemock.c
+++ b/tests/virfilemock.c
@@ -188,7 +188,7 @@ canonicalize_file_name(const char *path)
char *ret;
if ((p = STRSKIP(path, "/some/symlink")))
- virAsprintf(&ret, "/gluster%s", p);
+ ret = g_strdup_printf("/gluster%s", p);
else
ret = g_strdup(path);
diff --git a/tests/virfiletest.c b/tests/virfiletest.c
index ba947129be..c7d5f6abeb 100644
--- a/tests/virfiletest.c
+++ b/tests/virfiletest.c
@@ -325,7 +325,7 @@ testFileIsSharedFSType(const void *opaque G_GNUC_UNUSED)
bool actual;
int ret = -1;
- virAsprintf(&mtabFile, abs_srcdir "/virfiledata/%s",
data->mtabFile);
+ mtabFile = g_strdup_printf(abs_srcdir "/virfiledata/%s",
data->mtabFile);
if (setenv("LIBVIRT_MTAB", mtabFile, 1) < 0) {
fprintf(stderr, "Unable to set env variable\n");
diff --git a/tests/virfilewrapper.c b/tests/virfilewrapper.c
index e3d3c225ad..0500a3617e 100644
--- a/tests/virfilewrapper.c
+++ b/tests/virfilewrapper.c
@@ -124,7 +124,7 @@ virMockStatRedirect(const char *path, char **newpath)
if (!tmp)
continue;
- virAsprintf(newpath, "%s%s", overrides[i], tmp);
+ *newpath = g_strdup_printf("%s%s", overrides[i], tmp);
break;
}
diff --git a/tests/virhostcputest.c b/tests/virhostcputest.c
index 7b1b1a6d89..01ba745338 100644
--- a/tests/virhostcputest.c
+++ b/tests/virhostcputest.c
@@ -55,12 +55,12 @@ linuxTestCompareFiles(const char *cpuinfofile,
}
VIR_FORCE_FCLOSE(cpuinfo);
- virAsprintf(&actualData,
- "CPUs: %u/%u, MHz: %u, Nodes: %u, Sockets: %u, "
- "Cores: %u, Threads: %u\n",
- nodeinfo.cpus, VIR_NODEINFO_MAXCPUS(nodeinfo),
- nodeinfo.mhz, nodeinfo.nodes, nodeinfo.sockets,
- nodeinfo.cores, nodeinfo.threads);
+ actualData = g_strdup_printf(
+ "CPUs: %u/%u, MHz: %u, Nodes: %u, Sockets: %u,
"
+ "Cores: %u, Threads: %u\n",
+ nodeinfo.cpus, VIR_NODEINFO_MAXCPUS(nodeinfo),
+ nodeinfo.mhz, nodeinfo.nodes, nodeinfo.sockets,
+ nodeinfo.cores, nodeinfo.threads);
Extra newline after the '('.
if (virTestCompareToFile(actualData, outputfile) < 0)
goto fail;
@@ -176,12 +176,12 @@ linuxTestHostCPU(const void *opaque)
struct linuxTestHostCPUData *data = (struct linuxTestHostCPUData *) opaque;
const char *archStr = virArchToString(data->arch);
- virAsprintf(&sysfs_prefix, "%s/virhostcpudata/linux-%s",
- abs_srcdir, data->testName);
- virAsprintf(&cpuinfo, "%s/virhostcpudata/linux-%s-%s.cpuinfo",
- abs_srcdir, archStr, data->testName);
- virAsprintf(&output, "%s/virhostcpudata/linux-%s-%s.expected",
- abs_srcdir, archStr, data->testName);
+ sysfs_prefix = g_strdup_printf("%s/virhostcpudata/linux-%s",
+ abs_srcdir, data->testName);
+ cpuinfo = g_strdup_printf("%s/virhostcpudata/linux-%s-%s.cpuinfo",
+ abs_srcdir, archStr, data->testName);
+ output = g_strdup_printf("%s/virhostcpudata/linux-%s-%s.expected",
+ abs_srcdir, archStr, data->testName);
virFileWrapperAddPrefix(SYSFS_SYSTEM_PATH, sysfs_prefix);
result = linuxTestCompareFiles(cpuinfo, data->arch, output);
@@ -207,10 +207,10 @@ linuxTestNodeCPUStats(const void *data)
char *cpustatfile = NULL;
char *outfile = NULL;
- virAsprintf(&cpustatfile, "%s/virhostcpudata/linux-cpustat-%s.stat",
- abs_srcdir, testData->name);
- virAsprintf(&outfile, "%s/virhostcpudata/linux-cpustat-%s.out",
- abs_srcdir, testData->name);
+ cpustatfile = g_strdup_printf("%s/virhostcpudata/linux-cpustat-%s.stat",
+ abs_srcdir, testData->name);
+ outfile = g_strdup_printf("%s/virhostcpudata/linux-cpustat-%s.out",
+ abs_srcdir, testData->name);
result = linuxCPUStatsCompareFiles(cpustatfile,
testData->ncpus,
diff --git a/tests/virjsontest.c b/tests/virjsontest.c
index 75c70a49c9..9da0f9c90d 100644
--- a/tests/virjsontest.c
+++ b/tests/virjsontest.c
@@ -26,10 +26,10 @@ testJSONFromFile(const void *data)
g_autofree char *outfile = NULL;
g_autofree char *actual = NULL;
- virAsprintf(&infile, "%s/virjsondata/parse-%s-in.json",
- abs_srcdir, info->name);
- virAsprintf(&outfile, "%s/virjsondata/parse-%s-out.json",
- abs_srcdir, info->name);
+ infile = g_strdup_printf("%s/virjsondata/parse-%s-in.json",
+ abs_srcdir, info->name);
+ outfile = g_strdup_printf("%s/virjsondata/parse-%s-out.json",
+ abs_srcdir, info->name);
if (virTestLoadFile(infile, &indata) < 0)
return -1;
@@ -113,10 +113,10 @@ testJSONAddRemove(const void *data)
g_autofree char *outfile = NULL;
g_autofree char *actual = NULL;
- virAsprintf(&infile, "%s/virjsondata/add-remove-%s-in.json",
- abs_srcdir, info->name);
- virAsprintf(&outfile, "%s/virjsondata/add-remove-%s-out.json",
- abs_srcdir, info->name);
+ infile = g_strdup_printf("%s/virjsondata/add-remove-%s-in.json",
+ abs_srcdir, info->name);
+ outfile = g_strdup_printf("%s/virjsondata/add-remove-%s-out.json",
+ abs_srcdir, info->name);
if (virTestLoadFile(infile, &indata) < 0)
return -1;
@@ -348,10 +348,10 @@ testJSONDeflatten(const void *data)
g_autofree char *outfile = NULL;
g_autofree char *actual = NULL;
- virAsprintf(&infile, "%s/virjsondata/deflatten-%s-in.json",
- abs_srcdir, info->name);
- virAsprintf(&outfile, "%s/virjsondata/deflatten-%s-out.json",
- abs_srcdir, info->name);
+ infile = g_strdup_printf("%s/virjsondata/deflatten-%s-in.json",
+ abs_srcdir, info->name);
+ outfile = g_strdup_printf("%s/virjsondata/deflatten-%s-out.json",
+ abs_srcdir, info->name);
if (virTestLoadFile(infile, &indata) < 0)
return -1;
diff --git a/tests/virmacmaptest.c b/tests/virmacmaptest.c
index 17880728e7..69d75dfa34 100644
--- a/tests/virmacmaptest.c
+++ b/tests/virmacmaptest.c
@@ -41,7 +41,7 @@ testMACLookup(const void *opaque)
char *file = NULL;
int ret = -1;
- virAsprintf(&file, "%s/virmacmaptestdata/%s.json", abs_srcdir,
data->file);
+ file = g_strdup_printf("%s/virmacmaptestdata/%s.json", abs_srcdir,
data->file);
if (!(mgr = virMacMapNew(file)))
goto cleanup;
@@ -92,7 +92,7 @@ testMACRemove(const void *opaque)
char *file = NULL;
int ret = -1;
- virAsprintf(&file, "%s/virmacmaptestdata/%s.json", abs_srcdir,
data->file);
+ file = g_strdup_printf("%s/virmacmaptestdata/%s.json", abs_srcdir,
data->file);
if (!(mgr = virMacMapNew(file)))
goto cleanup;
@@ -127,7 +127,7 @@ testMACFlush(const void *opaque)
char *str = NULL;
int ret = -1;
- virAsprintf(&file, "%s/virmacmaptestdata/%s.json", abs_srcdir,
data->file);
+ file = g_strdup_printf("%s/virmacmaptestdata/%s.json", abs_srcdir,
data->file);
if (virMacMapDumpStr(data->mgr, &str) < 0)
goto cleanup;
diff --git a/tests/virnetdaemontest.c b/tests/virnetdaemontest.c
index 2dfa04e83f..825487f0a1 100644
--- a/tests/virnetdaemontest.c
+++ b/tests/virnetdaemontest.c
@@ -295,11 +295,11 @@ static int testExecRestart(const void *opaque)
goto cleanup;
}
- virAsprintf(&infile, "%s/virnetdaemondata/input-data-%s.json",
abs_srcdir,
- data->jsonfile);
+ infile = g_strdup_printf("%s/virnetdaemondata/input-data-%s.json",
abs_srcdir,
+ data->jsonfile);
- virAsprintf(&outfile, "%s/virnetdaemondata/output-data-%s.json",
- abs_srcdir, data->jsonfile);
+ outfile = g_strdup_printf("%s/virnetdaemondata/output-data-%s.json",
+ abs_srcdir, data->jsonfile);
if (virFileReadAll(infile, 8192, &injsonstr) < 0)
goto cleanup;
diff --git a/tests/virnetdevmock.c b/tests/virnetdevmock.c
index 8834b2ca6a..f26991a48c 100644
--- a/tests/virnetdevmock.c
+++ b/tests/virnetdevmock.c
@@ -30,8 +30,8 @@ virNetDevSysfsFile(char **pf_sysfs_device_link,
const char *ifname,
const char *file)
{
- virAsprintf(pf_sysfs_device_link, "%s/%s/%s",
- NET_DEV_TEST_DATA_PREFIX, ifname, file);
+ *pf_sysfs_device_link = g_strdup_printf("%s/%s/%s",
+ NET_DEV_TEST_DATA_PREFIX, ifname, file);
return 0;
}
#else
diff --git a/tests/virnetdevopenvswitchtest.c b/tests/virnetdevopenvswitchtest.c
index 7b814474b7..fd47e927ea 100644
--- a/tests/virnetdevopenvswitchtest.c
+++ b/tests/virnetdevopenvswitchtest.c
@@ -38,8 +38,8 @@ testInterfaceParseStats(const void *opaque)
g_autofree char *buf = NULL;
virDomainInterfaceStatsStruct actual;
- virAsprintf(&filename, "%s/virnetdevopenvswitchdata/%s", abs_srcdir,
- data->filename);
+ filename = g_strdup_printf("%s/virnetdevopenvswitchdata/%s", abs_srcdir,
+ data->filename);
if (virFileReadAll(filename, 1024, &buf) < 0)
return -1;
diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c
index 29568eea1a..4e9f201e45 100644
--- a/tests/virnetsockettest.c
+++ b/tests/virnetsockettest.c
@@ -196,7 +196,7 @@ testSocketAccept(const void *opaque)
VIR_WARN("Failed to create temporary directory");
goto cleanup;
}
- virAsprintf(&path, "%s/test.sock", tmpdir);
+ path = g_strdup_printf("%s/test.sock", tmpdir);
if (virNetSocketNewListenUNIX(path, 0700, -1, getegid(), &usock) < 0)
goto cleanup;
@@ -320,7 +320,7 @@ static int testSocketUNIXAddrs(const void *data G_GNUC_UNUSED)
VIR_WARN("Failed to create temporary directory");
goto cleanup;
}
- virAsprintf(&path, "%s/test.sock", tmpdir);
+ path = g_strdup_printf("%s/test.sock", tmpdir);
if (virNetSocketNewListenUNIX(path, 0700, -1, getegid(), &lsock) < 0)
goto cleanup;
diff --git a/tests/virnetworkportxml2xmltest.c b/tests/virnetworkportxml2xmltest.c
index 89f9de0c17..1b2175dd9d 100644
--- a/tests/virnetworkportxml2xmltest.c
+++ b/tests/virnetworkportxml2xmltest.c
@@ -66,8 +66,8 @@ testCompareXMLToXMLHelper(const void *data)
int ret = -1;
char *xml = NULL;
- virAsprintf(&xml, "%s/virnetworkportxml2xmldata/%s.xml", abs_srcdir,
- info->name);
+ xml = g_strdup_printf("%s/virnetworkportxml2xmldata/%s.xml", abs_srcdir,
+ info->name);
ret = testCompareXMLToXMLFiles(xml);
diff --git a/tests/virnumamock.c b/tests/virnumamock.c
index 4a52483a7f..e6282c7f33 100644
--- a/tests/virnumamock.c
+++ b/tests/virnumamock.c
@@ -43,7 +43,7 @@ virNumaIsAvailable(void)
if (numa_avail < 0) {
char *sysfs_node_path = NULL;
- virAsprintf(&sysfs_node_path, "%s/node", SYSFS_SYSTEM_PATH);
+ sysfs_node_path = g_strdup_printf("%s/node", SYSFS_SYSTEM_PATH);
numa_avail = virFileExists(sysfs_node_path);
diff --git a/tests/virnwfilterbindingxml2xmltest.c
b/tests/virnwfilterbindingxml2xmltest.c
index d5ace8f89f..3360dd28d3 100644
--- a/tests/virnwfilterbindingxml2xmltest.c
+++ b/tests/virnwfilterbindingxml2xmltest.c
@@ -72,8 +72,8 @@ testCompareXMLToXMLHelper(const void *data)
const test_parms *tp = data;
char *xml = NULL;
- virAsprintf(&xml, "%s/virnwfilterbindingxml2xmldata/%s.xml",
abs_srcdir,
- tp->name);
+ xml = g_strdup_printf("%s/virnwfilterbindingxml2xmldata/%s.xml",
abs_srcdir,
+ tp->name);
result = testCompareXMLToXMLFiles(xml);
diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index 67107450e6..0d502db68c 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -186,7 +186,7 @@ make_file(const char *path,
if (value && len == -1)
len = strlen(value);
- virAsprintf(&filepath, "%s/%s", path, name);
+ filepath = g_strdup_printf("%s/%s", path, name);
if ((fd = real_open(filepath, O_CREAT|O_WRONLY, 0666)) < 0)
ABORT("Unable to open: %s", filepath);
@@ -203,7 +203,7 @@ make_dir(const char *path,
{
g_autofree char *dirpath = NULL;
- virAsprintf(&dirpath, "%s/%s", path, name);
+ dirpath = g_strdup_printf("%s/%s", path, name);
if (virFileMakePath(dirpath) < 0)
ABORT("Unable to create: %s", dirpath);
@@ -216,7 +216,7 @@ make_symlink(const char *path,
{
g_autofree char *filepath = NULL;
- virAsprintf(&filepath, "%s/%s", path, name);
+ filepath = g_strdup_printf("%s/%s", path, name);
if (symlink(target, filepath) < 0)
ABORT("Unable to create symlink filepath -> target");
@@ -232,7 +232,7 @@ pci_read_file(const char *path,
int fd = -1;
g_autofree char *newpath = NULL;
- virAsprintf(&newpath, "%s/%s", fakerootdir, path);
+ newpath = g_strdup_printf("%s/%s", fakerootdir, path);
if ((fd = real_open(newpath, O_RDWR)) < 0)
goto cleanup;
@@ -269,13 +269,13 @@ getrealpath(char **newpath,
init_env();
if (STRPREFIX(path, SYSFS_PCI_PREFIX)) {
- virAsprintf(newpath, "%s/sys/bus/pci/%s",
- fakerootdir,
- path + strlen(SYSFS_PCI_PREFIX));
+ *newpath = g_strdup_printf("%s/sys/bus/pci/%s",
+ fakerootdir,
+ path + strlen(SYSFS_PCI_PREFIX));
} else if (pathPrefixIsMocked(path)) {
- virAsprintf(newpath, "%s/%s",
- fakerootdir,
- path);
+ *newpath = g_strdup_printf("%s/%s",
+ fakerootdir,
+ path);
} else {
*newpath = g_strdup(path);
}
@@ -356,9 +356,9 @@ pci_address_format(struct pciDeviceAddress const *addr)
{
char *ret;
- virAsprintf(&ret, ADDR_STR_FMT,
- addr->domain, addr->bus,
- addr->device, addr->function);
+ ret = g_strdup_printf(ADDR_STR_FMT,
+ addr->domain, addr->bus,
+ addr->device, addr->function);
return ret;
}
@@ -393,13 +393,13 @@ pci_device_get_path(const struct pciDevice *dev,
* and then they are just symlinked to /sys/bus/pci/devices/
*/
if (file) {
- virAsprintf(&ret, "%s/sys/devices/pci%04x:%02x/%s/%s",
- prefix, dev->addr.domain, dev->addr.bus,
- devid, file);
+ ret = g_strdup_printf("%s/sys/devices/pci%04x:%02x/%s/%s",
+ prefix, dev->addr.domain, dev->addr.bus,
+ devid, file);
} else {
- virAsprintf(&ret, "%s/sys/devices/pci%04x:%02x/%s",
- prefix, dev->addr.domain, dev->addr.bus,
- devid);
+ ret = g_strdup_printf("%s/sys/devices/pci%04x:%02x/%s",
+ prefix, dev->addr.domain, dev->addr.bus,
+ devid);
}
return ret;
@@ -415,8 +415,8 @@ pci_device_create_iommu(const struct pciDevice *dev,
char tmp[256];
size_t i;
- virAsprintf(&iommuPath, "%s/sys/kernel/iommu_groups/%d/devices/",
- fakerootdir, dev->iommuGroup);
+ iommuPath = g_strdup_printf("%s/sys/kernel/iommu_groups/%d/devices/",
+ fakerootdir, dev->iommuGroup);
if (virFileMakePath(iommuPath) < 0)
ABORT("Unable to create: %s", iommuPath);
@@ -482,7 +482,7 @@ pci_device_new_from_stub(const struct pciDevice *data)
if (VIR_ALLOC_QUIET(dev) < 0)
ABORT_OOM();
- virAsprintf(&configSrc, "%s/virpcitestdata/%s.config", abs_srcdir,
id);
+ configSrc = g_strdup_printf("%s/virpcitestdata/%s.config", abs_srcdir,
id);
memcpy(dev, data, sizeof(*dev));
@@ -544,7 +544,7 @@ pci_device_new_from_stub(const struct pciDevice *data)
ABORT("@tmp overflow");
}
- virAsprintf(&devsympath, "%s" SYSFS_PCI_PREFIX "devices",
fakerootdir);
+ devsympath = g_strdup_printf("%s" SYSFS_PCI_PREFIX "devices",
fakerootdir);
make_symlink(devsympath, devid, tmp);
@@ -625,9 +625,9 @@ pci_vfio_release_iommu(struct pciDevice *device)
pciIommuGroups[i]->nDevicesBoundToVFIO--;
if (!pciIommuGroups[i]->nDevicesBoundToVFIO) {
- virAsprintf(&vfiopath, "%s/dev/vfio/%d",
- fakerootdir,
- device->iommuGroup);
+ vfiopath = g_strdup_printf("%s/dev/vfio/%d",
+ fakerootdir,
+ device->iommuGroup);
if (unlink(vfiopath) < 0)
return -1;
@@ -651,9 +651,9 @@ pci_vfio_lock_iommu(struct pciDevice *device)
continue;
if (pciIommuGroups[i]->nDevicesBoundToVFIO == 0) {
- virAsprintf(&vfiopath, "%s/dev/vfio/%d",
- fakerootdir,
- device->iommuGroup);
+ vfiopath = g_strdup_printf("%s/dev/vfio/%d",
+ fakerootdir,
+ device->iommuGroup);
if ((fd = real_open(vfiopath, O_CREAT)) < 0)
goto cleanup;
@@ -685,11 +685,11 @@ pci_driver_get_path(const struct pciDriver *driver,
prefix = fakerootdir;
if (file) {
- virAsprintf(&ret, "%s" SYSFS_PCI_PREFIX
"drivers/%s/%s",
- prefix, driver->name, file);
+ ret = g_strdup_printf("%s" SYSFS_PCI_PREFIX
"drivers/%s/%s",
+ prefix, driver->name, file);
} else {
- virAsprintf(&ret, "%s" SYSFS_PCI_PREFIX "drivers/%s",
- prefix, driver->name);
+ ret = g_strdup_printf("%s" SYSFS_PCI_PREFIX "drivers/%s",
+ prefix, driver->name);
}
return ret;
@@ -971,7 +971,7 @@ init_env(void)
if (!(fakerootdir = getenv("LIBVIRT_FAKE_ROOT_DIR")))
ABORT("Missing LIBVIRT_FAKE_ROOT_DIR env variable\n");
- virAsprintf(&tmp, "%s%s", fakerootdir, SYSFS_PCI_PREFIX);
+ tmp = g_strdup_printf("%s%s", fakerootdir, SYSFS_PCI_PREFIX);
if (virFileMakePath(tmp) < 0)
ABORT("Unable to create: %s", tmp);
@@ -982,7 +982,7 @@ init_env(void)
/* Create /dev/vfio/ dir and /dev/vfio/vfio file */
VIR_FREE(tmp);
- virAsprintf(&tmp, "%s/dev/vfio", fakerootdir);
+ tmp = g_strdup_printf("%s/dev/vfio", fakerootdir);
if (virFileMakePath(tmp) < 0)
ABORT("Unable to create: %s", tmp);
diff --git a/tests/virpcitest.c b/tests/virpcitest.c
index 20eb2caea9..0bac23cb23 100644
--- a/tests/virpcitest.c
+++ b/tests/virpcitest.c
@@ -349,8 +349,8 @@ mymain(void)
domain, bus, slot, function, NULL \
}; \
char *label = NULL; \
- virAsprintf(&label, "%s(%04x:%02x:%02x.%x)", \
- #fnc, domain, bus, slot, function); \
+ label = g_strdup_printf("%s(%04x:%02x:%02x.%x)", \
+#fnc, domain, bus, slot, function); \
Misaligned "#fnc, domain...." line.
if (virTestRun(label, fnc, &data) < 0) \
ret = -1; \
VIR_FREE(label); \
@@ -362,9 +362,9 @@ mymain(void)
domain, bus, slot, function, driver \
}; \
char *label = NULL; \
- virAsprintf(&label, "PCI driver %04x:%02x:%02x.%x is %s", \
- domain, bus, slot, function, \
- NULLSTR(driver)); \
+ label = g_strdup_printf("PCI driver %04x:%02x:%02x.%x is %s", \
+ domain, bus, slot, function, \
+ NULLSTR(driver)); \
if (virTestRun(label, testVirPCIDeviceCheckDriverTest, \
&data) < 0) \
ret = -1; \
diff --git a/tests/virrandommock.c b/tests/virrandommock.c
index eff72a8aa7..6dd15213e3 100644
--- a/tests/virrandommock.c
+++ b/tests/virrandommock.c
@@ -53,8 +53,8 @@ uint64_t virRandomBits(int nbits)
int virRandomGenerateWWN(char **wwn,
const char *virt_type G_GNUC_UNUSED)
{
- virAsprintf(wwn, "5100000%09llx",
- (unsigned long long)virRandomBits(36));
+ *wwn = g_strdup_printf("5100000%09llx",
+ (unsigned long long)virRandomBits(36));
return 0;
}
diff --git a/tests/virresctrltest.c b/tests/virresctrltest.c
index 71870e9f3f..bb6d0fe48e 100644
--- a/tests/virresctrltest.c
+++ b/tests/virresctrltest.c
@@ -26,14 +26,14 @@ test_virResctrlGetUnused(const void *opaque)
char *schemata_file;
virCapsPtr caps = NULL;
- virAsprintf(&system_dir, "%s/vircaps2xmldata/linux-%s/system",
abs_srcdir,
- data->filename);
+ system_dir = g_strdup_printf("%s/vircaps2xmldata/linux-%s/system",
abs_srcdir,
+ data->filename);
- virAsprintf(&resctrl_dir, "%s/vircaps2xmldata/linux-%s/resctrl",
- abs_srcdir, data->filename);
+ resctrl_dir = g_strdup_printf("%s/vircaps2xmldata/linux-%s/resctrl",
+ abs_srcdir, data->filename);
- virAsprintf(&schemata_file, "%s/virresctrldata/%s.schemata",
abs_srcdir,
- data->filename);
+ schemata_file = g_strdup_printf("%s/virresctrldata/%s.schemata",
abs_srcdir,
+ data->filename);
virFileWrapperAddPrefix("/sys/devices/system", system_dir);
virFileWrapperAddPrefix("/sys/fs/resctrl", resctrl_dir);
diff --git a/tests/virschematest.c b/tests/virschematest.c
index 1370068601..c301b37a9d 100644
--- a/tests/virschematest.c
+++ b/tests/virschematest.c
@@ -87,9 +87,9 @@ testSchemaDir(const char *schema,
if (ent->d_name[0] == '.')
continue;
- virAsprintf(&xml_path, "%s/%s", dir_path, ent->d_name);
+ xml_path = g_strdup_printf("%s/%s", dir_path, ent->d_name);
- virAsprintf(&test_name, "Checking %s against %s", ent->d_name,
schema);
+ test_name = g_strdup_printf("Checking %s against %s", ent->d_name,
schema);
data.xml_path = xml_path;
if (virTestRun(test_name, testSchemaFile, &data) < 0)
@@ -120,7 +120,7 @@ testSchemaDirs(const char *schema, virXMLValidatorPtr validator,
...)
va_start(args, validator);
while ((dir = va_arg(args, char *))) {
- virAsprintf(&dir_path, "%s/%s", abs_srcdir, dir);
+ dir_path = g_strdup_printf("%s/%s", abs_srcdir, dir);
if (testSchemaDir(schema, validator, dir_path) < 0)
ret = -1;
VIR_FREE(dir_path);
@@ -139,8 +139,8 @@ testSchemaGrammar(const void *opaque)
char *schema_path;
int ret = -1;
- virAsprintf(&schema_path, "%s/docs/schemas/%s", abs_top_srcdir,
- data->schema);
+ schema_path = g_strdup_printf("%s/docs/schemas/%s", abs_top_srcdir,
+ data->schema);
if (!(data->validator = virXMLValidatorInit(schema_path)))
goto cleanup;
diff --git a/tests/virscsitest.c b/tests/virscsitest.c
index 0d2ddd3b6a..4d40f2bb82 100644
--- a/tests/virscsitest.c
+++ b/tests/virscsitest.c
@@ -167,9 +167,9 @@ create_symlink(const char *tmpdir, const char *src_name, const char
*dst_name)
char *src_path = NULL;
char *dst_path = NULL;
- virAsprintf(&src_path, "%s/%s", virscsi_prefix, src_name);
+ src_path = g_strdup_printf("%s/%s", virscsi_prefix, src_name);
- virAsprintf(&dst_path, "%s/%s", tmpdir, dst_name);
+ dst_path = g_strdup_printf("%s/%s", tmpdir, dst_name);
if (symlink(src_path, dst_path) < 0) {
VIR_WARN("Failed to create symlink '%s' to '%s'",
src_path, dst_path);
@@ -192,7 +192,7 @@ mymain(void)
char *tmpdir = NULL;
char template[] = "/tmp/libvirt_XXXXXX";
- virAsprintf(&virscsi_prefix, "%s" VIR_SCSI_DATA, abs_srcdir);
+ virscsi_prefix = g_strdup_printf("%s" VIR_SCSI_DATA, abs_srcdir);
tmpdir = mkdtemp(template);
diff --git a/tests/virshtest.c b/tests/virshtest.c
index 475933a93c..189238b826 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -252,8 +252,8 @@ mymain(void)
{
int ret = 0;
- virAsprintf(&custom_uri,
"test://%s/../examples/xml/test/testnode.xml",
- abs_srcdir);
+ custom_uri =
g_strdup_printf("test://%s/../examples/xml/test/testnode.xml",
+ abs_srcdir);
if (virTestRun("virsh list (default)",
testCompareListDefault, NULL) != 0)
diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
index af1b4fc43f..f0de35dd83 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -138,12 +138,12 @@ testPrepImages(void)
compat = true;
VIR_FREE(buf);
- virAsprintf(&absraw, "%s/raw", datadir);
- virAsprintf(&absqcow2, "%s/qcow2", datadir);
- virAsprintf(&abswrap, "%s/wrap", datadir);
- virAsprintf(&absqed, "%s/qed", datadir);
- virAsprintf(&absdir, "%s/dir", datadir);
- virAsprintf(&abslink2, "%s/sub/link2", datadir);
+ absraw = g_strdup_printf("%s/raw", datadir);
+ absqcow2 = g_strdup_printf("%s/qcow2", datadir);
+ abswrap = g_strdup_printf("%s/wrap", datadir);
+ absqed = g_strdup_printf("%s/qed", datadir);
+ absdir = g_strdup_printf("%s/dir", datadir);
+ abslink2 = g_strdup_printf("%s/sub/link2", datadir);
if (virFileMakePath(datadir "/sub") < 0) {
fprintf(stderr, "unable to create directory %s\n", datadir
"/sub");
@@ -159,7 +159,7 @@ testPrepImages(void)
goto cleanup;
}
- virAsprintf(&buf, "%1024d", 0);
+ buf = g_strdup_printf("%1024d", 0);
if (virFileWriteStr("raw", buf, 0600) < 0) {
fprintf(stderr, "unable to create raw file\n");
goto cleanup;
@@ -321,28 +321,28 @@ testStorageChain(const void *args)
return -1;
}
- virAsprintf(&expect,
- testStorageChainFormat, i,
- NULLSTR(data->files[i]->path),
- NULLSTR(data->files[i]->expBackingStoreRaw),
- data->files[i]->expCapacity,
- data->files[i]->expEncrypted,
- NULLSTR(data->files[i]->pathRel),
- data->files[i]->type,
- data->files[i]->format,
- virStorageNetProtocolTypeToString(data->files[i]->protocol),
- NULLSTR(data->files[i]->hostname));
- virAsprintf(&actual,
- testStorageChainFormat, i,
- NULLSTR(elt->path),
- NULLSTR(elt->backingStoreRaw),
- elt->capacity,
- !!elt->encryption,
- NULLSTR(elt->relPath),
- elt->type,
- elt->format,
- virStorageNetProtocolTypeToString(elt->protocol),
- NULLSTR(elt->nhosts ? elt->hosts[0].name : NULL));
+ expect = g_strdup_printf(
+ testStorageChainFormat, i,
+ NULLSTR(data->files[i]->path),
+ NULLSTR(data->files[i]->expBackingStoreRaw),
+ data->files[i]->expCapacity,
+ data->files[i]->expEncrypted,
+ NULLSTR(data->files[i]->pathRel),
+ data->files[i]->type,
+ data->files[i]->format,
+
virStorageNetProtocolTypeToString(data->files[i]->protocol),
+ NULLSTR(data->files[i]->hostname));
Extra newline after the '('.
+ actual = g_strdup_printf(
+ testStorageChainFormat, i,
+ NULLSTR(elt->path),
+ NULLSTR(elt->backingStoreRaw),
+ elt->capacity,
+ !!elt->encryption,
+ NULLSTR(elt->relPath),
+ elt->type,
+ elt->format,
+ virStorageNetProtocolTypeToString(elt->protocol),
+ NULLSTR(elt->nhosts ? elt->hosts[0].name :
NULL));
Extra newline after the '('.
Reviewed-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>