[02/13] drm/mgag200: Remove unecessary NULL check in gem_free
diff mbox

Message ID 1396691102-22904-4-git-send-email-daniel.vetter@ffwll.ch
State New, archived
Headers show

Commit Message

Daniel Vetter April 5, 2014, 9:44 a.m. UTC
The ->gem_free_object never gets called with a NULL pointer, the check
is redundant. Also checking after the upcast allows compilers to elide
it anyway.

Spotted by coverity.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/mgag200/mgag200_main.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Ian Romanick April 7, 2014, 3:23 p.m. UTC | #1
On 04/05/2014 02:44 AM, Daniel Vetter wrote:
> The ->gem_free_object never gets called with a NULL pointer, the check
> is redundant. Also checking after the upcast allows compilers to elide
> it anyway.

Right... because if obj was NULL, subtracting some offset from it won't
still be NULL.

> Spotted by coverity.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>

> ---
>  drivers/gpu/drm/mgag200/mgag200_main.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c
> index 0722d18992f4..f6b283b8375e 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_main.c
> +++ b/drivers/gpu/drm/mgag200/mgag200_main.c
> @@ -329,8 +329,6 @@ void mgag200_gem_free_object(struct drm_gem_object *obj)
>  {
>  	struct mgag200_bo *mgag200_bo = gem_to_mga_bo(obj);
>  
> -	if (!mgag200_bo)
> -		return;
>  	mgag200_bo_unref(&mgag200_bo);
>  }
>  
>

Patch
diff mbox

diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c
index 0722d18992f4..f6b283b8375e 100644
--- a/drivers/gpu/drm/mgag200/mgag200_main.c
+++ b/drivers/gpu/drm/mgag200/mgag200_main.c
@@ -329,8 +329,6 @@  void mgag200_gem_free_object(struct drm_gem_object *obj)
 {
 	struct mgag200_bo *mgag200_bo = gem_to_mga_bo(obj);
 
-	if (!mgag200_bo)
-		return;
 	mgag200_bo_unref(&mgag200_bo);
 }