All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/virtio: remove some redundant code
@ 2023-07-11  9:00 ` Su Hui
  0 siblings, 0 replies; 13+ messages in thread
From: Su Hui @ 2023-07-11  9:00 UTC (permalink / raw)
  To: airlied, kraxel, gurchetansingh, olvaffe, daniel
  Cc: dri-devel, virtualization, linux-kernel, kernel-janitors, Su Hui

virtio_gpu_get_vbuf always be successful,
so remove the error judgment.

Signed-off-by: Su Hui <suhui@nfschina.com>
---
 drivers/gpu/drm/virtio/virtgpu_vq.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
index b1a00c0c25a7..7a2680b3f1a7 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -129,10 +129,6 @@ virtio_gpu_alloc_cursor(struct virtio_gpu_device *vgdev,
 	vbuf = virtio_gpu_get_vbuf
 		(vgdev, sizeof(struct virtio_gpu_update_cursor),
 		 0, NULL, NULL);
-	if (IS_ERR(vbuf)) {
-		*vbuffer_p = NULL;
-		return ERR_CAST(vbuf);
-	}
 	*vbuffer_p = vbuf;
 	return (struct virtio_gpu_update_cursor *)vbuf->buf;
 }
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH] drm/virtio: remove some redundant code
@ 2023-07-11  9:00 ` Su Hui
  0 siblings, 0 replies; 13+ messages in thread
From: Su Hui @ 2023-07-11  9:00 UTC (permalink / raw)
  To: airlied, kraxel, gurchetansingh, olvaffe, daniel
  Cc: Su Hui, kernel-janitors, linux-kernel, dri-devel, virtualization

virtio_gpu_get_vbuf always be successful,
so remove the error judgment.

Signed-off-by: Su Hui <suhui@nfschina.com>
---
 drivers/gpu/drm/virtio/virtgpu_vq.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
index b1a00c0c25a7..7a2680b3f1a7 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -129,10 +129,6 @@ virtio_gpu_alloc_cursor(struct virtio_gpu_device *vgdev,
 	vbuf = virtio_gpu_get_vbuf
 		(vgdev, sizeof(struct virtio_gpu_update_cursor),
 		 0, NULL, NULL);
-	if (IS_ERR(vbuf)) {
-		*vbuffer_p = NULL;
-		return ERR_CAST(vbuf);
-	}
 	*vbuffer_p = vbuf;
 	return (struct virtio_gpu_update_cursor *)vbuf->buf;
 }
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/virtio: remove some redundant code
  2023-07-11  9:00 ` Su Hui
  (?)
@ 2023-07-11  9:33 ` Markus Elfring
  2023-07-12  1:26     ` Su Hui
  -1 siblings, 1 reply; 13+ messages in thread
From: Markus Elfring @ 2023-07-11  9:33 UTC (permalink / raw)
  To: Su Hui, dri-devel, virtualization, kernel-janitors,
	Daniel Vetter, Dave Airlie, Gerd Hoffmann, Gurchetan Singh,
	Chia-I Wu
  Cc: LKML

> virtio_gpu_get_vbuf always be successful,
> so remove the error judgment.

How do you think about to improve this change description any more?

Regards,
Markus

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/virtio: remove some redundant code
  2023-07-11  9:00 ` Su Hui
@ 2023-07-11 11:13   ` Dan Carpenter
  -1 siblings, 0 replies; 13+ messages in thread
From: Dan Carpenter @ 2023-07-11 11:13 UTC (permalink / raw)
  To: Su Hui
  Cc: airlied, kraxel, gurchetansingh, olvaffe, daniel, dri-devel,
	virtualization, linux-kernel, kernel-janitors

On Tue, Jul 11, 2023 at 05:00:31PM +0800, Su Hui wrote:
> virtio_gpu_get_vbuf always be successful,
> so remove the error judgment.
> 

No, just ignore the static checker false positive in this case.  The
intent of the code is clear that if it did have an error it should
return an error pointer.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/virtio: remove some redundant code
@ 2023-07-11 11:13   ` Dan Carpenter
  0 siblings, 0 replies; 13+ messages in thread
From: Dan Carpenter @ 2023-07-11 11:13 UTC (permalink / raw)
  To: Su Hui
  Cc: kernel-janitors, linux-kernel, dri-devel, gurchetansingh, kraxel,
	airlied, virtualization

On Tue, Jul 11, 2023 at 05:00:31PM +0800, Su Hui wrote:
> virtio_gpu_get_vbuf always be successful,
> so remove the error judgment.
> 

No, just ignore the static checker false positive in this case.  The
intent of the code is clear that if it did have an error it should
return an error pointer.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/virtio: remove some redundant code
  2023-07-11 11:13   ` Dan Carpenter
@ 2023-07-12  1:18     ` Su Hui
  -1 siblings, 0 replies; 13+ messages in thread
From: Su Hui @ 2023-07-12  1:18 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: airlied, kraxel, gurchetansingh, olvaffe, daniel, dri-devel,
	virtualization, linux-kernel, kernel-janitors

On 2023/7/11 19:13, Dan Carpenter wrote:
> On Tue, Jul 11, 2023 at 05:00:31PM +0800, Su Hui wrote:
>> virtio_gpu_get_vbuf always be successful,
>> so remove the error judgment.
>>
> No, just ignore the static checker false positive in this case.  The
> intent of the code is clear that if it did have an error it should
> return an error pointer.

Hi, Dan,

Function "virtio_gpu_get_vbuf" call "kmem_cache_zalloc (vgdev->vbufs, 
GFP_KERNEL | __GFP_NOFAIL)" to
allocate memory. Adding the " __GFP_NOFAIL”flag make sure it won't fail. 
And "virtio_gpu_get_vbuf" never
return an error code, so I think this is not a false positive.

Su Hui

>
> regards,
> dan carpenter
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/virtio: remove some redundant code
@ 2023-07-12  1:18     ` Su Hui
  0 siblings, 0 replies; 13+ messages in thread
From: Su Hui @ 2023-07-12  1:18 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: kernel-janitors, linux-kernel, dri-devel, gurchetansingh, kraxel,
	airlied, virtualization

On 2023/7/11 19:13, Dan Carpenter wrote:
> On Tue, Jul 11, 2023 at 05:00:31PM +0800, Su Hui wrote:
>> virtio_gpu_get_vbuf always be successful,
>> so remove the error judgment.
>>
> No, just ignore the static checker false positive in this case.  The
> intent of the code is clear that if it did have an error it should
> return an error pointer.

Hi, Dan,

Function "virtio_gpu_get_vbuf" call "kmem_cache_zalloc (vgdev->vbufs, 
GFP_KERNEL | __GFP_NOFAIL)" to
allocate memory. Adding the " __GFP_NOFAIL”flag make sure it won't fail. 
And "virtio_gpu_get_vbuf" never
return an error code, so I think this is not a false positive.

Su Hui

>
> regards,
> dan carpenter
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/virtio: remove some redundant code
  2023-07-11  9:33 ` Markus Elfring
@ 2023-07-12  1:26     ` Su Hui
  0 siblings, 0 replies; 13+ messages in thread
From: Su Hui @ 2023-07-12  1:26 UTC (permalink / raw)
  To: Markus Elfring
  Cc: LKML, dri-devel, Gerd Hoffmann, Dave Airlie, virtualization,
	Gurchetan Singh, Daniel Vetter, kernel-janitors, Chia-I Wu


On 2023/7/11 17:33, Markus Elfring wrote:
>> virtio_gpu_get_vbuf always be successful,
>> so remove the error judgment.
> How do you think about to improve this change description any more?

Hi,

virtio_gpu_get_vbuf use "__GFP_NOFAIL" flag to allocate memory, this 
make sure
it won't fail, and virtio_gpu_get_vbuf never return error code, so 
remove the error judgment.

How about this one? Thanks for your advice.

Su Hui

> Regards,
> Markus

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/virtio: remove some redundant code
@ 2023-07-12  1:26     ` Su Hui
  0 siblings, 0 replies; 13+ messages in thread
From: Su Hui @ 2023-07-12  1:26 UTC (permalink / raw)
  To: Markus Elfring
  Cc: kernel-janitors, LKML, dri-devel, virtualization, Gerd Hoffmann,
	Dave Airlie, Gurchetan Singh


On 2023/7/11 17:33, Markus Elfring wrote:
>> virtio_gpu_get_vbuf always be successful,
>> so remove the error judgment.
> How do you think about to improve this change description any more?

Hi,

virtio_gpu_get_vbuf use "__GFP_NOFAIL" flag to allocate memory, this 
make sure
it won't fail, and virtio_gpu_get_vbuf never return error code, so 
remove the error judgment.

How about this one? Thanks for your advice.

Su Hui

> Regards,
> Markus

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/virtio: remove some redundant code
  2023-07-12  1:18     ` Su Hui
@ 2023-07-12  6:36       ` Dan Carpenter
  -1 siblings, 0 replies; 13+ messages in thread
From: Dan Carpenter @ 2023-07-12  6:36 UTC (permalink / raw)
  To: Su Hui
  Cc: kernel-janitors, linux-kernel, dri-devel, gurchetansingh, kraxel,
	airlied, virtualization

On Wed, Jul 12, 2023 at 09:18:42AM +0800, Su Hui wrote:
> On 2023/7/11 19:13, Dan Carpenter wrote:
> > On Tue, Jul 11, 2023 at 05:00:31PM +0800, Su Hui wrote:
> > > virtio_gpu_get_vbuf always be successful,
> > > so remove the error judgment.
> > > 
> > No, just ignore the static checker false positive in this case.  The
> > intent of the code is clear that if it did have an error it should
> > return an error pointer.
> 
> Hi, Dan,
> 
> Function "virtio_gpu_get_vbuf" call "kmem_cache_zalloc (vgdev->vbufs,
> GFP_KERNEL | __GFP_NOFAIL)" to
> allocate memory. Adding the " __GFP_NOFAIL”flag make sure it won't fail. And
> "virtio_gpu_get_vbuf" never
> return an error code, so I think this is not a false positive.

We all see this and agree.

However the check for if (IS_ERR()) is written deliberately because we
might change the code to return error pointers in the future.  Static
checkers are looking for code that does something unintentional but in
this case the code was written that way deliberately.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/virtio: remove some redundant code
@ 2023-07-12  6:36       ` Dan Carpenter
  0 siblings, 0 replies; 13+ messages in thread
From: Dan Carpenter @ 2023-07-12  6:36 UTC (permalink / raw)
  To: Su Hui
  Cc: airlied, kraxel, gurchetansingh, olvaffe, daniel, dri-devel,
	virtualization, linux-kernel, kernel-janitors

On Wed, Jul 12, 2023 at 09:18:42AM +0800, Su Hui wrote:
> On 2023/7/11 19:13, Dan Carpenter wrote:
> > On Tue, Jul 11, 2023 at 05:00:31PM +0800, Su Hui wrote:
> > > virtio_gpu_get_vbuf always be successful,
> > > so remove the error judgment.
> > > 
> > No, just ignore the static checker false positive in this case.  The
> > intent of the code is clear that if it did have an error it should
> > return an error pointer.
> 
> Hi, Dan,
> 
> Function "virtio_gpu_get_vbuf" call "kmem_cache_zalloc (vgdev->vbufs,
> GFP_KERNEL | __GFP_NOFAIL)" to
> allocate memory. Adding the " __GFP_NOFAIL”flag make sure it won't fail. And
> "virtio_gpu_get_vbuf" never
> return an error code, so I think this is not a false positive.

We all see this and agree.

However the check for if (IS_ERR()) is written deliberately because we
might change the code to return error pointers in the future.  Static
checkers are looking for code that does something unintentional but in
this case the code was written that way deliberately.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/virtio: remove some redundant code
  2023-07-12  6:36       ` Dan Carpenter
@ 2023-07-12 10:15         ` Su Hui
  -1 siblings, 0 replies; 13+ messages in thread
From: Su Hui @ 2023-07-12 10:15 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: airlied, kraxel, gurchetansingh, olvaffe, daniel, dri-devel,
	virtualization, linux-kernel, kernel-janitors

On 2023/7/12 14:36, Dan Carpenter wrote:

> On Wed, Jul 12, 2023 at 09:18:42AM +0800, Su Hui wrote:
>> On 2023/7/11 19:13, Dan Carpenter wrote:
>>> On Tue, Jul 11, 2023 at 05:00:31PM +0800, Su Hui wrote:
>>>> virtio_gpu_get_vbuf always be successful,
>>>> so remove the error judgment.
>>>>
>>> No, just ignore the static checker false positive in this case.  The
>>> intent of the code is clear that if it did have an error it should
>>> return an error pointer.
>> Hi, Dan,
>>
>> Function "virtio_gpu_get_vbuf" call "kmem_cache_zalloc (vgdev->vbufs,
>> GFP_KERNEL | __GFP_NOFAIL)" to
>> allocate memory. Adding the " __GFP_NOFAIL”flag make sure it won't fail. And
>> "virtio_gpu_get_vbuf" never
>> return an error code, so I think this is not a false positive.
> We all see this and agree.
>
> However the check for if (IS_ERR()) is written deliberately because we
> might change the code to return error pointers in the future.  Static
> checkers are looking for code that does something unintentional but in
> this case the code was written that way deliberately.
Got it ,  I shouldn't remove it because the check may be useful in the 
future.
Thanks for your explanation.

Su Hui

>
> regards,
> dan carpenter
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/virtio: remove some redundant code
@ 2023-07-12 10:15         ` Su Hui
  0 siblings, 0 replies; 13+ messages in thread
From: Su Hui @ 2023-07-12 10:15 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: kernel-janitors, linux-kernel, dri-devel, gurchetansingh, kraxel,
	airlied, virtualization

On 2023/7/12 14:36, Dan Carpenter wrote:

> On Wed, Jul 12, 2023 at 09:18:42AM +0800, Su Hui wrote:
>> On 2023/7/11 19:13, Dan Carpenter wrote:
>>> On Tue, Jul 11, 2023 at 05:00:31PM +0800, Su Hui wrote:
>>>> virtio_gpu_get_vbuf always be successful,
>>>> so remove the error judgment.
>>>>
>>> No, just ignore the static checker false positive in this case.  The
>>> intent of the code is clear that if it did have an error it should
>>> return an error pointer.
>> Hi, Dan,
>>
>> Function "virtio_gpu_get_vbuf" call "kmem_cache_zalloc (vgdev->vbufs,
>> GFP_KERNEL | __GFP_NOFAIL)" to
>> allocate memory. Adding the " __GFP_NOFAIL”flag make sure it won't fail. And
>> "virtio_gpu_get_vbuf" never
>> return an error code, so I think this is not a false positive.
> We all see this and agree.
>
> However the check for if (IS_ERR()) is written deliberately because we
> might change the code to return error pointers in the future.  Static
> checkers are looking for code that does something unintentional but in
> this case the code was written that way deliberately.
Got it ,  I shouldn't remove it because the check may be useful in the 
future.
Thanks for your explanation.

Su Hui

>
> regards,
> dan carpenter
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-07-12 10:15 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-11  9:00 [PATCH] drm/virtio: remove some redundant code Su Hui
2023-07-11  9:00 ` Su Hui
2023-07-11  9:33 ` Markus Elfring
2023-07-12  1:26   ` Su Hui
2023-07-12  1:26     ` Su Hui
2023-07-11 11:13 ` Dan Carpenter
2023-07-11 11:13   ` Dan Carpenter
2023-07-12  1:18   ` Su Hui
2023-07-12  1:18     ` Su Hui
2023-07-12  6:36     ` Dan Carpenter
2023-07-12  6:36       ` Dan Carpenter
2023-07-12 10:15       ` Su Hui
2023-07-12 10:15         ` Su Hui

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.