vfio/mdev: remove unnecessary NULL check in mbochs_create()
Subsystems (3)
PATCH v2 1/1 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.
---
Update the commit message
samples/vfio-mdev/mbochs.c | 2 -- samples/vfio-mdev/mdpy.c | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-)
samples/vfio-mdev/mbochs.c +0 -2
@@ -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 ;
samples/vfio-mdev/mdpy.c +1 -2
@@ -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);
Signature · 1 line
2.30.2
Quoted 7 lines · Dan Carpenter
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.
Quoted 8 lines
Fixes 3d3a360e570616 ("vfio/mbochs: Use mdev_get_type_group_id()")Signed-off-by Dan Carpenter <[email protected]>---
Update the commit messagesamples/vfio-mdev/mbochs.c | 2 -- samples/vfio-mdev/mdpy.c | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-)
There are problably several of these code removal oversights.
Thanks,
Jason