Skip to content

Commit

Permalink
uml: driver formatting fixes
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff Dike authored and Linus Torvalds committed May 7, 2007
1 parent b47d2de commit 56bd194
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 106 deletions.
2 changes: 1 addition & 1 deletion arch/um/drivers/chan_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static int winch_tramp(int fd, struct tty_struct *tty, int *fd_out)
*/
err = run_helper_thread(winch_thread, &data, CLONE_FILES, &stack, 0);
if(err < 0){
printk("fork of winch_thread failed - errno = %d\n", errno);
printk("fork of winch_thread failed - errno = %d\n", err);
goto out_close;
}

Expand Down
25 changes: 7 additions & 18 deletions arch/um/drivers/daemon_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ static struct sockaddr_un *new_addr(void *name, int len)
sun = um_kmalloc(sizeof(struct sockaddr_un));
if(sun == NULL){
printk("new_addr: allocation of sockaddr_un failed\n");
return(NULL);
return NULL;
}
sun->sun_family = AF_UNIX;
memcpy(sun->sun_path, name, len);
return(sun);
return sun;
}

static int connect_to_switch(struct daemon_data *pri)
Expand Down Expand Up @@ -112,15 +112,15 @@ static int connect_to_switch(struct daemon_data *pri)
}

pri->data_addr = sun;
return(fd);
return fd;

out_free:
kfree(sun);
out_close:
os_close_file(fd);
out:
os_close_file(pri->control);
return(err);
return err;
}

static void daemon_user_init(void *data, void *dev)
Expand Down Expand Up @@ -152,7 +152,7 @@ static void daemon_user_init(void *data, void *dev)
static int daemon_open(void *data)
{
struct daemon_data *pri = data;
return(pri->fd);
return pri->fd;
}

static void daemon_remove(void *data)
Expand All @@ -176,12 +176,12 @@ int daemon_user_write(int fd, void *buf, int len, struct daemon_data *pri)
{
struct sockaddr_un *data_addr = pri->data_addr;

return(net_sendto(fd, buf, len, data_addr, sizeof(*data_addr)));
return net_sendto(fd, buf, len, data_addr, sizeof(*data_addr));
}

static int daemon_set_mtu(int mtu, void *data)
{
return(mtu);
return mtu;
}

const struct net_user_info daemon_user_info = {
Expand All @@ -194,14 +194,3 @@ const struct net_user_info daemon_user_info = {
.delete_address = NULL,
.max_packet = MAX_PACKET - ETH_HEADER_OTHER
};

/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically
* adjust the settings for this buffer only. This must remain at the end
* of the file.
* ---------------------------------------------------------------------------
* Local variables:
* c-file-style: "linux"
* End:
*/
12 changes: 6 additions & 6 deletions arch/um/drivers/mcast_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ static struct sockaddr_in *new_addr(char *addr, unsigned short port)
sin = um_kmalloc(sizeof(struct sockaddr_in));
if(sin == NULL){
printk("new_addr: allocation of sockaddr_in failed\n");
return(NULL);
return NULL;
}
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = in_aton(addr);
sin->sin_port = htons(port);
return(sin);
return sin;
}

static void mcast_user_init(void *data, void *dev)
Expand Down Expand Up @@ -107,8 +107,8 @@ static int mcast_open(void *data)
err = -errno;
printk("mcast_open : data bind failed, errno = %d\n", errno);
goto out_close;
}
}

/* subscribe to the multicast group */
mreq.imr_multiaddr.s_addr = sin->sin_addr.s_addr;
mreq.imr_interface.s_addr = 0;
Expand Down Expand Up @@ -153,12 +153,12 @@ int mcast_user_write(int fd, void *buf, int len, struct mcast_data *pri)
{
struct sockaddr_in *data_addr = pri->mcast_addr;

return(net_sendto(fd, buf, len, data_addr, sizeof(*data_addr)));
return net_sendto(fd, buf, len, data_addr, sizeof(*data_addr));
}

static int mcast_set_mtu(int mtu, void *data)
{
return(mtu);
return mtu;
}

const struct net_user_info mcast_user_info = {
Expand Down
33 changes: 11 additions & 22 deletions arch/um/drivers/pcap_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,39 +42,39 @@ static int pcap_open(void *data)
int err;

if(pri->pcap == NULL)
return(-ENODEV);
return -ENODEV;

if(pri->filter != NULL){
err = dev_netmask(pri->dev, &netmask);
if(err < 0){
printk("pcap_open : dev_netmask failed\n");
return(-EIO);
return -EIO;
}

pri->compiled = um_kmalloc(sizeof(struct bpf_program));
if(pri->compiled == NULL){
printk("pcap_open : kmalloc failed\n");
return(-ENOMEM);
return -ENOMEM;
}

err = pcap_compile(pri->pcap,
(struct bpf_program *) pri->compiled,
pri->filter, pri->optimize, netmask);
if(err < 0){
printk("pcap_open : pcap_compile failed - '%s'\n",
pcap_geterr(pri->pcap));
return(-EIO);
return -EIO;
}

err = pcap_setfilter(pri->pcap, pri->compiled);
if(err < 0){
printk("pcap_open : pcap_setfilter failed - '%s'\n",
pcap_geterr(pri->pcap));
return(-EIO);
return -EIO;
}
}
return(PCAP_FD(pri->pcap));

return PCAP_FD(pri->pcap);
}

static void pcap_remove(void *data)
Expand Down Expand Up @@ -114,11 +114,11 @@ int pcap_user_read(int fd, void *buffer, int len, struct pcap_data *pri)
n = pcap_dispatch(pri->pcap, 1, handler, (u_char *) &hdata);
if(n < 0){
printk("pcap_dispatch failed - %s\n", pcap_geterr(pri->pcap));
return(-EIO);
return -EIO;
}
else if(n == 0)
return(0);
return(hdata.len);
return 0;
return hdata.len;
}

const struct net_user_info pcap_user_info = {
Expand All @@ -131,14 +131,3 @@ const struct net_user_info pcap_user_info = {
.delete_address = NULL,
.max_packet = MAX_PACKET - ETH_HEADER_OTHER
};

/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically
* adjust the settings for this buffer only. This must remain at the end
* of the file.
* ---------------------------------------------------------------------------
* Local variables:
* c-file-style: "linux"
* End:
*/
15 changes: 2 additions & 13 deletions arch/um/drivers/ubd_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ int start_io_thread(unsigned long sp, int *fd_out)
pid = clone(io_thread, (void *) sp, CLONE_FILES | CLONE_VM | SIGCHLD,
NULL);
if(pid < 0){
printk("start_io_thread - clone failed : errno = %d\n", errno);
err = -errno;
printk("start_io_thread - clone failed : errno = %d\n", errno);
goto out_close;
}

Expand All @@ -60,16 +60,5 @@ int start_io_thread(unsigned long sp, int *fd_out)
kernel_fd = -1;
*fd_out = -1;
out:
return(err);
return err;
}

/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically
* adjust the settings for this buffer only. This must remain at the end
* of the file.
* ---------------------------------------------------------------------------
* Local variables:
* c-file-style: "linux"
* End:
*/
36 changes: 14 additions & 22 deletions arch/um/os-Linux/drivers/ethertap_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static int etap_tramp(char *dev, char *gate, int control_me,
n = os_read_file(control_me, &c, sizeof(c));
if(n != sizeof(c)){
printk("etap_tramp : read of status failed, err = %d\n", -n);
return(-EINVAL);
return -EINVAL;
}
if(c != 1){
printk("etap_tramp : uml_net failed\n");
Expand All @@ -132,7 +132,7 @@ static int etap_tramp(char *dev, char *gate, int control_me,
else if(!WIFEXITED(status) || (WEXITSTATUS(status) != 1))
printk("uml_net didn't exit with status 1\n");
}
return(err);
return err;
}

static int etap_open(void *data)
Expand All @@ -142,20 +142,21 @@ static int etap_open(void *data)
int data_fds[2], control_fds[2], err, output_len;

err = tap_open_common(pri->dev, pri->gate_addr);
if(err) return(err);
if(err)
return err;

err = os_pipe(data_fds, 0, 0);
if(err < 0){
printk("data os_pipe failed - err = %d\n", -err);
return(err);
return err;
}

err = os_pipe(control_fds, 1, 0);
if(err < 0){
printk("control os_pipe failed - err = %d\n", -err);
return(err);
return err;
}

err = etap_tramp(pri->dev_name, pri->gate_addr, control_fds[0],
control_fds[1], data_fds[0], data_fds[1]);
output_len = page_size();
Expand All @@ -171,13 +172,13 @@ static int etap_open(void *data)

if(err < 0){
printk("etap_tramp failed - err = %d\n", -err);
return(err);
return err;
}

pri->data_fd = data_fds[0];
pri->control_fd = control_fds[0];
iter_addresses(pri->dev, etap_open_addr, &pri->control_fd);
return(data_fds[0]);
return data_fds[0];
}

static void etap_close(int fd, void *data)
Expand All @@ -195,7 +196,7 @@ static void etap_close(int fd, void *data)

static int etap_set_mtu(int mtu, void *data)
{
return(mtu);
return mtu;
}

static void etap_add_addr(unsigned char *addr, unsigned char *netmask,
Expand All @@ -204,7 +205,8 @@ static void etap_add_addr(unsigned char *addr, unsigned char *netmask,
struct ethertap_data *pri = data;

tap_check_ips(pri->gate_addr, addr);
if(pri->control_fd == -1) return;
if(pri->control_fd == -1)
return;
etap_open_addr(addr, netmask, &pri->control_fd);
}

Expand All @@ -213,7 +215,8 @@ static void etap_del_addr(unsigned char *addr, unsigned char *netmask,
{
struct ethertap_data *pri = data;

if(pri->control_fd == -1) return;
if(pri->control_fd == -1)
return;
etap_close_addr(addr, netmask, &pri->control_fd);
}

Expand All @@ -227,14 +230,3 @@ const struct net_user_info ethertap_user_info = {
.delete_address = etap_del_addr,
.max_packet = MAX_PACKET - ETH_HEADER_ETHERTAP
};

/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically
* adjust the settings for this buffer only. This must remain at the end
* of the file.
* ---------------------------------------------------------------------------
* Local variables:
* c-file-style: "linux"
* End:
*/
Loading

0 comments on commit 56bd194

Please sign in to comment.