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

Christian Brauner christian.brauner at mailbox.org
Tue Nov 10 07:09:32 UTC 2015


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

diff --git a/src/lxc/lxc_copy.c b/src/lxc/lxc_copy.c
index e5f52d2..be2e3ee 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};
 
@@ -589,7 +588,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 +630,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 +711,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