Skip to content

Commit 698f99e

Browse files
Dan Carpenterawilliam
authored andcommitted
vfio/mdev: remove unnecessary NULL check in mbochs_create()
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: 3d3a360 ("vfio/mbochs: Use mdev_get_type_group_id()") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Message-Id: <20210429095327.GY1981@kadam> Signed-off-by: Alex Williamson <[email protected]>
1 parent 5e321de commit 698f99e

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

samples/vfio-mdev/mbochs.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,6 @@ static int mbochs_create(struct mdev_device *mdev)
513513
struct device *dev = mdev_dev(mdev);
514514
struct mdev_state *mdev_state;
515515

516-
if (!type)
517-
type = &mbochs_types[0];
518516
if (type->mbytes + mbochs_used_mbytes > max_mbytes)
519517
return -ENOMEM;
520518

samples/vfio-mdev/mdpy.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,8 +667,7 @@ static ssize_t description_show(struct mdev_type *mtype,
667667
&mdpy_types[mtype_get_type_group_id(mtype)];
668668

669669
return sprintf(buf, "virtual display, %dx%d framebuffer\n",
670-
type ? type->width : 0,
671-
type ? type->height : 0);
670+
type->width, type->height);
672671
}
673672
static MDEV_TYPE_ATTR_RO(description);
674673

0 commit comments

Comments
 (0)