mirror of
https://github.com/libvirt/libvirt.git
synced 2026-08-14 07:04:43 -05:00
tests: 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:
+7
-19
@@ -72,13 +72,10 @@ create_scsihost(const char *fakesysfsdir, const char *devicepath,
|
||||
int ret = -1;
|
||||
int fd = -1;
|
||||
|
||||
if (virAsprintfQuiet(&unique_id_path, "%s/devices/pci0000:00/%s/unique_id",
|
||||
fakesysfsdir, devicepath) < 0 ||
|
||||
virAsprintfQuiet(&link_path, "%s/class/scsi_host/%s",
|
||||
fakesysfsdir, hostname) < 0) {
|
||||
fprintf(stderr, "Out of memory\n");
|
||||
goto cleanup;
|
||||
}
|
||||
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
|
||||
@@ -208,9 +205,7 @@ testVirFindSCSIHostByPCI(const void *data G_GNUC_UNUSED)
|
||||
char *ret_host = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (virAsprintf(&path_addr, "%s/%s", abs_srcdir,
|
||||
"sysfs/class/scsi_host") < 0)
|
||||
goto cleanup;
|
||||
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)) ||
|
||||
@@ -260,21 +255,14 @@ mymain(void)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virAsprintfQuiet(&fakesysfsdir, "%s/sys", fakerootdir) < 0) {
|
||||
fprintf(stderr, "Out of memory\n");
|
||||
goto cleanup;
|
||||
}
|
||||
fakesysfsdir = g_strdup_printf("%s/sys", fakerootdir);
|
||||
|
||||
if (init_scsihost_sysfs(fakesysfsdir) < 0) {
|
||||
fprintf(stderr, "Failed to create fakesysfs='%s'\n", fakesysfsdir);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virAsprintfQuiet(&scsihost_class_path, "%s/class/scsi_host",
|
||||
fakesysfsdir) < 0) {
|
||||
fprintf(stderr, "Out of memory\n");
|
||||
goto cleanup;
|
||||
}
|
||||
scsihost_class_path = g_strdup_printf("%s/class/scsi_host", fakesysfsdir);
|
||||
VIR_DEBUG("Reading from '%s'", scsihost_class_path);
|
||||
|
||||
if (virTestRun("testVirReadSCSIUniqueId",
|
||||
|
||||
Reference in New Issue
Block a user