Change strings to use g_autofree.
Signed-off-by: Maxim Kostin <ttxinee(a)outlook.com>
---
src/util/virvhba.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/src/util/virvhba.c b/src/util/virvhba.c
index a4e88024d1..76c39e5f2b 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;
}
@@ -315,8 +310,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 +338,6 @@ vhbaReadCompareWWN(const char *prefix,
ret = 1;
cleanup:
- VIR_FREE(path);
- VIR_FREE(buf);
return ret;
}
--
2.34.1