Commit 8b028bcd authored by Paolo 'Blaisorblade' Giarrusso's avatar Paolo 'Blaisorblade' Giarrusso Committed by Linus Torvalds

[PATCH] uml: code convention cleanup of a file

Fix coding conventions violations is arch/um/os-Linux/helper.c.
Signed-off-by: default avatarPaolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Cc: Jeff Dike <jdike@addtoit.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent c13e5690
...@@ -35,18 +35,18 @@ static int helper_child(void *arg) ...@@ -35,18 +35,18 @@ static int helper_child(void *arg)
char **argv = data->argv; char **argv = data->argv;
int errval; int errval;
if(helper_pause){ if (helper_pause){
signal(SIGHUP, helper_hup); signal(SIGHUP, helper_hup);
pause(); pause();
} }
if(data->pre_exec != NULL) if (data->pre_exec != NULL)
(*data->pre_exec)(data->pre_data); (*data->pre_exec)(data->pre_data);
execvp(argv[0], argv); execvp(argv[0], argv);
errval = -errno; errval = -errno;
printk("helper_child - execve of '%s' failed - errno = %d\n", argv[0], errno); printk("helper_child - execve of '%s' failed - errno = %d\n", argv[0], errno);
os_write_file(data->fd, &errval, sizeof(errval)); os_write_file(data->fd, &errval, sizeof(errval));
kill(os_getpid(), SIGKILL); kill(os_getpid(), SIGKILL);
return(0); return 0;
} }
/* Returns either the pid of the child process we run or -E* on failure. /* Returns either the pid of the child process we run or -E* on failure.
...@@ -58,20 +58,21 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, ...@@ -58,20 +58,21 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
unsigned long stack, sp; unsigned long stack, sp;
int pid, fds[2], ret, n; int pid, fds[2], ret, n;
if((stack_out != NULL) && (*stack_out != 0)) if ((stack_out != NULL) && (*stack_out != 0))
stack = *stack_out; stack = *stack_out;
else stack = alloc_stack(0, __cant_sleep()); else
if(stack == 0) stack = alloc_stack(0, __cant_sleep());
if (stack == 0)
return -ENOMEM; return -ENOMEM;
ret = os_pipe(fds, 1, 0); ret = os_pipe(fds, 1, 0);
if(ret < 0){ if (ret < 0) {
printk("run_helper : pipe failed, ret = %d\n", -ret); printk("run_helper : pipe failed, ret = %d\n", -ret);
goto out_free; goto out_free;
} }
ret = os_set_exec_close(fds[1], 1); ret = os_set_exec_close(fds[1], 1);
if(ret < 0){ if (ret < 0) {
printk("run_helper : setting FD_CLOEXEC failed, ret = %d\n", printk("run_helper : setting FD_CLOEXEC failed, ret = %d\n",
-ret); -ret);
goto out_close; goto out_close;
...@@ -83,7 +84,7 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, ...@@ -83,7 +84,7 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
data.argv = argv; data.argv = argv;
data.fd = fds[1]; data.fd = fds[1];
pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data); pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data);
if(pid < 0){ if (pid < 0) {
ret = -errno; ret = -errno;
printk("run_helper : clone failed, errno = %d\n", errno); printk("run_helper : clone failed, errno = %d\n", errno);
goto out_close; goto out_close;
...@@ -95,10 +96,10 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, ...@@ -95,10 +96,10 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
/* Read the errno value from the child, if the exec failed, or get 0 if /* Read the errno value from the child, if the exec failed, or get 0 if
* the exec succeeded because the pipe fd was set as close-on-exec. */ * the exec succeeded because the pipe fd was set as close-on-exec. */
n = os_read_file(fds[0], &ret, sizeof(ret)); n = os_read_file(fds[0], &ret, sizeof(ret));
if(n == 0) if (n == 0) {
ret = pid; ret = pid;
else { } else {
if(n < 0){ if (n < 0) {
printk("run_helper : read on pipe failed, ret = %d\n", printk("run_helper : read on pipe failed, ret = %d\n",
-n); -n);
ret = n; ret = n;
...@@ -112,10 +113,11 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, ...@@ -112,10 +113,11 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
close(fds[1]); close(fds[1]);
close(fds[0]); close(fds[0]);
out_free: out_free:
if(stack_out == NULL) if (stack_out == NULL)
free_stack(stack, 0); free_stack(stack, 0);
else *stack_out = stack; else
return(ret); *stack_out = stack;
return ret;
} }
int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags,
...@@ -125,31 +127,32 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, ...@@ -125,31 +127,32 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags,
int pid, status, err; int pid, status, err;
stack = alloc_stack(stack_order, __cant_sleep()); stack = alloc_stack(stack_order, __cant_sleep());
if(stack == 0) return(-ENOMEM); if (stack == 0)
return -ENOMEM;
sp = stack + (page_size() << stack_order) - sizeof(void *); sp = stack + (page_size() << stack_order) - sizeof(void *);
pid = clone(proc, (void *) sp, flags | SIGCHLD, arg); pid = clone(proc, (void *) sp, flags | SIGCHLD, arg);
if(pid < 0){ if (pid < 0) {
err = -errno; err = -errno;
printk("run_helper_thread : clone failed, errno = %d\n", printk("run_helper_thread : clone failed, errno = %d\n",
errno); errno);
return err; return err;
} }
if(stack_out == NULL){ if (stack_out == NULL) {
CATCH_EINTR(pid = waitpid(pid, &status, 0)); CATCH_EINTR(pid = waitpid(pid, &status, 0));
if(pid < 0){ if (pid < 0) {
err = -errno; err = -errno;
printk("run_helper_thread - wait failed, errno = %d\n", printk("run_helper_thread - wait failed, errno = %d\n",
errno); errno);
pid = err; pid = err;
} }
if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0))
printk("run_helper_thread - thread returned status " printk("run_helper_thread - thread returned status "
"0x%x\n", status); "0x%x\n", status);
free_stack(stack, stack_order); free_stack(stack, stack_order);
} } else
else *stack_out = stack; *stack_out = stack;
return(pid); return pid;
} }
int helper_wait(int pid) int helper_wait(int pid)
...@@ -157,9 +160,9 @@ int helper_wait(int pid) ...@@ -157,9 +160,9 @@ int helper_wait(int pid)
int ret; int ret;
CATCH_EINTR(ret = waitpid(pid, NULL, WNOHANG)); CATCH_EINTR(ret = waitpid(pid, NULL, WNOHANG));
if(ret < 0){ if (ret < 0) {
ret = -errno; ret = -errno;
printk("helper_wait : waitpid failed, errno = %d\n", errno); printk("helper_wait : waitpid failed, errno = %d\n", errno);
} }
return(ret); return ret;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment