aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/os-Linux
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2007-05-06 17:51:02 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-07 15:13:00 -0400
commit56bd194bb200ef0c49517de67a7d7f4b043b11b1 (patch)
tree2c180ee0e18e0e18b997a8a14d84505f0388f1c7 /arch/um/os-Linux
parentb47d2debf229469c78af4145ee7ad35a0f21b67f (diff)
uml: driver formatting fixes
Fix a bunch of formatting violations in the drivers: return(n) -> return n whitespace fixes emacs formatting comment removal breaking if(foo) return(n) into two lines There are also a couple of errno use bugs: using errno in a printk when the failure put errno into a local variable saving errno after a printk, which can change it Signed-off-by: Jeff Dike <jdike@linux.intel.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/os-Linux')
-rw-r--r--arch/um/os-Linux/drivers/ethertap_user.c36
-rw-r--r--arch/um/os-Linux/drivers/tuntap_user.c40
2 files changed, 30 insertions, 46 deletions
diff --git a/arch/um/os-Linux/drivers/ethertap_user.c b/arch/um/os-Linux/drivers/ethertap_user.c
index 863981ba1468..f3ad0dac7cdc 100644
--- a/arch/um/os-Linux/drivers/ethertap_user.c
+++ b/arch/um/os-Linux/drivers/ethertap_user.c
@@ -121,7 +121,7 @@ static int etap_tramp(char *dev, char *gate, int control_me,
121 n = os_read_file(control_me, &c, sizeof(c)); 121 n = os_read_file(control_me, &c, sizeof(c));
122 if(n != sizeof(c)){ 122 if(n != sizeof(c)){
123 printk("etap_tramp : read of status failed, err = %d\n", -n); 123 printk("etap_tramp : read of status failed, err = %d\n", -n);
124 return(-EINVAL); 124 return -EINVAL;
125 } 125 }
126 if(c != 1){ 126 if(c != 1){
127 printk("etap_tramp : uml_net failed\n"); 127 printk("etap_tramp : uml_net failed\n");
@@ -132,7 +132,7 @@ static int etap_tramp(char *dev, char *gate, int control_me,
132 else if(!WIFEXITED(status) || (WEXITSTATUS(status) != 1)) 132 else if(!WIFEXITED(status) || (WEXITSTATUS(status) != 1))
133 printk("uml_net didn't exit with status 1\n"); 133 printk("uml_net didn't exit with status 1\n");
134 } 134 }
135 return(err); 135 return err;
136} 136}
137 137
138static int etap_open(void *data) 138static int etap_open(void *data)
@@ -142,20 +142,21 @@ static int etap_open(void *data)
142 int data_fds[2], control_fds[2], err, output_len; 142 int data_fds[2], control_fds[2], err, output_len;
143 143
144 err = tap_open_common(pri->dev, pri->gate_addr); 144 err = tap_open_common(pri->dev, pri->gate_addr);
145 if(err) return(err); 145 if(err)
146 return err;
146 147
147 err = os_pipe(data_fds, 0, 0); 148 err = os_pipe(data_fds, 0, 0);
148 if(err < 0){ 149 if(err < 0){
149 printk("data os_pipe failed - err = %d\n", -err); 150 printk("data os_pipe failed - err = %d\n", -err);
150 return(err); 151 return err;
151 } 152 }
152 153
153 err = os_pipe(control_fds, 1, 0); 154 err = os_pipe(control_fds, 1, 0);
154 if(err < 0){ 155 if(err < 0){
155 printk("control os_pipe failed - err = %d\n", -err); 156 printk("control os_pipe failed - err = %d\n", -err);
156 return(err); 157 return err;
157 } 158 }
158 159
159 err = etap_tramp(pri->dev_name, pri->gate_addr, control_fds[0], 160 err = etap_tramp(pri->dev_name, pri->gate_addr, control_fds[0],
160 control_fds[1], data_fds[0], data_fds[1]); 161 control_fds[1], data_fds[0], data_fds[1]);
161 output_len = page_size(); 162 output_len = page_size();
@@ -171,13 +172,13 @@ static int etap_open(void *data)
171 172
172 if(err < 0){ 173 if(err < 0){
173 printk("etap_tramp failed - err = %d\n", -err); 174 printk("etap_tramp failed - err = %d\n", -err);
174 return(err); 175 return err;
175 } 176 }
176 177
177 pri->data_fd = data_fds[0]; 178 pri->data_fd = data_fds[0];
178 pri->control_fd = control_fds[0]; 179 pri->control_fd = control_fds[0];
179 iter_addresses(pri->dev, etap_open_addr, &pri->control_fd); 180 iter_addresses(pri->dev, etap_open_addr, &pri->control_fd);
180 return(data_fds[0]); 181 return data_fds[0];
181} 182}
182 183
183static void etap_close(int fd, void *data) 184static void etap_close(int fd, void *data)
@@ -195,7 +196,7 @@ static void etap_close(int fd, void *data)
195 196
196static int etap_set_mtu(int mtu, void *data) 197static int etap_set_mtu(int mtu, void *data)
197{ 198{
198 return(mtu); 199 return mtu;
199} 200}
200 201
201static void etap_add_addr(unsigned char *addr, unsigned char *netmask, 202static void etap_add_addr(unsigned char *addr, unsigned char *netmask,
@@ -204,7 +205,8 @@ static void etap_add_addr(unsigned char *addr, unsigned char *netmask,
204 struct ethertap_data *pri = data; 205 struct ethertap_data *pri = data;
205 206
206 tap_check_ips(pri->gate_addr, addr); 207 tap_check_ips(pri->gate_addr, addr);
207 if(pri->control_fd == -1) return; 208 if(pri->control_fd == -1)
209 return;
208 etap_open_addr(addr, netmask, &pri->control_fd); 210 etap_open_addr(addr, netmask, &pri->control_fd);
209} 211}
210 212
@@ -213,7 +215,8 @@ static void etap_del_addr(unsigned char *addr, unsigned char *netmask,
213{ 215{
214 struct ethertap_data *pri = data; 216 struct ethertap_data *pri = data;
215 217
216 if(pri->control_fd == -1) return; 218 if(pri->control_fd == -1)
219 return;
217 etap_close_addr(addr, netmask, &pri->control_fd); 220 etap_close_addr(addr, netmask, &pri->control_fd);
218} 221}
219 222
@@ -227,14 +230,3 @@ const struct net_user_info ethertap_user_info = {
227 .delete_address = etap_del_addr, 230 .delete_address = etap_del_addr,
228 .max_packet = MAX_PACKET - ETH_HEADER_ETHERTAP 231 .max_packet = MAX_PACKET - ETH_HEADER_ETHERTAP
229}; 232};
230
231/*
232 * Overrides for Emacs so that we follow Linus's tabbing style.
233 * Emacs will notice this stuff at the end of the file and automatically
234 * adjust the settings for this buffer only. This must remain at the end
235 * of the file.
236 * ---------------------------------------------------------------------------
237 * Local variables:
238 * c-file-style: "linux"
239 * End:
240 */
diff --git a/arch/um/os-Linux/drivers/tuntap_user.c b/arch/um/os-Linux/drivers/tuntap_user.c
index e846b23f7558..ab63fb6f9992 100644
--- a/arch/um/os-Linux/drivers/tuntap_user.c
+++ b/arch/um/os-Linux/drivers/tuntap_user.c
@@ -37,7 +37,8 @@ static void tuntap_add_addr(unsigned char *addr, unsigned char *netmask,
37 struct tuntap_data *pri = data; 37 struct tuntap_data *pri = data;
38 38
39 tap_check_ips(pri->gate_addr, addr); 39 tap_check_ips(pri->gate_addr, addr);
40 if((pri->fd == -1) || pri->fixed_config) return; 40 if((pri->fd == -1) || pri->fixed_config)
41 return;
41 open_addr(addr, netmask, pri->dev_name); 42 open_addr(addr, netmask, pri->dev_name);
42} 43}
43 44
@@ -46,7 +47,8 @@ static void tuntap_del_addr(unsigned char *addr, unsigned char *netmask,
46{ 47{
47 struct tuntap_data *pri = data; 48 struct tuntap_data *pri = data;
48 49
49 if((pri->fd == -1) || pri->fixed_config) return; 50 if((pri->fd == -1) || pri->fixed_config)
51 return;
50 close_addr(addr, netmask, pri->dev_name); 52 close_addr(addr, netmask, pri->dev_name);
51} 53}
52 54
@@ -58,7 +60,7 @@ struct tuntap_pre_exec_data {
58static void tuntap_pre_exec(void *arg) 60static void tuntap_pre_exec(void *arg)
59{ 61{
60 struct tuntap_pre_exec_data *data = arg; 62 struct tuntap_pre_exec_data *data = arg;
61 63
62 dup2(data->stdout, 1); 64 dup2(data->stdout, 1);
63 os_close_file(data->close_me); 65 os_close_file(data->close_me);
64} 66}
@@ -83,7 +85,8 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote,
83 85
84 pid = run_helper(tuntap_pre_exec, &data, argv, NULL); 86 pid = run_helper(tuntap_pre_exec, &data, argv, NULL);
85 87
86 if(pid < 0) return(-pid); 88 if(pid < 0)
89 return -pid;
87 90
88 os_close_file(remote); 91 os_close_file(remote);
89 92
@@ -114,16 +117,16 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote,
114 cmsg = CMSG_FIRSTHDR(&msg); 117 cmsg = CMSG_FIRSTHDR(&msg);
115 if(cmsg == NULL){ 118 if(cmsg == NULL){
116 printk("tuntap_open_tramp : didn't receive a message\n"); 119 printk("tuntap_open_tramp : didn't receive a message\n");
117 return(-EINVAL); 120 return -EINVAL;
118 } 121 }
119 if((cmsg->cmsg_level != SOL_SOCKET) || 122 if((cmsg->cmsg_level != SOL_SOCKET) ||
120 (cmsg->cmsg_type != SCM_RIGHTS)){ 123 (cmsg->cmsg_type != SCM_RIGHTS)){
121 printk("tuntap_open_tramp : didn't receive a descriptor\n"); 124 printk("tuntap_open_tramp : didn't receive a descriptor\n");
122 return(-EINVAL); 125 return -EINVAL;
123 } 126 }
124 *fd_out = ((int *) CMSG_DATA(cmsg))[0]; 127 *fd_out = ((int *) CMSG_DATA(cmsg))[0];
125 os_set_exec_close(*fd_out, 1); 128 os_set_exec_close(*fd_out, 1);
126 return(0); 129 return 0;
127} 130}
128 131
129static int tuntap_open(void *data) 132static int tuntap_open(void *data)
@@ -135,7 +138,7 @@ static int tuntap_open(void *data)
135 138
136 err = tap_open_common(pri->dev, pri->gate_addr); 139 err = tap_open_common(pri->dev, pri->gate_addr);
137 if(err < 0) 140 if(err < 0)
138 return(err); 141 return err;
139 142
140 if(pri->fixed_config){ 143 if(pri->fixed_config){
141 pri->fd = os_open_file("/dev/net/tun", 144 pri->fd = os_open_file("/dev/net/tun",
@@ -143,7 +146,7 @@ static int tuntap_open(void *data)
143 if(pri->fd < 0){ 146 if(pri->fd < 0){
144 printk("Failed to open /dev/net/tun, err = %d\n", 147 printk("Failed to open /dev/net/tun, err = %d\n",
145 -pri->fd); 148 -pri->fd);
146 return(pri->fd); 149 return pri->fd;
147 } 150 }
148 memset(&ifr, 0, sizeof(ifr)); 151 memset(&ifr, 0, sizeof(ifr));
149 ifr.ifr_flags = IFF_TAP | IFF_NO_PI; 152 ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
@@ -160,7 +163,7 @@ static int tuntap_open(void *data)
160 if(err < 0){ 163 if(err < 0){
161 printk("tuntap_open : os_pipe failed - err = %d\n", 164 printk("tuntap_open : os_pipe failed - err = %d\n",
162 -err); 165 -err);
163 return(err); 166 return err;
164 } 167 }
165 168
166 buffer = get_output_buffer(&len); 169 buffer = get_output_buffer(&len);
@@ -175,7 +178,7 @@ static int tuntap_open(void *data)
175 printk("%s", output); 178 printk("%s", output);
176 free_output_buffer(buffer); 179 free_output_buffer(buffer);
177 printk("tuntap_open_tramp failed - err = %d\n", -err); 180 printk("tuntap_open_tramp failed - err = %d\n", -err);
178 return(err); 181 return err;
179 } 182 }
180 183
181 pri->dev_name = uml_strdup(buffer); 184 pri->dev_name = uml_strdup(buffer);
@@ -187,7 +190,7 @@ static int tuntap_open(void *data)
187 iter_addresses(pri->dev, open_addr, pri->dev_name); 190 iter_addresses(pri->dev, open_addr, pri->dev_name);
188 } 191 }
189 192
190 return(pri->fd); 193 return pri->fd;
191} 194}
192 195
193static void tuntap_close(int fd, void *data) 196static void tuntap_close(int fd, void *data)
@@ -202,7 +205,7 @@ static void tuntap_close(int fd, void *data)
202 205
203static int tuntap_set_mtu(int mtu, void *data) 206static int tuntap_set_mtu(int mtu, void *data)
204{ 207{
205 return(mtu); 208 return mtu;
206} 209}
207 210
208const struct net_user_info tuntap_user_info = { 211const struct net_user_info tuntap_user_info = {
@@ -215,14 +218,3 @@ const struct net_user_info tuntap_user_info = {
215 .delete_address = tuntap_del_addr, 218 .delete_address = tuntap_del_addr,
216 .max_packet = MAX_PACKET 219 .max_packet = MAX_PACKET
217}; 220};
218
219/*
220 * Overrides for Emacs so that we follow Linus's tabbing style.
221 * Emacs will notice this stuff at the end of the file and automatically
222 * adjust the settings for this buffer only. This must remain at the end
223 * of the file.
224 * ---------------------------------------------------------------------------
225 * Local variables:
226 * c-file-style: "linux"
227 * End:
228 */