Skip to contentSkip to conversation

drm/i915/gem: remove unused assignments

PATCH In review [email protected] 3 participants 6 messages Jun 20, 2022 – Jun 22, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915/gem: remove unused assignments

From: katrinzhou <[email protected]>

The variable ret is reassigned and the value EINVAL is never used. Thus, remove the unused assignments.

Addresses-Coverity: ("Unused value")

Fixes d4433c7600f7 ("drm/i915/gem: Use the proto-context to handle create parameters (v5)")
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_context.c +0 -2
index ab4c5ab28e4d..d5ef5243673a 100644
@@ -931,8 +931,6 @@ static int set_proto_ctx_param(struct drm_i915_file_private *fpriv,
 		break;
 
 	case I915_CONTEXT_PARAM_PERSISTENCE:
-		if (args->size)
-			ret = -EINVAL;
 		ret = proto_context_set_persistence(fpriv->dev_priv, pc,
 						    args->value);
 		break;
Signature · 1 line
2.27.0
maintainer
#1 lore raw
Quoted 4 lines · On Mon, 20 Jun 2022, [email protected] wrote:

From: katrinzhou <[email protected]>

The variable ret is reassigned and the value EINVAL is never used. Thus, remove the unused assignments.

It's obviously a bug, but it's not obvious just throwing the code away is the fix. Maybe there's a missing "else" instead.

BR,
Jani.

Quoted 21 lines

Addresses-Coverity: ("Unused value")

Fixes d4433c7600f7 ("drm/i915/gem: Use the proto-context to handle create parameters (v5)")
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_context.c +0 -2
index ab4c5ab28e4d..d5ef5243673a 100644
@@ -931,8 +931,6 @@ static int set_proto_ctx_param(struct drm_i915_file_private *fpriv,
 		break;
 
 	case I915_CONTEXT_PARAM_PERSISTENCE:
-		if (args->size)
-			ret = -EINVAL;
 		ret = proto_context_set_persistence(fpriv->dev_priv, pc,
 						    args->value);
 		break;
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
author
#2 lore raw
Quoted 29 lines · Jani Nikula
Quoted 4 lines · On Mon, 20 Jun 2022, [email protected] wrote:

From: katrinzhou <[email protected]>

The variable ret is reassigned and the value EINVAL is never used. Thus, remove the unused assignments.

It's obviously a bug, but it's not obvious just throwing the code away is the fix. Maybe there's a missing "else" instead.

BR,
Jani.

Quoted 15 lines

Addresses-Coverity: ("Unused value")

Fixes d4433c7600f7 ("drm/i915/gem: Use the proto-context to handle create parameters (v5)")
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_context.c +0 -0
index ab4c5ab28e4d..d5ef5243673a 100644
@@ -931,8 +931,6 @@ static int set_proto_ctx_param(struct drm_i915_file_private *fpriv,
              break;
 
Quoted 9 lines

drivers/gpu/drm/i915/gem/i915_gem_context.c static int set_proto_ctx_param(struct drm_i915_file_private *fpriv, · line 936

Quoted 6 lines
drivers/gpu/drm/i915/gem/i915_gem_context.c +0 -2
      case I915_CONTEXT_PARAM_PERSISTENCE:
-             if (args->size)
-                     ret = -EINVAL;
              ret = proto_context_set_persistence(fpriv->dev_priv, pc,
                                                  args->value);
              break;

--
Jani Nikula, Intel Open Source Graphics Center

Thanks for reviewing!

Best Regards,
Katrin

#3 lore raw
In reply to [email protected]
Quoted 17 lines · On 20/06/2022 11:02, [email protected] wrote:

From: katrinzhou <[email protected]>

The variable ret is reassigned and the value EINVAL is never used. Thus, remove the unused assignments.

Addresses-Coverity: ("Unused value")

Fixes d4433c7600f7 ("drm/i915/gem: Use the proto-context to handle create parameters (v5)")
---
  drivers/gpu/drm/i915/gem/i915_gem_context.c | 2 --
  1 file changed, 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_context.c +0 -0
index ab4c5ab28e4d..d5ef5243673a 100644

drivers/gpu/drm/i915/gem/i915_gem_context.c static int set_proto_ctx_param(struct drm_i915_file_private *fpriv, · line 935

Quoted 7 lines
drivers/gpu/drm/i915/gem/i915_gem_context.c +0 -2
@@ -931,8 +931,6 @@ static int set_proto_ctx_param(struct drm_i915_file_private *fpriv,
  		break;
 
  	case I915_CONTEXT_PARAM_PERSISTENCE:
-		if (args->size)
-			ret = -EINVAL;
  		ret = proto_context_set_persistence(fpriv->dev_priv, pc,
  						    args->value);

AFAICT fix should end up with code like this:

if (args->size)

	ret = -EINVAL;

else
ret = proto_context_set_persistence(...)
break;

Alternatively move args->size checking into proto_context_set_persistence to align with set_persistence().

Regards,

Tvrtko

Quoted 1 line
drivers/gpu/drm/i915/gem/i915_gem_context.c +0 -0
  		break;
author
#4 lore raw
Quoted 37 lines · Tvrtko Ursulin
Quoted 17 lines · On 20/06/2022 11:02, [email protected] wrote:

From: katrinzhou <[email protected]>

The variable ret is reassigned and the value EINVAL is never used. Thus, remove the unused assignments.

Addresses-Coverity: ("Unused value")

Fixes d4433c7600f7 ("drm/i915/gem: Use the proto-context to handle create parameters (v5)")
---
  drivers/gpu/drm/i915/gem/i915_gem_context.c | 2 --
  1 file changed, 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_context.c +0 -0
index ab4c5ab28e4d..d5ef5243673a 100644

drivers/gpu/drm/i915/gem/i915_gem_context.c static int set_proto_ctx_param(struct drm_i915_file_private *fpriv, · line 935

Quoted 7 lines
drivers/gpu/drm/i915/gem/i915_gem_context.c +0 -2
@@ -931,8 +931,6 @@ static int set_proto_ctx_param(struct drm_i915_file_private *fpriv,
              break;
 
      case I915_CONTEXT_PARAM_PERSISTENCE:
-             if (args->size)
-                     ret = -EINVAL;
              ret = proto_context_set_persistence(fpriv->dev_priv, pc,
                                                  args->value);

AFAICT fix should end up with code like this:

if (args->size)

        ret = -EINVAL;

else
ret = proto_context_set_persistence(...)
break;

Quoted 8 lines

Alternatively move args->size checking into proto_context_set_persistence to align with set_persistence().

Regards,

Tvrtko

Quoted 1 line
drivers/gpu/drm/i915/gem/i915_gem_context.c +0 -0
              break;

Thanks for reviewing! I sent the V2 patch, modified according to your suggestion.

Best Regards,
Katrin

#5 lore raw
Quoted 42 lines · Katrin Jo
Quoted 40 lines · Tvrtko Ursulin
Quoted 17 lines · On 20/06/2022 11:02, [email protected] wrote:

From: katrinzhou <[email protected]>

The variable ret is reassigned and the value EINVAL is never used. Thus, remove the unused assignments.

Addresses-Coverity: ("Unused value")

Fixes d4433c7600f7 ("drm/i915/gem: Use the proto-context to handle create parameters (v5)")
---
   drivers/gpu/drm/i915/gem/i915_gem_context.c | 2 --
   1 file changed, 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_context.c +0 -0
index ab4c5ab28e4d..d5ef5243673a 100644

drivers/gpu/drm/i915/gem/i915_gem_context.c static int set_proto_ctx_param(struct drm_i915_file_private *fpriv, · line 935

Quoted 7 lines
drivers/gpu/drm/i915/gem/i915_gem_context.c +0 -2
@@ -931,8 +931,6 @@ static int set_proto_ctx_param(struct drm_i915_file_private *fpriv,
               break;
 
       case I915_CONTEXT_PARAM_PERSISTENCE:
-             if (args->size)
-                     ret = -EINVAL;
               ret = proto_context_set_persistence(fpriv->dev_priv, pc,
                                                   args->value);

AFAICT fix should end up with code like this:

if (args->size)

         ret = -EINVAL;

else
ret = proto_context_set_persistence(...)
break;

Alternatively move args->size checking into proto_context_set_persistence to align with set_persistence().

Quoted 8 lines
Quoted 5 lines

Regards,

Tvrtko

Quoted 1 line
drivers/gpu/drm/i915/gem/i915_gem_context.c +0 -0
               break;

Thanks for reviewing! I sent the V2 patch, modified according to your suggestion.

I have merged the v2 to drm-intel-gt-next - thanks for the fix!

Regards,

Tvrtko