As Pino's comment, we should take advantage of
macro CLEANUP_FREE_STRING_LIST.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
v2: initialize variable of CLEANUP_FREE_STRING_LIST to null
daemon/btrfs.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 39392f7..3ca39ab 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -409,7 +409,7 @@ umount (char *fs_buf, const mountable_t *fs)
guestfs_int_btrfssubvolume_list *
do_btrfs_subvolume_list (const mountable_t *fs)
{
- char **lines;
+ CLEANUP_FREE_STRING_LIST char **lines = NULL;
size_t i = 0;
const size_t MAX_ARGS = 64;
const char *argv[MAX_ARGS];
@@ -534,13 +534,11 @@ do_btrfs_subvolume_list (const mountable_t *fs)
this->btrfssubvolume_path = line;
}
- free (lines);
pcre_free (re);
return ret;
error:
- free_stringslen (lines, nr_subvolumes);
if (ret) free (ret->guestfs_int_btrfssubvolume_list_val);
free (ret);
if (re) pcre_free (re);
@@ -1253,8 +1251,8 @@ do_btrfs_qgroup_show (const char *path)
CLEANUP_FREE char *path_buf = NULL;
CLEANUP_FREE char *err = NULL;
CLEANUP_FREE char *out = NULL;
+ CLEANUP_FREE_STRING_LIST char **lines = NULL;
int r;
- char **lines;
path_buf = sysroot_path (path);
if (path_buf == NULL) {
@@ -1323,11 +1321,9 @@ do_btrfs_qgroup_show (const char *path)
this->btrfsqgroup_id = line;
}
- free (lines);
return ret;
error:
- free_stringslen (lines, nr_qgroups + 2);
if (ret)
free (ret->guestfs_int_btrfsqgroup_list_val);
free (ret);
@@ -1704,10 +1700,10 @@ do_btrfs_balance_status (const char *path)
size_t i = 0;
CLEANUP_FREE char *path_buf = NULL;
CLEANUP_FREE char *err = NULL;
+ CLEANUP_FREE_STRING_LIST char **lines = NULL;
char *out;
int r;
guestfs_int_btrfsbalance *ret;
- char **lines;
size_t nlines;
const char *errptr;
int erroffset;
@@ -1830,10 +1826,10 @@ do_btrfs_scrub_status (const char *path)
size_t i = 0;
CLEANUP_FREE char *path_buf = NULL;
CLEANUP_FREE char *err = NULL;
+ CLEANUP_FREE_STRING_LIST char **lines = NULL;
char *out;
int r;
guestfs_int_btrfsscrub *ret;
- char **lines;
path_buf = sysroot_path (path);
if (path_buf == NULL) {
--
2.1.0