net: some cleanups
Subsystems (5)
v3 cover net: some cleanups
From: Zhi Yong Wu <[email protected]>
Since net-next is open now, it's time to post them again.
Zhi Yong Wu (6):
vhost: remove the dead branch
vhost: adjust vhost_dev_init() to be void
macvtap: remove the dead branch
macvtap: adjust macvtap_skb_to_vnet_hdr() to be void
macvtap: remove unused parameter in macvtap_do_read()
tun: remove unused parameter in tun_do_read()
drivers/net/macvtap.c | 14 +++++--------- drivers/net/tun.c | 7 +++---- drivers/vhost/net.c | 9 ++------- drivers/vhost/scsi.c | 7 +------ drivers/vhost/test.c | 8 +------- drivers/vhost/vhost.c | 4 +--- drivers/vhost/vhost.h | 2 +- 7 files changed, 14 insertions(+), 37 deletions(-)
Signature · 1 line
1.7.6.5
PATCH v3 2/6 vhost: adjust vhost_dev_init() to be void
From: Zhi Yong Wu <[email protected]>
--- drivers/vhost/net.c | 4 ++-- drivers/vhost/scsi.c | 2 +- drivers/vhost/test.c | 3 +-- drivers/vhost/vhost.c | 4 +--- drivers/vhost/vhost.h | 2 +- 5 files changed, 6 insertions(+), 9 deletions(-)
drivers/vhost/net.c +2 -2
@@ -683,7 +683,7 @@ static int vhost_net_open(struct inode *inode, struct file *f)struct vhost_net *n =kmalloc (sizeof *n,GFP_KERNEL );struct vhost_dev *dev;struct vhost_virtqueue **vqs; -int r, i; +int i;if (!n)return -ENOMEM ;
@@ -706,7 +706,7 @@ static int vhost_net_open(struct inode *inode, struct file *f) n->vqs[i].vhost_hlen =0 ; n->vqs[i].sock_hlen =0 ; } - r =vhost_dev_init (dev, vqs,VHOST_NET_VQ_MAX ); +vhost_dev_init (dev, vqs,VHOST_NET_VQ_MAX );vhost_poll_init (n->poll +VHOST_NET_VQ_TX , handle_tx_net,POLLOUT , dev);vhost_poll_init (n->poll +VHOST_NET_VQ_RX , handle_rx_net,POLLIN , dev);
drivers/vhost/scsi.c +1 -1
@@ -1417,7 +1417,7 @@ static int vhost_scsi_open(struct inode *inode, struct file *f) vqs[i] = &vs->vqs[i].vq; vs->vqs[i].vq.handle_kick = vhost_scsi_handle_kick; } - r =vhost_dev_init (&vs->dev, vqs,VHOST_SCSI_MAX_VQ ); +vhost_dev_init (&vs->dev, vqs,VHOST_SCSI_MAX_VQ );tcm_vhost_init_inflight (vs,NULL );
drivers/vhost/test.c +1 -2
@@ -104,7 +104,6 @@ static int vhost_test_open(struct inode *inode, struct file *f)struct vhost_test *n =kmalloc (sizeof *n,GFP_KERNEL );struct vhost_dev *dev;struct vhost_virtqueue **vqs; -int r;if (!n)return -ENOMEM ;
@@ -117,7 +116,7 @@ static int vhost_test_open(struct inode *inode, struct file *f) dev = &n->dev; vqs[VHOST_TEST_VQ ] = &n->vqs[VHOST_TEST_VQ ]; n->vqs[VHOST_TEST_VQ ].handle_kick = handle_vq_kick; - r =vhost_dev_init (dev, vqs,VHOST_TEST_VQ_MAX ); +vhost_dev_init (dev, vqs,VHOST_TEST_VQ_MAX ); f->private_data = n;
drivers/vhost/vhost.c +1 -3
@@ -290,7 +290,7 @@ static void vhost_dev_free_iovecs(struct vhost_dev *dev)vhost_vq_free_iovecs (dev->vqs[i]); } -long vhost_dev_init (struct vhost_dev *dev, +void vhost_dev_init (struct vhost_dev *dev,struct vhost_virtqueue **vqs,int nvqs) {struct vhost_virtqueue *vq;
@@ -319,8 +319,6 @@ long vhost_dev_init(struct vhost_dev *dev,vhost_poll_init (&vq->poll, vq->handle_kick,POLLIN , dev); } - -return 0 ; }EXPORT_SYMBOL_GPL (vhost_dev_init);
drivers/vhost/vhost.h +1 -1
@@ -127,7 +127,7 @@ struct vhost_dev {struct task_struct *worker; }; -long vhost_dev_init (struct vhost_dev *,struct vhost_virtqueue **vqs,int nvqs); +void vhost_dev_init (struct vhost_dev *,struct vhost_virtqueue **vqs,int nvqs);long vhost_dev_set_owner (struct vhost_dev *dev);bool vhost_dev_has_owner (struct vhost_dev *dev);long vhost_dev_check_owner (struct vhost_dev *);
Signature · 1 line
1.7.6.5
PATCH v3 3/6 macvtap: remove the dead branch
In reply to Zhi Yong WuFrom: Zhi Yong Wu <[email protected]>
--- drivers/net/macvtap.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/net/macvtap.c +0 -2
@@ -779,8 +779,6 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,return -EINVAL ; ret =macvtap_skb_to_vnet_hdr (skb, &vnet_hdr); -if (ret) -return ret;if (memcpy_toiovecend (iv, (void *)&vnet_hdr,0 ,sizeof (vnet_hdr)))return -EFAULT ;
Signature · 1 line
1.7.6.5
PATCH v3 4/6 macvtap: adjust macvtap_skb_to_vnet_hdr() to be void
In reply to Zhi Yong WuFrom: Zhi Yong Wu <[email protected]>
--- drivers/net/macvtap.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/net/macvtap.c +2 -4
@@ -588,7 +588,7 @@ static int macvtap_skb_from_vnet_hdr(struct sk_buff *skb,return 0 ; } -static int macvtap_skb_to_vnet_hdr (const struct sk_buff *skb, +static void macvtap_skb_to_vnet_hdr (const struct sk_buff *skb,struct virtio_net_hdr *vnet_hdr) {memset (vnet_hdr,0 ,sizeof (*vnet_hdr));
@@ -619,8 +619,6 @@ static int macvtap_skb_to_vnet_hdr(const struct sk_buff *skb, }else if (skb->ip_summed ==CHECKSUM_UNNECESSARY ) { vnet_hdr->flags =VIRTIO_NET_HDR_F_DATA_VALID ; }/* else everything is zero */ - -return 0 ; }/* Get packet from user space buffer */
@@ -778,7 +776,7 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,if ((len -= vnet_hdr_len) <0 )return -EINVAL ; - ret =macvtap_skb_to_vnet_hdr (skb, &vnet_hdr); +macvtap_skb_to_vnet_hdr (skb, &vnet_hdr);if (memcpy_toiovecend (iv, (void *)&vnet_hdr,0 ,sizeof (vnet_hdr)))return -EFAULT ;
Signature · 1 line
1.7.6.5
PATCH v3 5/6 macvtap: remove unused parameter in macvtap_do_read()
In reply to Zhi Yong WuFrom: Zhi Yong Wu <[email protected]>
--- drivers/net/macvtap.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/macvtap.c +3 -3
@@ -819,7 +819,7 @@ done:return ret ? ret : copied; } -static ssize_t macvtap_do_read (struct macvtap_queue *q,struct kiocb *iocb, +static ssize_t macvtap_do_read (struct macvtap_queue *q,const struct iovec *iv,unsigned long len,int noblock) {
@@ -870,7 +870,7 @@ static ssize_t macvtap_aio_read(struct kiocb *iocb, const struct iovec *iv, goto out; } - ret =macvtap_do_read (q, iocb, iv, len, file->f_flags &O_NONBLOCK ); + ret =macvtap_do_read (q, iv, len, file->f_flags &O_NONBLOCK ); ret =min_t (ssize_t, ret, len);/* XXX copied from tun.c. Why? */ out:return ret;
@@ -1102,7 +1102,7 @@ static int macvtap_recvmsg(struct kiocb *iocb, struct socket *sock,int ret;if (flags & ~(MSG_DONTWAIT |MSG_TRUNC ))return -EINVAL ; - ret =macvtap_do_read (q, iocb, m->msg_iov, total_len, + ret =macvtap_do_read (q, m->msg_iov, total_len, flags &MSG_DONTWAIT );if (ret > total_len) { m->msg_flags |=MSG_TRUNC ;
Signature · 1 line
1.7.6.5
PATCH v3 1/6 vhost: remove the dead branch
In reply to Zhi Yong WuFrom: Zhi Yong Wu <[email protected]>
Since vhost_dev_init() forever return 0, some branches are never run, therefore need to be removed.
--- drivers/vhost/net.c | 5 ----- drivers/vhost/scsi.c | 5 ----- drivers/vhost/test.c | 5 ----- 3 files changed, 0 insertions(+), 15 deletions(-)
drivers/vhost/net.c +0 -5
@@ -707,11 +707,6 @@ static int vhost_net_open(struct inode *inode, struct file *f) n->vqs[i].sock_hlen =0 ; } r =vhost_dev_init (dev, vqs,VHOST_NET_VQ_MAX ); -if (r <0 ) { -kfree (n); -kfree (vqs); -return r; - }vhost_poll_init (n->poll +VHOST_NET_VQ_TX , handle_tx_net,POLLOUT , dev);vhost_poll_init (n->poll +VHOST_NET_VQ_RX , handle_rx_net,POLLIN , dev);
drivers/vhost/scsi.c +0 -5
@@ -1421,14 +1421,9 @@ static int vhost_scsi_open(struct inode *inode, struct file *f)tcm_vhost_init_inflight (vs,NULL ); -if (r <0 ) - goto err_init; - f->private_data = vs;return 0 ; -err_init: -kfree (vqs); err_vqs:vhost_scsi_free (vs); err_vs:
drivers/vhost/test.c +0 -5
@@ -118,11 +118,6 @@ static int vhost_test_open(struct inode *inode, struct file *f) vqs[VHOST_TEST_VQ ] = &n->vqs[VHOST_TEST_VQ ]; n->vqs[VHOST_TEST_VQ ].handle_kick = handle_vq_kick; r =vhost_dev_init (dev, vqs,VHOST_TEST_VQ_MAX ); -if (r <0 ) { -kfree (vqs); -kfree (n); -return r; - } f->private_data = n;
Signature · 1 line
1.7.6.5
PATCH v3 6/6 tun: remove unused parameter in tun_do_read()
In reply to Zhi Yong WuFrom: Zhi Yong Wu <[email protected]>
--- drivers/net/tun.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
drivers/net/tun.c +3 -4
@@ -1289,8 +1289,7 @@ done: }static ssize_t tun_do_read (struct tun_struct *tun,struct tun_file *tfile, -struct kiocb *iocb,const struct iovec *iv, -ssize_t len,int noblock) +const struct iovec *iv,ssize_t len,int noblock) {DECLARE_WAITQUEUE (wait, current);struct sk_buff *skb;
@@ -1353,7 +1352,7 @@ static ssize_t tun_chr_aio_read(struct kiocb *iocb, const struct iovec *iv, goto out; } - ret =tun_do_read (tun, tfile, iocb, iv, len, + ret =tun_do_read (tun, tfile, iv, len, file->f_flags &O_NONBLOCK ); ret =min_t (ssize_t, ret, len); out:
@@ -1452,7 +1451,7 @@ static int tun_recvmsg(struct kiocb *iocb, struct socket *sock, SOL_PACKET, TUN_TX_TIMESTAMP); goto out; } - ret =tun_do_read (tun, tfile, iocb, m->msg_iov, total_len, + ret =tun_do_read (tun, tfile, m->msg_iov, total_len, flags &MSG_DONTWAIT );if (ret > total_len) { m->msg_flags |=MSG_TRUNC ;
Signature · 1 line
1.7.6.5
David Miller
maintainerRe: [net-next PATCH v3 4/6] macvtap: adjust macvtap_skb_to_vnet_hdr() to be void
In reply to Zhi Yong WuFrom: Zhi Yong Wu <[email protected]>
Date: Fri, 6 Dec 2013 14:19:40 +0800
Quoted 3 lines
From: Zhi Yong Wu <[email protected]>
Signed-off-by Zhi Yong Wu <[email protected]>
As mentioned elsewhere, please combine the change that removes the return value check with the change which adjusts the function return type to "void".
Thank you.