]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc_clone: get rid of some indirection
authorTycho Andersen <tycho@tycho.ws>
Thu, 9 May 2019 18:18:10 +0000 (14:18 -0400)
committerTycho Andersen <tycho@tycho.ws>
Wed, 15 May 2019 13:56:29 +0000 (07:56 -0600)
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 <tycho@tycho.ws>
src/lxc/namespace.c

index bc14fb52c91aaba4c03c6fb4396fca301fcf2a17..22c19f647bfa3a2d68a8d552070f331eb8a5c6eb 100644 (file)
 
 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);