Commit f9bb3b59 authored by Hans-Werner Hilse's avatar Hans-Werner Hilse Committed by Richard Weinberger

um: Do not use stdin and stdout identifiers for struct members

stdin, stdout and stderr are macros according to C89/C99.
Thus do not use them as struct member identifiers to avoid
bad results from macro expansion.
Signed-off-by: default avatarHans-Werner Hilse <hwhilse@gmail.com>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent 9a75551a
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
#include <os.h> #include <os.h>
struct dog_data { struct dog_data {
int stdin; int stdin_fd;
int stdout; int stdout_fd;
int close_me[2]; int close_me[2];
}; };
...@@ -18,11 +18,11 @@ static void pre_exec(void *d) ...@@ -18,11 +18,11 @@ static void pre_exec(void *d)
{ {
struct dog_data *data = d; struct dog_data *data = d;
dup2(data->stdin, 0); dup2(data->stdin_fd, 0);
dup2(data->stdout, 1); dup2(data->stdout_fd, 1);
dup2(data->stdout, 2); dup2(data->stdout_fd, 2);
close(data->stdin); close(data->stdin_fd);
close(data->stdout); close(data->stdout_fd);
close(data->close_me[0]); close(data->close_me[0]);
close(data->close_me[1]); close(data->close_me[1]);
} }
...@@ -49,8 +49,8 @@ int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock) ...@@ -49,8 +49,8 @@ int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock)
goto out_close_in; goto out_close_in;
} }
data.stdin = out_fds[0]; data.stdin_fd = out_fds[0];
data.stdout = in_fds[1]; data.stdout_fd = in_fds[1];
data.close_me[0] = out_fds[1]; data.close_me[0] = out_fds[1];
data.close_me[1] = in_fds[0]; data.close_me[1] = in_fds[0];
......
...@@ -166,7 +166,7 @@ int net_sendto(int fd, void *buf, int len, void *to, int sock_len) ...@@ -166,7 +166,7 @@ int net_sendto(int fd, void *buf, int len, void *to, int sock_len)
struct change_pre_exec_data { struct change_pre_exec_data {
int close_me; int close_me;
int stdout; int stdout_fd;
}; };
static void change_pre_exec(void *arg) static void change_pre_exec(void *arg)
...@@ -174,7 +174,7 @@ static void change_pre_exec(void *arg) ...@@ -174,7 +174,7 @@ static void change_pre_exec(void *arg)
struct change_pre_exec_data *data = arg; struct change_pre_exec_data *data = arg;
close(data->close_me); close(data->close_me);
dup2(data->stdout, 1); dup2(data->stdout_fd, 1);
} }
static int change_tramp(char **argv, char *output, int output_len) static int change_tramp(char **argv, char *output, int output_len)
...@@ -189,7 +189,7 @@ static int change_tramp(char **argv, char *output, int output_len) ...@@ -189,7 +189,7 @@ static int change_tramp(char **argv, char *output, int output_len)
return err; return err;
} }
pe_data.close_me = fds[0]; pe_data.close_me = fds[0];
pe_data.stdout = fds[1]; pe_data.stdout_fd = fds[1];
pid = run_helper(change_pre_exec, &pe_data, argv); pid = run_helper(change_pre_exec, &pe_data, argv);
if (pid > 0) /* Avoid hang as we won't get data in failure case. */ if (pid > 0) /* Avoid hang as we won't get data in failure case. */
......
...@@ -55,8 +55,8 @@ static int set_up_tty(int fd) ...@@ -55,8 +55,8 @@ static int set_up_tty(int fd)
} }
struct slip_pre_exec_data { struct slip_pre_exec_data {
int stdin; int stdin_fd;
int stdout; int stdout_fd;
int close_me; int close_me;
}; };
...@@ -64,9 +64,9 @@ static void slip_pre_exec(void *arg) ...@@ -64,9 +64,9 @@ static void slip_pre_exec(void *arg)
{ {
struct slip_pre_exec_data *data = arg; struct slip_pre_exec_data *data = arg;
if (data->stdin >= 0) if (data->stdin_fd >= 0)
dup2(data->stdin, 0); dup2(data->stdin_fd, 0);
dup2(data->stdout, 1); dup2(data->stdout_fd, 1);
if (data->close_me >= 0) if (data->close_me >= 0)
close(data->close_me); close(data->close_me);
} }
...@@ -85,8 +85,8 @@ static int slip_tramp(char **argv, int fd) ...@@ -85,8 +85,8 @@ static int slip_tramp(char **argv, int fd)
} }
err = 0; err = 0;
pe_data.stdin = fd; pe_data.stdin_fd = fd;
pe_data.stdout = fds[1]; pe_data.stdout_fd = fds[1];
pe_data.close_me = fds[0]; pe_data.close_me = fds[0];
err = run_helper(slip_pre_exec, &pe_data, argv); err = run_helper(slip_pre_exec, &pe_data, argv);
if (err < 0) if (err < 0)
......
...@@ -20,18 +20,18 @@ static int slirp_user_init(void *data, void *dev) ...@@ -20,18 +20,18 @@ static int slirp_user_init(void *data, void *dev)
} }
struct slirp_pre_exec_data { struct slirp_pre_exec_data {
int stdin; int stdin_fd;
int stdout; int stdout_fd;
}; };
static void slirp_pre_exec(void *arg) static void slirp_pre_exec(void *arg)
{ {
struct slirp_pre_exec_data *data = arg; struct slirp_pre_exec_data *data = arg;
if (data->stdin != -1) if (data->stdin_fd != -1)
dup2(data->stdin, 0); dup2(data->stdin_fd, 0);
if (data->stdout != -1) if (data->stdout_fd != -1)
dup2(data->stdout, 1); dup2(data->stdout_fd, 1);
} }
static int slirp_tramp(char **argv, int fd) static int slirp_tramp(char **argv, int fd)
...@@ -39,8 +39,8 @@ static int slirp_tramp(char **argv, int fd) ...@@ -39,8 +39,8 @@ static int slirp_tramp(char **argv, int fd)
struct slirp_pre_exec_data pe_data; struct slirp_pre_exec_data pe_data;
int pid; int pid;
pe_data.stdin = fd; pe_data.stdin_fd = fd;
pe_data.stdout = fd; pe_data.stdout_fd = fd;
pid = run_helper(slirp_pre_exec, &pe_data, argv); pid = run_helper(slirp_pre_exec, &pe_data, argv);
return pid; return pid;
......
...@@ -47,7 +47,7 @@ static void tuntap_del_addr(unsigned char *addr, unsigned char *netmask, ...@@ -47,7 +47,7 @@ static void tuntap_del_addr(unsigned char *addr, unsigned char *netmask,
} }
struct tuntap_pre_exec_data { struct tuntap_pre_exec_data {
int stdout; int stdout_fd;
int close_me; int close_me;
}; };
...@@ -55,7 +55,7 @@ static void tuntap_pre_exec(void *arg) ...@@ -55,7 +55,7 @@ static void tuntap_pre_exec(void *arg)
{ {
struct tuntap_pre_exec_data *data = arg; struct tuntap_pre_exec_data *data = arg;
dup2(data->stdout, 1); dup2(data->stdout_fd, 1);
close(data->close_me); close(data->close_me);
} }
...@@ -74,7 +74,7 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote, ...@@ -74,7 +74,7 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote,
sprintf(version_buf, "%d", UML_NET_VERSION); sprintf(version_buf, "%d", UML_NET_VERSION);
data.stdout = remote; data.stdout_fd = remote;
data.close_me = me; data.close_me = me;
pid = run_helper(tuntap_pre_exec, &data, argv); pid = run_helper(tuntap_pre_exec, &data, argv);
......
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