Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Hans-Werner Hilse <hwhilse@gmail.com>
Signed-off-by: Richard Weinberger <richard@nod.at>

authored by

Hans-Werner Hilse and committed by
Richard Weinberger
f9bb3b59 9a75551a

+30 -30
+9 -9
arch/um/drivers/harddog_user.c
··· 9 9 #include <os.h> 10 10 11 11 struct dog_data { 12 - int stdin; 13 - int stdout; 12 + int stdin_fd; 13 + int stdout_fd; 14 14 int close_me[2]; 15 15 }; 16 16 ··· 18 18 { 19 19 struct dog_data *data = d; 20 20 21 - dup2(data->stdin, 0); 22 - dup2(data->stdout, 1); 23 - dup2(data->stdout, 2); 24 - close(data->stdin); 25 - close(data->stdout); 21 + dup2(data->stdin_fd, 0); 22 + dup2(data->stdout_fd, 1); 23 + dup2(data->stdout_fd, 2); 24 + close(data->stdin_fd); 25 + close(data->stdout_fd); 26 26 close(data->close_me[0]); 27 27 close(data->close_me[1]); 28 28 } ··· 49 49 goto out_close_in; 50 50 } 51 51 52 - data.stdin = out_fds[0]; 53 - data.stdout = in_fds[1]; 52 + data.stdin_fd = out_fds[0]; 53 + data.stdout_fd = in_fds[1]; 54 54 data.close_me[0] = out_fds[1]; 55 55 data.close_me[1] = in_fds[0]; 56 56
+3 -3
arch/um/drivers/net_user.c
··· 166 166 167 167 struct change_pre_exec_data { 168 168 int close_me; 169 - int stdout; 169 + int stdout_fd; 170 170 }; 171 171 172 172 static void change_pre_exec(void *arg) ··· 174 174 struct change_pre_exec_data *data = arg; 175 175 176 176 close(data->close_me); 177 - dup2(data->stdout, 1); 177 + dup2(data->stdout_fd, 1); 178 178 } 179 179 180 180 static int change_tramp(char **argv, char *output, int output_len) ··· 189 189 return err; 190 190 } 191 191 pe_data.close_me = fds[0]; 192 - pe_data.stdout = fds[1]; 192 + pe_data.stdout_fd = fds[1]; 193 193 pid = run_helper(change_pre_exec, &pe_data, argv); 194 194 195 195 if (pid > 0) /* Avoid hang as we won't get data in failure case. */
+7 -7
arch/um/drivers/slip_user.c
··· 55 55 } 56 56 57 57 struct slip_pre_exec_data { 58 - int stdin; 59 - int stdout; 58 + int stdin_fd; 59 + int stdout_fd; 60 60 int close_me; 61 61 }; 62 62 ··· 64 64 { 65 65 struct slip_pre_exec_data *data = arg; 66 66 67 - if (data->stdin >= 0) 68 - dup2(data->stdin, 0); 69 - dup2(data->stdout, 1); 67 + if (data->stdin_fd >= 0) 68 + dup2(data->stdin_fd, 0); 69 + dup2(data->stdout_fd, 1); 70 70 if (data->close_me >= 0) 71 71 close(data->close_me); 72 72 } ··· 85 85 } 86 86 87 87 err = 0; 88 - pe_data.stdin = fd; 89 - pe_data.stdout = fds[1]; 88 + pe_data.stdin_fd = fd; 89 + pe_data.stdout_fd = fds[1]; 90 90 pe_data.close_me = fds[0]; 91 91 err = run_helper(slip_pre_exec, &pe_data, argv); 92 92 if (err < 0)
+8 -8
arch/um/drivers/slirp_user.c
··· 20 20 } 21 21 22 22 struct slirp_pre_exec_data { 23 - int stdin; 24 - int stdout; 23 + int stdin_fd; 24 + int stdout_fd; 25 25 }; 26 26 27 27 static void slirp_pre_exec(void *arg) 28 28 { 29 29 struct slirp_pre_exec_data *data = arg; 30 30 31 - if (data->stdin != -1) 32 - dup2(data->stdin, 0); 33 - if (data->stdout != -1) 34 - dup2(data->stdout, 1); 31 + if (data->stdin_fd != -1) 32 + dup2(data->stdin_fd, 0); 33 + if (data->stdout_fd != -1) 34 + dup2(data->stdout_fd, 1); 35 35 } 36 36 37 37 static int slirp_tramp(char **argv, int fd) ··· 39 39 struct slirp_pre_exec_data pe_data; 40 40 int pid; 41 41 42 - pe_data.stdin = fd; 43 - pe_data.stdout = fd; 42 + pe_data.stdin_fd = fd; 43 + pe_data.stdout_fd = fd; 44 44 pid = run_helper(slirp_pre_exec, &pe_data, argv); 45 45 46 46 return pid;
+3 -3
arch/um/os-Linux/drivers/tuntap_user.c
··· 47 47 } 48 48 49 49 struct tuntap_pre_exec_data { 50 - int stdout; 50 + int stdout_fd; 51 51 int close_me; 52 52 }; 53 53 ··· 55 55 { 56 56 struct tuntap_pre_exec_data *data = arg; 57 57 58 - dup2(data->stdout, 1); 58 + dup2(data->stdout_fd, 1); 59 59 close(data->close_me); 60 60 } 61 61 ··· 74 74 75 75 sprintf(version_buf, "%d", UML_NET_VERSION); 76 76 77 - data.stdout = remote; 77 + data.stdout_fd = remote; 78 78 data.close_me = me; 79 79 80 80 pid = run_helper(tuntap_pre_exec, &data, argv);