diff mbox

drm/i915/dp: silence a static checker warning

Message ID 20180503105306.GA5315@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter May 3, 2018, 10:53 a.m. UTC
Smatch warns that "n_entries" isn't always set.  It would trigger a
some WARN_ON()s on that path so presumably it can't happen but it's
simple enough to initialize it to zero just to silence the warning.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Rodrigo Vivi May 3, 2018, 4:40 p.m. UTC | #1
On Thu, May 03, 2018 at 01:53:22PM +0300, Dan Carpenter wrote:
> Smatch warns that "n_entries" isn't always set.  It would trigger a
> some WARN_ON()s on that path so presumably it can't happen but it's
> simple enough to initialize it to zero just to silence the warning.

I usually would just ask if it would be possible to dispositioning
as false positive or intentional on the tool, but it looks better
indeed...

so, why not?!

> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> 
> diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
> index 8225d223f452..f4951ae33ac2 100644
> --- a/drivers/gpu/drm/i915/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/intel_ddi.c
> @@ -2062,7 +2062,7 @@ u8 intel_ddi_dp_voltage_max(struct intel_encoder *encoder)
>  {
>  	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
>  	enum port port = encoder->port;
> -	int n_entries;
> +	int n_entries = 0;
>  
>  	if (IS_ICELAKE(dev_priv)) {
>  		if (port == PORT_A || port == PORT_B)
Chris Wilson May 4, 2018, 3:15 p.m. UTC | #2
Quoting Rodrigo Vivi (2018-05-03 17:40:00)
> On Thu, May 03, 2018 at 01:53:22PM +0300, Dan Carpenter wrote:
> > Smatch warns that "n_entries" isn't always set.  It would trigger a
> > some WARN_ON()s on that path so presumably it can't happen but it's
> > simple enough to initialize it to zero just to silence the warning.
> 
> I usually would just ask if it would be possible to dispositioning
> as false positive or intentional on the tool, but it looks better
> indeed...

It doesn't appear to be a false positive.

intel_ddi_dp_voltage_max
 -> icl_get_combo_buf_trans()
 	default:
		MISSING_CASE();
		return NULL; /* *n_entries unset */

With

@@ -888,6 +888,7 @@ icl_get_combo_buf_trans(struct drm_i915_private *dev_priv, enum port port,
                        *n_entries = ARRAY_SIZE(icl_combo_phy_ddi_translations_edp_1_05V);
                        return icl_combo_phy_ddi_translations_edp_1_05V;
                default:
+                       *n_entries = 0;
                        MISSING_CASE(voltage);
                        return NULL;
                }
@@ -903,6 +904,7 @@ icl_get_combo_buf_trans(struct drm_i915_private *dev_priv, enum port port,
                        *n_entries = ARRAY_SIZE(icl_combo_phy_ddi_translations_dp_hdmi_1_05V);
                        return icl_combo_phy_ddi_translations_dp_hdmi_1_05V;
                default:
+                       *n_entries = 0;
                        MISSING_CASE(voltage);
                        return NULL;
                }

smatch is reassured that all paths then initialise n_entries.
-Chris
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 8225d223f452..f4951ae33ac2 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -2062,7 +2062,7 @@  u8 intel_ddi_dp_voltage_max(struct intel_encoder *encoder)
 {
 	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
 	enum port port = encoder->port;
-	int n_entries;
+	int n_entries = 0;
 
 	if (IS_ICELAKE(dev_priv)) {
 		if (port == PORT_A || port == PORT_B)