* [PATCH] vfio/mdev: remove unnecessary NULL check in mbochs_create()
@ 2021-04-21 13:29 Dan Carpenter
2021-04-21 18:23 ` Jason Gunthorpe
2021-04-21 22:51 ` Alex Williamson
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-04-21 13:29 UTC (permalink / raw)
To: Kirti Wankhede, Jason Gunthorpe; +Cc: Alex Williamson, kvm, kernel-janitors
This NULL check is no longer required because "type" now points to
an element in a non-NULL array.
Fixes: 3d3a360e570616 ("vfio/mbochs: Use mdev_get_type_group_id()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
samples/vfio-mdev/mbochs.c | 2 --
samples/vfio-mdev/mdpy.c | 3 +--
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c
index 861c76914e76..881ef9a7296f 100644
--- a/samples/vfio-mdev/mbochs.c
+++ b/samples/vfio-mdev/mbochs.c
@@ -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;
diff --git a/samples/vfio-mdev/mdpy.c b/samples/vfio-mdev/mdpy.c
index f0c0e7209719..e889c1cf8fd1 100644
--- a/samples/vfio-mdev/mdpy.c
+++ b/samples/vfio-mdev/mdpy.c
@@ -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);
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] vfio/mdev: remove unnecessary NULL check in mbochs_create()
2021-04-21 13:29 [PATCH] vfio/mdev: remove unnecessary NULL check in mbochs_create() Dan Carpenter
@ 2021-04-21 18:23 ` Jason Gunthorpe
2021-04-21 22:51 ` Alex Williamson
1 sibling, 0 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2021-04-21 18:23 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Kirti Wankhede, Alex Williamson, kvm, kernel-janitors
On Wed, Apr 21, 2021 at 04:29:36PM +0300, Dan Carpenter wrote:
> This NULL check is no longer required because "type" now points to
> an element in a non-NULL array.
>
> Fixes: 3d3a360e570616 ("vfio/mbochs: Use mdev_get_type_group_id()")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> samples/vfio-mdev/mbochs.c | 2 --
> samples/vfio-mdev/mdpy.c | 3 +--
> 2 files changed, 1 insertion(+), 4 deletions(-)
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Thanks,
Jason
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] vfio/mdev: remove unnecessary NULL check in mbochs_create()
2021-04-21 13:29 [PATCH] vfio/mdev: remove unnecessary NULL check in mbochs_create() Dan Carpenter
2021-04-21 18:23 ` Jason Gunthorpe
@ 2021-04-21 22:51 ` Alex Williamson
1 sibling, 0 replies; 3+ messages in thread
From: Alex Williamson @ 2021-04-21 22:51 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Kirti Wankhede, Jason Gunthorpe, kvm, kernel-janitors
On Wed, 21 Apr 2021 16:29:36 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> This NULL check is no longer required because "type" now points to
> an element in a non-NULL array.
I think the mdpy change is correct too, but it's hard to verify from
this commit log that it was actually intended. Can we note that change
as well? Thanks,
Alex
>
> Fixes: 3d3a360e570616 ("vfio/mbochs: Use mdev_get_type_group_id()")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> samples/vfio-mdev/mbochs.c | 2 --
> samples/vfio-mdev/mdpy.c | 3 +--
> 2 files changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c
> index 861c76914e76..881ef9a7296f 100644
> --- a/samples/vfio-mdev/mbochs.c
> +++ b/samples/vfio-mdev/mbochs.c
> @@ -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;
>
> diff --git a/samples/vfio-mdev/mdpy.c b/samples/vfio-mdev/mdpy.c
> index f0c0e7209719..e889c1cf8fd1 100644
> --- a/samples/vfio-mdev/mdpy.c
> +++ b/samples/vfio-mdev/mdpy.c
> @@ -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);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-04-21 22:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-21 13:29 [PATCH] vfio/mdev: remove unnecessary NULL check in mbochs_create() Dan Carpenter
2021-04-21 18:23 ` Jason Gunthorpe
2021-04-21 22:51 ` Alex Williamson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.