vhost: remove the dead branch
authorZhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Fri, 6 Dec 2013 20:13:03 +0000 (04:13 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 6 Dec 2013 20:22:05 +0000 (15:22 -0500)
Since vhost_dev_init() forever return 0, some branches are never run,
therefore need to be removed.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/vhost/net.c
drivers/vhost/scsi.c
drivers/vhost/test.c
drivers/vhost/vhost.c
drivers/vhost/vhost.h

index 831eb4fd197d4867f607a42b4ed76541159099ba..9a68409580d5b76d8d3972e42a33314dc22f16f8 100644 (file)
@@ -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,12 +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);
-       if (r < 0) {
-               kfree(n);
-               kfree(vqs);
-               return r;
-       }
+       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);
index f175629513ed3dc0f5ad30eb3d8510506a894e1b..1e4c75c5b36bd3c9a394c755c39a291a0d2b831d 100644 (file)
@@ -1417,18 +1417,13 @@ 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);
 
-       if (r < 0)
-               goto err_init;
-
        f->private_data = vs;
        return 0;
 
-err_init:
-       kfree(vqs);
 err_vqs:
        vhost_scsi_free(vs);
 err_vs:
index 339eae85859a58afbd6ea563b4b9fae3f667100c..c2a54fbf7f996e9065702a5aab1d284447c9785b 100644 (file)
@@ -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,12 +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);
-       if (r < 0) {
-               kfree(vqs);
-               kfree(n);
-               return r;
-       }
+       vhost_dev_init(dev, vqs, VHOST_TEST_VQ_MAX);
 
        f->private_data = n;
 
index 69068e0d8f31af183c075afe3026d60b09a0b55e..78987e481bc6a3e578f1ea5789802ae9b1ae7045 100644 (file)
@@ -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);
 
index 4465ed5f316d6e9b36e1f43c05df1c980aa908ae..35eeb2a1badaf8e90e2af8215ff376b23a2e9853 100644 (file)
@@ -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 *);