From: Barrett Schonefeld <bschoney(a)utexas.edu>
- src/util/virvhba.c
Signed-off-by: Barrett Schonefeld <bschoney(a)utexas.edu>
---
src/util/virvhba.c | 35 ++++++++++++-----------------------
1 file changed, 12 insertions(+), 23 deletions(-)
diff --git a/src/util/virvhba.c b/src/util/virvhba.c
index a4e88024d1..a80145b8fd 100644
--- a/src/util/virvhba.c
+++ b/src/util/virvhba.c
@@ -49,7 +49,7 @@ bool
virVHBAPathExists(const char *sysfs_prefix,
int host)
{
- char *sysfs_path = NULL;
+ g_autofree char *sysfs_path = NULL;
bool ret = false;
sysfs_path = g_strdup_printf("%s/host%d",
@@ -58,7 +58,6 @@ virVHBAPathExists(const char *sysfs_prefix,
if (virFileExists(sysfs_path))
ret = true;
- VIR_FREE(sysfs_path);
return ret;
}
@@ -79,8 +78,8 @@ bool
virVHBAIsVportCapable(const char *sysfs_prefix,
int host)
{
- char *scsi_host_path = NULL;
- char *fc_host_path = NULL;
+ g_autofree char *scsi_host_path = NULL;
+ g_autofree char *fc_host_path = NULL;
bool ret = false;
fc_host_path = g_strdup_printf("%s/host%d/%s",
@@ -94,8 +93,6 @@ virVHBAIsVportCapable(const char *sysfs_prefix,
if (virFileExists(fc_host_path) || virFileExists(scsi_host_path))
ret = true;
- VIR_FREE(fc_host_path);
- VIR_FREE(scsi_host_path);
return ret;
}
@@ -115,9 +112,9 @@ virVHBAGetConfig(const char *sysfs_prefix,
int host,
const char *entry)
{
- char *sysfs_path = NULL;
+ g_autofree char *sysfs_path = NULL;
char *p = NULL;
- char *buf = NULL;
+ g_autofree char *buf = NULL;
char *result = NULL;
sysfs_path = g_strdup_printf("%s/host%d/%s",
@@ -140,8 +137,6 @@ virVHBAGetConfig(const char *sysfs_prefix,
result = g_strdup(p);
cleanup:
- VIR_FREE(sysfs_path);
- VIR_FREE(buf);
return result;
}
@@ -160,8 +155,8 @@ virVHBAFindVportHost(const char *sysfs_prefix)
const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_FC_HOST_PATH;
g_autoptr(DIR) dir = NULL;
struct dirent *entry = NULL;
- char *max_vports = NULL;
- char *vports = NULL;
+ g_autofree char *max_vports = NULL;
+ g_autofree char *vports = NULL;
char *state = NULL;
char *ret = NULL;
@@ -220,8 +215,6 @@ virVHBAFindVportHost(const char *sysfs_prefix)
}
cleanup:
- VIR_FREE(max_vports);
- VIR_FREE(vports);
return ret;
}
@@ -241,7 +234,8 @@ virVHBAManageVport(const int parent_host,
int operation)
{
int ret = -1;
- char *operation_path = NULL, *vport_name = NULL;
+ g_autofree char *operation_path = NULL;
+ g_autofree char *vport_name = NULL;
const char *operation_file = NULL;
switch (operation) {
@@ -291,8 +285,6 @@ virVHBAManageVport(const int parent_host,
vport_name, operation_path);
cleanup:
- VIR_FREE(vport_name);
- VIR_FREE(operation_path);
return ret;
}
@@ -315,8 +307,8 @@ vhbaReadCompareWWN(const char *prefix,
const char *f_name,
const char *wwn)
{
- char *path;
- char *buf = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *buf = NULL;
char *p;
int ret = -1;
@@ -343,8 +335,6 @@ vhbaReadCompareWWN(const char *prefix,
ret = 1;
cleanup:
- VIR_FREE(path);
- VIR_FREE(buf);
return ret;
}
@@ -407,7 +397,7 @@ virVHBAGetHostByFabricWWN(const char *sysfs_prefix,
const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_FC_HOST_PATH;
struct dirent *entry = NULL;
g_autoptr(DIR) dir = NULL;
- char *vport_create_path = NULL;
+ g_autofree char *vport_create_path = NULL;
char *ret = NULL;
if (virDirOpen(&dir, prefix) < 0)
@@ -438,7 +428,6 @@ virVHBAGetHostByFabricWWN(const char *sysfs_prefix,
}
cleanup:
- VIR_FREE(vport_create_path);
return ret;
}
--
2.29.0