From 5e7b4b3c166873030d51dc725907351f19d7e0fd Mon Sep 17 00:00:00 2001 From: Tycho Andersen Date: Thu, 9 May 2019 14:18:10 -0400 Subject: [PATCH] lxc_clone: get rid of some indirection We have a do_clone(), which just calls a void f(void *) that it gets passed. We build up a struct consisting of two args that are just the actual arg and actual function. Let's just have the syscall do this for us. Signed-off-by: Tycho Andersen --- src/lxc/namespace.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/lxc/namespace.c b/src/lxc/namespace.c index bc14fb52c..22c19f647 100644 --- a/src/lxc/namespace.c +++ b/src/lxc/namespace.c @@ -42,25 +42,10 @@ lxc_log_define(namespace, lxc); -struct clone_arg { - int (*fn)(void *); - void *arg; -}; - -static int do_clone(void *arg) -{ - struct clone_arg *clone_arg = arg; - return clone_arg->fn(clone_arg->arg); -} - #define __LXC_STACK_SIZE 4096 pid_t lxc_clone(int (*fn)(void *), void *arg, int flags, int *pidfd) { pid_t ret; - struct clone_arg clone_arg = { - .fn = fn, - .arg = arg, - }; void *stack; stack = malloc(__LXC_STACK_SIZE); @@ -70,9 +55,9 @@ pid_t lxc_clone(int (*fn)(void *), void *arg, int flags, int *pidfd) } #ifdef __ia64__ - ret = __clone2(fn, stack, __LXC_STACK_SIZE, flags | SIGCHLD, &clone_arg, pidfd); + ret = __clone2(fn, stack, __LXC_STACK_SIZE, flags | SIGCHLD, arg, pidfd); #else - ret = clone(fn, stack + __LXC_STACK_SIZE, flags | SIGCHLD, &clone_arg, pidfd); + ret = clone(fn, stack + __LXC_STACK_SIZE, flags | SIGCHLD, arg, pidfd); #endif if (ret < 0) SYSERROR("Failed to clone (%#x)", flags); -- 2.47.2