vfio/mdev: remove unnecessary NULL check in mbochs_create()
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 29 Apr 2021 09:53:27 +0000 (12:53 +0300)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 4 May 2021 15:56:02 +0000 (09:56 -0600)
Originally "type" could be NULL and these checks were required, but we
recently changed how "type" is assigned and that's no longer the case.
Now "type" points to an element in the middle of a non-NULL array.

Removing the checks does not affect runtime at all, but it makes the
code a little bit simpler to read.

Fixes: 3d3a360e570616 ("vfio/mbochs: Use mdev_get_type_group_id()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Message-Id: <20210429095327.GY1981@kadam>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
samples/vfio-mdev/mbochs.c
samples/vfio-mdev/mdpy.c

index 861c76914e7639f7228dd978e6a687b77260f6e1..881ef9a7296f23ee6a26bc2bbd0f6f207c101b5a 100644 (file)
@@ -513,8 +513,6 @@ static int mbochs_create(struct mdev_device *mdev)
        struct device *dev = mdev_dev(mdev);
        struct mdev_state *mdev_state;
 
-       if (!type)
-               type = &mbochs_types[0];
        if (type->mbytes + mbochs_used_mbytes > max_mbytes)
                return -ENOMEM;
 
index f0c0e7209719a3749d6f816e7e69870217eb5382..e889c1cf8fd1cd7f9d726368a60a02f76fbc2129 100644 (file)
@@ -667,8 +667,7 @@ static ssize_t description_show(struct mdev_type *mtype,
                &mdpy_types[mtype_get_type_group_id(mtype)];
 
        return sprintf(buf, "virtual display, %dx%d framebuffer\n",
-                      type ? type->width  : 0,
-                      type ? type->height : 0);
+                      type->width, type->height);
 }
 static MDEV_TYPE_ATTR_RO(description);