diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-05-06 17:51:02 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-07 15:13:00 -0400 |
commit | 56bd194bb200ef0c49517de67a7d7f4b043b11b1 (patch) | |
tree | 2c180ee0e18e0e18b997a8a14d84505f0388f1c7 /arch | |
parent | b47d2debf229469c78af4145ee7ad35a0f21b67f (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')
-rw-r--r-- | arch/um/drivers/chan_user.c | 2 | ||||
-rw-r--r-- | arch/um/drivers/daemon_user.c | 25 | ||||
-rw-r--r-- | arch/um/drivers/mcast_user.c | 12 | ||||
-rw-r--r-- | arch/um/drivers/pcap_user.c | 33 | ||||
-rw-r--r-- | arch/um/drivers/ubd_user.c | 15 | ||||
-rw-r--r-- | arch/um/os-Linux/drivers/ethertap_user.c | 36 | ||||
-rw-r--r-- | arch/um/os-Linux/drivers/tuntap_user.c | 40 |
7 files changed, 57 insertions, 106 deletions
diff --git a/arch/um/drivers/chan_user.c b/arch/um/drivers/chan_user.c index 0cad3546cb89..77d3fdb0c21a 100644 --- a/arch/um/drivers/chan_user.c +++ b/arch/um/drivers/chan_user.c | |||
@@ -158,7 +158,7 @@ static int winch_tramp(int fd, struct tty_struct *tty, int *fd_out) | |||
158 | */ | 158 | */ |
159 | err = run_helper_thread(winch_thread, &data, CLONE_FILES, &stack, 0); | 159 | err = run_helper_thread(winch_thread, &data, CLONE_FILES, &stack, 0); |
160 | if(err < 0){ | 160 | if(err < 0){ |
161 | printk("fork of winch_thread failed - errno = %d\n", errno); | 161 | printk("fork of winch_thread failed - errno = %d\n", err); |
162 | goto out_close; | 162 | goto out_close; |
163 | } | 163 | } |
164 | 164 | ||
diff --git a/arch/um/drivers/daemon_user.c b/arch/um/drivers/daemon_user.c index 021b82c7a759..09d1de90297c 100644 --- a/arch/um/drivers/daemon_user.c +++ b/arch/um/drivers/daemon_user.c | |||
@@ -39,11 +39,11 @@ static struct sockaddr_un *new_addr(void *name, int len) | |||
39 | sun = um_kmalloc(sizeof(struct sockaddr_un)); | 39 | sun = um_kmalloc(sizeof(struct sockaddr_un)); |
40 | if(sun == NULL){ | 40 | if(sun == NULL){ |
41 | printk("new_addr: allocation of sockaddr_un failed\n"); | 41 | printk("new_addr: allocation of sockaddr_un failed\n"); |
42 | return(NULL); | 42 | return NULL; |
43 | } | 43 | } |
44 | sun->sun_family = AF_UNIX; | 44 | sun->sun_family = AF_UNIX; |
45 | memcpy(sun->sun_path, name, len); | 45 | memcpy(sun->sun_path, name, len); |
46 | return(sun); | 46 | return sun; |
47 | } | 47 | } |
48 | 48 | ||
49 | static int connect_to_switch(struct daemon_data *pri) | 49 | static int connect_to_switch(struct daemon_data *pri) |
@@ -112,7 +112,7 @@ static int connect_to_switch(struct daemon_data *pri) | |||
112 | } | 112 | } |
113 | 113 | ||
114 | pri->data_addr = sun; | 114 | pri->data_addr = sun; |
115 | return(fd); | 115 | return fd; |
116 | 116 | ||
117 | out_free: | 117 | out_free: |
118 | kfree(sun); | 118 | kfree(sun); |
@@ -120,7 +120,7 @@ static int connect_to_switch(struct daemon_data *pri) | |||
120 | os_close_file(fd); | 120 | os_close_file(fd); |
121 | out: | 121 | out: |
122 | os_close_file(pri->control); | 122 | os_close_file(pri->control); |
123 | return(err); | 123 | return err; |
124 | } | 124 | } |
125 | 125 | ||
126 | static void daemon_user_init(void *data, void *dev) | 126 | static void daemon_user_init(void *data, void *dev) |
@@ -152,7 +152,7 @@ static void daemon_user_init(void *data, void *dev) | |||
152 | static int daemon_open(void *data) | 152 | static int daemon_open(void *data) |
153 | { | 153 | { |
154 | struct daemon_data *pri = data; | 154 | struct daemon_data *pri = data; |
155 | return(pri->fd); | 155 | return pri->fd; |
156 | } | 156 | } |
157 | 157 | ||
158 | static void daemon_remove(void *data) | 158 | static void daemon_remove(void *data) |
@@ -176,12 +176,12 @@ int daemon_user_write(int fd, void *buf, int len, struct daemon_data *pri) | |||
176 | { | 176 | { |
177 | struct sockaddr_un *data_addr = pri->data_addr; | 177 | struct sockaddr_un *data_addr = pri->data_addr; |
178 | 178 | ||
179 | return(net_sendto(fd, buf, len, data_addr, sizeof(*data_addr))); | 179 | return net_sendto(fd, buf, len, data_addr, sizeof(*data_addr)); |
180 | } | 180 | } |
181 | 181 | ||
182 | static int daemon_set_mtu(int mtu, void *data) | 182 | static int daemon_set_mtu(int mtu, void *data) |
183 | { | 183 | { |
184 | return(mtu); | 184 | return mtu; |
185 | } | 185 | } |
186 | 186 | ||
187 | const struct net_user_info daemon_user_info = { | 187 | const struct net_user_info daemon_user_info = { |
@@ -194,14 +194,3 @@ const struct net_user_info daemon_user_info = { | |||
194 | .delete_address = NULL, | 194 | .delete_address = NULL, |
195 | .max_packet = MAX_PACKET - ETH_HEADER_OTHER | 195 | .max_packet = MAX_PACKET - ETH_HEADER_OTHER |
196 | }; | 196 | }; |
197 | |||
198 | /* | ||
199 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
200 | * Emacs will notice this stuff at the end of the file and automatically | ||
201 | * adjust the settings for this buffer only. This must remain at the end | ||
202 | * of the file. | ||
203 | * --------------------------------------------------------------------------- | ||
204 | * Local variables: | ||
205 | * c-file-style: "linux" | ||
206 | * End: | ||
207 | */ | ||
diff --git a/arch/um/drivers/mcast_user.c b/arch/um/drivers/mcast_user.c index b827e82884c9..cfaa2cc43139 100644 --- a/arch/um/drivers/mcast_user.c +++ b/arch/um/drivers/mcast_user.c | |||
@@ -34,12 +34,12 @@ static struct sockaddr_in *new_addr(char *addr, unsigned short port) | |||
34 | sin = um_kmalloc(sizeof(struct sockaddr_in)); | 34 | sin = um_kmalloc(sizeof(struct sockaddr_in)); |
35 | if(sin == NULL){ | 35 | if(sin == NULL){ |
36 | printk("new_addr: allocation of sockaddr_in failed\n"); | 36 | printk("new_addr: allocation of sockaddr_in failed\n"); |
37 | return(NULL); | 37 | return NULL; |
38 | } | 38 | } |
39 | sin->sin_family = AF_INET; | 39 | sin->sin_family = AF_INET; |
40 | sin->sin_addr.s_addr = in_aton(addr); | 40 | sin->sin_addr.s_addr = in_aton(addr); |
41 | sin->sin_port = htons(port); | 41 | sin->sin_port = htons(port); |
42 | return(sin); | 42 | return sin; |
43 | } | 43 | } |
44 | 44 | ||
45 | static void mcast_user_init(void *data, void *dev) | 45 | static void mcast_user_init(void *data, void *dev) |
@@ -107,8 +107,8 @@ static int mcast_open(void *data) | |||
107 | err = -errno; | 107 | err = -errno; |
108 | printk("mcast_open : data bind failed, errno = %d\n", errno); | 108 | printk("mcast_open : data bind failed, errno = %d\n", errno); |
109 | goto out_close; | 109 | goto out_close; |
110 | } | 110 | } |
111 | 111 | ||
112 | /* subscribe to the multicast group */ | 112 | /* subscribe to the multicast group */ |
113 | mreq.imr_multiaddr.s_addr = sin->sin_addr.s_addr; | 113 | mreq.imr_multiaddr.s_addr = sin->sin_addr.s_addr; |
114 | mreq.imr_interface.s_addr = 0; | 114 | mreq.imr_interface.s_addr = 0; |
@@ -153,12 +153,12 @@ int mcast_user_write(int fd, void *buf, int len, struct mcast_data *pri) | |||
153 | { | 153 | { |
154 | struct sockaddr_in *data_addr = pri->mcast_addr; | 154 | struct sockaddr_in *data_addr = pri->mcast_addr; |
155 | 155 | ||
156 | return(net_sendto(fd, buf, len, data_addr, sizeof(*data_addr))); | 156 | return net_sendto(fd, buf, len, data_addr, sizeof(*data_addr)); |
157 | } | 157 | } |
158 | 158 | ||
159 | static int mcast_set_mtu(int mtu, void *data) | 159 | static int mcast_set_mtu(int mtu, void *data) |
160 | { | 160 | { |
161 | return(mtu); | 161 | return mtu; |
162 | } | 162 | } |
163 | 163 | ||
164 | const struct net_user_info mcast_user_info = { | 164 | const struct net_user_info mcast_user_info = { |
diff --git a/arch/um/drivers/pcap_user.c b/arch/um/drivers/pcap_user.c index 11921a7baa7b..a1747dc0ff6f 100644 --- a/arch/um/drivers/pcap_user.c +++ b/arch/um/drivers/pcap_user.c | |||
@@ -42,39 +42,39 @@ static int pcap_open(void *data) | |||
42 | int err; | 42 | int err; |
43 | 43 | ||
44 | if(pri->pcap == NULL) | 44 | if(pri->pcap == NULL) |
45 | return(-ENODEV); | 45 | return -ENODEV; |
46 | 46 | ||
47 | if(pri->filter != NULL){ | 47 | if(pri->filter != NULL){ |
48 | err = dev_netmask(pri->dev, &netmask); | 48 | err = dev_netmask(pri->dev, &netmask); |
49 | if(err < 0){ | 49 | if(err < 0){ |
50 | printk("pcap_open : dev_netmask failed\n"); | 50 | printk("pcap_open : dev_netmask failed\n"); |
51 | return(-EIO); | 51 | return -EIO; |
52 | } | 52 | } |
53 | 53 | ||
54 | pri->compiled = um_kmalloc(sizeof(struct bpf_program)); | 54 | pri->compiled = um_kmalloc(sizeof(struct bpf_program)); |
55 | if(pri->compiled == NULL){ | 55 | if(pri->compiled == NULL){ |
56 | printk("pcap_open : kmalloc failed\n"); | 56 | printk("pcap_open : kmalloc failed\n"); |
57 | return(-ENOMEM); | 57 | return -ENOMEM; |
58 | } | 58 | } |
59 | 59 | ||
60 | err = pcap_compile(pri->pcap, | 60 | err = pcap_compile(pri->pcap, |
61 | (struct bpf_program *) pri->compiled, | 61 | (struct bpf_program *) pri->compiled, |
62 | pri->filter, pri->optimize, netmask); | 62 | pri->filter, pri->optimize, netmask); |
63 | if(err < 0){ | 63 | if(err < 0){ |
64 | printk("pcap_open : pcap_compile failed - '%s'\n", | 64 | printk("pcap_open : pcap_compile failed - '%s'\n", |
65 | pcap_geterr(pri->pcap)); | 65 | pcap_geterr(pri->pcap)); |
66 | return(-EIO); | 66 | return -EIO; |
67 | } | 67 | } |
68 | 68 | ||
69 | err = pcap_setfilter(pri->pcap, pri->compiled); | 69 | err = pcap_setfilter(pri->pcap, pri->compiled); |
70 | if(err < 0){ | 70 | if(err < 0){ |
71 | printk("pcap_open : pcap_setfilter failed - '%s'\n", | 71 | printk("pcap_open : pcap_setfilter failed - '%s'\n", |
72 | pcap_geterr(pri->pcap)); | 72 | pcap_geterr(pri->pcap)); |
73 | return(-EIO); | 73 | return -EIO; |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | return(PCAP_FD(pri->pcap)); | 77 | return PCAP_FD(pri->pcap); |
78 | } | 78 | } |
79 | 79 | ||
80 | static void pcap_remove(void *data) | 80 | static void pcap_remove(void *data) |
@@ -114,11 +114,11 @@ int pcap_user_read(int fd, void *buffer, int len, struct pcap_data *pri) | |||
114 | n = pcap_dispatch(pri->pcap, 1, handler, (u_char *) &hdata); | 114 | n = pcap_dispatch(pri->pcap, 1, handler, (u_char *) &hdata); |
115 | if(n < 0){ | 115 | if(n < 0){ |
116 | printk("pcap_dispatch failed - %s\n", pcap_geterr(pri->pcap)); | 116 | printk("pcap_dispatch failed - %s\n", pcap_geterr(pri->pcap)); |
117 | return(-EIO); | 117 | return -EIO; |
118 | } | 118 | } |
119 | else if(n == 0) | 119 | else if(n == 0) |
120 | return(0); | 120 | return 0; |
121 | return(hdata.len); | 121 | return hdata.len; |
122 | } | 122 | } |
123 | 123 | ||
124 | const struct net_user_info pcap_user_info = { | 124 | const struct net_user_info pcap_user_info = { |
@@ -131,14 +131,3 @@ const struct net_user_info pcap_user_info = { | |||
131 | .delete_address = NULL, | 131 | .delete_address = NULL, |
132 | .max_packet = MAX_PACKET - ETH_HEADER_OTHER | 132 | .max_packet = MAX_PACKET - ETH_HEADER_OTHER |
133 | }; | 133 | }; |
134 | |||
135 | /* | ||
136 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
137 | * Emacs will notice this stuff at the end of the file and automatically | ||
138 | * adjust the settings for this buffer only. This must remain at the end | ||
139 | * of the file. | ||
140 | * --------------------------------------------------------------------------- | ||
141 | * Local variables: | ||
142 | * c-file-style: "linux" | ||
143 | * End: | ||
144 | */ | ||
diff --git a/arch/um/drivers/ubd_user.c b/arch/um/drivers/ubd_user.c index b94d2bc4fe06..039572cbedfe 100644 --- a/arch/um/drivers/ubd_user.c +++ b/arch/um/drivers/ubd_user.c | |||
@@ -47,8 +47,8 @@ int start_io_thread(unsigned long sp, int *fd_out) | |||
47 | pid = clone(io_thread, (void *) sp, CLONE_FILES | CLONE_VM | SIGCHLD, | 47 | pid = clone(io_thread, (void *) sp, CLONE_FILES | CLONE_VM | SIGCHLD, |
48 | NULL); | 48 | NULL); |
49 | if(pid < 0){ | 49 | if(pid < 0){ |
50 | printk("start_io_thread - clone failed : errno = %d\n", errno); | ||
51 | err = -errno; | 50 | err = -errno; |
51 | printk("start_io_thread - clone failed : errno = %d\n", errno); | ||
52 | goto out_close; | 52 | goto out_close; |
53 | } | 53 | } |
54 | 54 | ||
@@ -60,16 +60,5 @@ int start_io_thread(unsigned long sp, int *fd_out) | |||
60 | kernel_fd = -1; | 60 | kernel_fd = -1; |
61 | *fd_out = -1; | 61 | *fd_out = -1; |
62 | out: | 62 | out: |
63 | return(err); | 63 | return err; |
64 | } | 64 | } |
65 | |||
66 | /* | ||
67 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
68 | * Emacs will notice this stuff at the end of the file and automatically | ||
69 | * adjust the settings for this buffer only. This must remain at the end | ||
70 | * of the file. | ||
71 | * --------------------------------------------------------------------------- | ||
72 | * Local variables: | ||
73 | * c-file-style: "linux" | ||
74 | * End: | ||
75 | */ | ||
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 | ||
138 | static int etap_open(void *data) | 138 | static 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 | ||
183 | static void etap_close(int fd, void *data) | 184 | static void etap_close(int fd, void *data) |
@@ -195,7 +196,7 @@ static void etap_close(int fd, void *data) | |||
195 | 196 | ||
196 | static int etap_set_mtu(int mtu, void *data) | 197 | static int etap_set_mtu(int mtu, void *data) |
197 | { | 198 | { |
198 | return(mtu); | 199 | return mtu; |
199 | } | 200 | } |
200 | 201 | ||
201 | static void etap_add_addr(unsigned char *addr, unsigned char *netmask, | 202 | static 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 { | |||
58 | static void tuntap_pre_exec(void *arg) | 60 | static 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 | ||
129 | static int tuntap_open(void *data) | 132 | static 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 | ||
193 | static void tuntap_close(int fd, void *data) | 196 | static void tuntap_close(int fd, void *data) |
@@ -202,7 +205,7 @@ static void tuntap_close(int fd, void *data) | |||
202 | 205 | ||
203 | static int tuntap_set_mtu(int mtu, void *data) | 206 | static int tuntap_set_mtu(int mtu, void *data) |
204 | { | 207 | { |
205 | return(mtu); | 208 | return mtu; |
206 | } | 209 | } |
207 | 210 | ||
208 | const struct net_user_info tuntap_user_info = { | 211 | const 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 | */ | ||