[PATCH 09/30] util: convert pointers to use g_autofree
Ján Tomko
jtomko at redhat.com
Tue Nov 24 11:57:51 UTC 2020
On a Monday in 2020, Ryan Gahagan wrote:
>From: Barrett Schonefeld <bschoney at utexas.edu>
>
>- src/util/virscsihost.c
>
>Signed-off-by: Barrett Schonefeld <bschoney at utexas.edu>
>---
> src/util/virscsihost.c | 15 +++++----------
> 1 file changed, 5 insertions(+), 10 deletions(-)
>
>diff --git a/src/util/virscsihost.c b/src/util/virscsihost.c
>index 969cdd9f79..2ce33e4cfb 100644
>--- a/src/util/virscsihost.c
>+++ b/src/util/virscsihost.c
>@@ -95,12 +95,12 @@ virSCSIHostFindByPCI(const char *sysfs_prefix,
> const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_HOST_PATH;
> struct dirent *entry = NULL;
> g_autoptr(DIR) dir = NULL;
>- char *host_link = NULL;
>- char *host_path = NULL;
>+ g_autofree char *host_link = NULL;
>+ g_autofree char *host_path = NULL;
> char *p = NULL;
> char *ret = NULL;
>- char *buf = NULL;
>- char *unique_path = NULL;
>+ g_autofree char *buf = NULL;
>+ g_autofree char *unique_path = NULL;
> unsigned int read_unique_id;
>
> if (virDirOpen(&dir, prefix) < 0)
>@@ -151,10 +151,6 @@ virSCSIHostFindByPCI(const char *sysfs_prefix,
> }
>
> cleanup:
>- VIR_FREE(unique_path);
>- VIR_FREE(host_link);
>- VIR_FREE(host_path);
>- VIR_FREE(buf);
All of these are also freed in the loop.
Jano
> return ret;
> }
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20201124/f5585255/attachment-0001.sig>
More information about the libvir-list
mailing list