[lxc-devel] [PATCH 3/3] Do not pass global variable as pointer

Christian Brauner christian.brauner at mailbox.org
Mon Nov 9 20:47:29 UTC 2015


Signed-off-by: Christian Brauner <christian.brauner at mailbox.org>
---
 src/lxc/lxc_copy.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/lxc/lxc_copy.c b/src/lxc/lxc_copy.c
index e5f52d2..791d7a2 100644
--- a/src/lxc/lxc_copy.c
+++ b/src/lxc/lxc_copy.c
@@ -123,8 +123,7 @@ Options :\n\
 	.daemonize = 1,
 };
 
-static struct mnts *add_mnt(struct mnts **mnts, unsigned int *num,
-			    enum mnttype type);
+static struct mnts *add_mnt(struct mnts **mnts, enum mnttype type);
 static int mk_rand_ovl_dirs(struct mnts *mnts, struct lxc_arguments *my_args);
 static char *construct_path(char *path, bool as_prefix);
 static char *set_mnt_entry(struct mnts *m);
@@ -211,17 +210,17 @@ int main(int argc, char *argv[])
 	exit(EXIT_FAILURE);
 }
 
-static struct mnts *add_mnt(struct mnts **mnts, unsigned int *num, enum mnttype type)
+static struct mnts *add_mnt(struct mnts **mnts, enum mnttype type)
 {
 	struct mnts *m, *n;
 
-	n = realloc(*mnts, (*num + 1) * sizeof(struct mnts));
+	n = realloc(*mnts, (num + 1) * sizeof(struct mnts));
 	if (!n)
 		return NULL;
 
 	*mnts = n;
-	m = *mnts + *num;
-	(*num)++;
+	m = *mnts + num;
+	num++;
 
 	*m = (struct mnts) {.type = type};
 
@@ -401,6 +400,7 @@ static int do_clone_ephemeral(struct lxc_container *c,
 		goto err;
 
 	/* allocate and set mount entries */
+	printf("%u\n", num);
 	for (i = 0; i < num; i++) {
 		char *mntentry = NULL;
 		n = mnts + i;
@@ -589,7 +589,7 @@ static int parse_aufs_mnt(char *mntstring, enum mnttype type)
 	char **mntarray = NULL;
 	struct mnts *m = NULL;
 
-	m = add_mnt(&mnts, &num, type);
+	m = add_mnt(&mnts, type);
 	if (!m)
 		goto err;
 
@@ -631,7 +631,7 @@ static int parse_bind_mnt(char *mntstring, enum mnttype type)
 	char **mntarray = NULL;
 	struct mnts *m = NULL;
 
-	m = add_mnt(&mnts, &num, type);
+	m = add_mnt(&mnts, type);
 	if (!m)
 		goto err;
 
@@ -712,7 +712,7 @@ static int parse_ovl_mnt(char *mntstring, enum mnttype type)
 	char **mntarray = NULL;
 	struct mnts *m;
 
-	m = add_mnt(&mnts, &num, type);
+	m = add_mnt(&mnts, type);
 	if (!m)
 		goto err;
 
-- 
2.6.2



More information about the lxc-devel mailing list