some cleanups
Subsystems (4)
cover some cleanups
From: Zhi Yong Wu <[email protected]>
Since net-next is open now, it's time to post them out 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: update file current position
macvtap: remove unused paramter in macvtap_do_read()
drivers/net/macvtap.c | 16 +++++++--------- 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 +- 6 files changed, 13 insertions(+), 33 deletions(-)
Signature · 1 line
1.7.6.5
PATCH 1/6 vhost: remove the dead branch
From: 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 2/6 vhost: adjust vhost_dev_init() to be void
In reply to Zhi Yong WuFrom: 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 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
Re: [net-next PATCH 3/6] macvtap: remove the dead branch
Quoted 12 lines · Zhi Yong Wu
From: Zhi Yong Wu <[email protected]>
Signed-off-by Zhi Yong Wu <[email protected]>--- drivers/net/macvtap.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)drivers/net/macvtap.c +0
-0
drivers/net/macvtap.c static ssize_t macvtap_put_user(struct macvtap_queue *q, · line 782
Quoted 6 lines
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;
Assigning the function's return value to ret just to ignore it seems odd.
Might make sense to change the function type to void.
Guenter
Re: [net-next PATCH 3/6] macvtap: remove the dead branch
Quoted 17 lines · Guenter Roeck
Quoted 16 lines · Zhi Yong Wu
From: Zhi Yong Wu <[email protected]>
Signed-off-by Zhi Yong Wu <[email protected]>--- drivers/net/macvtap.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)drivers/net/macvtap.c +0
-0@@ -779,8 +779,6 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q, return -EINVAL ;
Quoted 7 lines
drivers/net/macvtap.c static ssize_t macvtap_put_user(struct macvtap_queue *q, · line 782
Quoted 4 lines
drivers/net/macvtap.c +0
-2ret =macvtap_skb_to_vnet_hdr (skb, &vnet_hdr); -if (ret) -return ret;Assigning the function's return value to ret just to ignore it seems odd.
Might make sense to change the function type to void.
Yes, this is done in the next patch of this series.
Quoted 3 lines
Guenter
Signature · 3 lines
Regards, Zhi Yong Wu
David Miller
maintainerRe: [net-next PATCH 3/6] macvtap: remove the dead branch
In reply to Guenter RoeckFrom: Guenter Roeck <[email protected]>
Date: Thu, 05 Dec 2013 22:08:20 -0800
Quoted 4 lines
Assigning the function's return value to ret just to ignore it seems odd.
Might make sense to change the function type to void.
That's exactly what his very next patch does, undoubtedly the two patches should be combined into one.
Re: [net-next PATCH 3/6] macvtap: remove the dead branch
Quoted 11 lines · David Miller
From: Guenter Roeck <[email protected]>
Date: Thu, 05 Dec 2013 22:08:20 -0800Quoted 4 lines
Assigning the function's return value to ret just to ignore it seems odd.
Might make sense to change the function type to void.
That's exactly what his very next patch does, undoubtedly the two patches should be combined into one.
Yes, I think that would be a good idea.
Thanks,
Guenter
PATCH 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 5/6 macvtap: update file current position
In reply to Zhi Yong WuFrom: Zhi Yong Wu <[email protected]>
--- drivers/net/macvtap.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/net/macvtap.c +2 -0
@@ -872,6 +872,8 @@ static ssize_t macvtap_aio_read(struct kiocb *iocb, const struct iovec *iv, ret =macvtap_do_read (q, iocb, iv, len, file->f_flags &O_NONBLOCK ); ret =min_t (ssize_t, ret, len);/* XXX copied from tun.c. Why? */ +if (ret >0 ) + iocb->ki_pos = ret; out:return ret; }
Signature · 1 line
1.7.6.5
PATCH 6/6 macvtap: remove unused paramter 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? */ if (ret >0 ) iocb->ki_pos = ret;
@@ -1104,7 +1104,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