diff mbox

[v2] drm/i915: Initialise entry in intel_ppat_get() for older compilers

Message ID F3B0350DF4CB6849A642218320DE483D7D67C27D@SHSMSX104.ccr.corp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wang, Zhi A Nov. 17, 2017, 1:32 p.m. UTC
Thanks! Looks good to me.

-----Original Message-----
From: Chris Wilson [mailto:chris@chris-wilson.co.uk] 
Sent: Wednesday, November 15, 2017 3:17 PM
To: intel-gfx@lists.freedesktop.org
Cc: Chris Wilson <chris@chris-wilson.co.uk>; Joonas Lahtinen <joonas.lahtinen@linux.intel.com>; Wang, Zhi A <zhi.a.wang@intel.com>; Ville Syrjälä <ville.syrjala@linux.intel.com>
Subject: [PATCH v2] drm/i915: Initialise entry in intel_ppat_get() for older compilers

gcc-4.7.3 is confused by the guards inside intel_ppat_get() and reports:

drivers/gpu/drm/i915/i915_gem_gtt.c: In function ‘intel_ppat_get’:
drivers/gpu/drm/i915/i915_gem_gtt.c:3044:27: warning: ‘entry’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Forgive the compiler this once, and rearrange the code so that entry is always initialised.

v2: Flavour with a bit of NULL (instead of ERR_PTR(-ENOSPC).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Zhi Wang <zhi.a.wang@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

 
 	if (scanned == ppat->max_entries) {
-		if (!best_score)
+		if (!entry)
 			return ERR_PTR(-ENOSPC);
 
 		kref_get(&entry->ref);
--
2.15.0

Comments

Joonas Lahtinen Nov. 20, 2017, 9:54 a.m. UTC | #1
On Fri, 2017-11-17 at 13:32 +0000, Wang, Zhi A wrote:
> Thanks! Looks good to me.

An explicit Reviewed-by would probably be in place then? Then we get
the patch merged, too.

Regards, Joonas

> -----Original Message-----
> From: Chris Wilson [mailto:chris@chris-wilson.co.uk] 
> Sent: Wednesday, November 15, 2017 3:17 PM
> To: intel-gfx@lists.freedesktop.org
> Cc: Chris Wilson <chris@chris-wilson.co.uk>; Joonas Lahtinen <joonas.lahtinen@linux.intel.com>; Wang, Zhi A <zhi.a.wang@intel.com>; Ville Syrjälä <ville.syrjala@linux.intel.com>
> Subject: [PATCH v2] drm/i915: Initialise entry in intel_ppat_get() for older compilers
> 
> gcc-4.7.3 is confused by the guards inside intel_ppat_get() and reports:
> 
> drivers/gpu/drm/i915/i915_gem_gtt.c: In function ‘intel_ppat_get’:
> drivers/gpu/drm/i915/i915_gem_gtt.c:3044:27: warning: ‘entry’ may be used uninitialized in this function [-Wmaybe-uninitialized]
> 
> Forgive the compiler this once, and rearrange the code so that entry is always initialised.
> 
> v2: Flavour with a bit of NULL (instead of ERR_PTR(-ENOSPC).
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Zhi Wang <zhi.a.wang@intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem_gtt.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index 3c3a699436c9..f92a39fc511c 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -3076,7 +3076,7 @@ const struct intel_ppat_entry *  intel_ppat_get(struct drm_i915_private *i915, u8 value)  {
>  	struct intel_ppat *ppat = &i915->ppat;
> -	struct intel_ppat_entry *entry;
> +	struct intel_ppat_entry *entry = NULL;
>  	unsigned int scanned, best_score;
>  	int i;
>  
> @@ -3099,7 +3099,7 @@ intel_ppat_get(struct drm_i915_private *i915, u8 value)
>  	}
>  
>  	if (scanned == ppat->max_entries) {
> -		if (!best_score)
> +		if (!entry)
>  			return ERR_PTR(-ENOSPC);
>  
>  		kref_get(&entry->ref);
> --
> 2.15.0
>
Wang, Zhi A Nov. 20, 2017, 10:02 a.m. UTC | #2
Reviewed-by: Zhi Wang <zhi.a.wang@intel.com>


-----Original Message-----
From: Joonas Lahtinen [mailto:joonas.lahtinen@linux.intel.com] 

Sent: Monday, November 20, 2017 11:55 AM
To: Wang, Zhi A <zhi.a.wang@intel.com>; Chris Wilson <chris@chris-wilson.co.uk>; intel-gfx@lists.freedesktop.org
Cc: Ville Syrj?l? <ville.syrjala@linux.intel.com>
Subject: Re: [PATCH v2] drm/i915: Initialise entry in intel_ppat_get() for older compilers

On Fri, 2017-11-17 at 13:32 +0000, Wang, Zhi A wrote:
> Thanks! Looks good to me.


An explicit Reviewed-by would probably be in place then? Then we get the patch merged, too.

Regards, Joonas

> -----Original Message-----

> From: Chris Wilson [mailto:chris@chris-wilson.co.uk]

> Sent: Wednesday, November 15, 2017 3:17 PM

> To: intel-gfx@lists.freedesktop.org

> Cc: Chris Wilson <chris@chris-wilson.co.uk>; Joonas Lahtinen 

> <joonas.lahtinen@linux.intel.com>; Wang, Zhi A <zhi.a.wang@intel.com>; 

> Ville Syrjälä <ville.syrjala@linux.intel.com>

> Subject: [PATCH v2] drm/i915: Initialise entry in intel_ppat_get() for 

> older compilers

> 

> gcc-4.7.3 is confused by the guards inside intel_ppat_get() and reports:

> 

> drivers/gpu/drm/i915/i915_gem_gtt.c: In function ‘intel_ppat_get’:

> drivers/gpu/drm/i915/i915_gem_gtt.c:3044:27: warning: ‘entry’ may be 

> used uninitialized in this function [-Wmaybe-uninitialized]

> 

> Forgive the compiler this once, and rearrange the code so that entry is always initialised.

> 

> v2: Flavour with a bit of NULL (instead of ERR_PTR(-ENOSPC).

> 

> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

> Cc: Zhi Wang <zhi.a.wang@intel.com>

> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>

> ---

>  drivers/gpu/drm/i915/i915_gem_gtt.c | 4 ++--

>  1 file changed, 2 insertions(+), 2 deletions(-)

> 

> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c 

> b/drivers/gpu/drm/i915/i915_gem_gtt.c

> index 3c3a699436c9..f92a39fc511c 100644

> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c

> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c

> @@ -3076,7 +3076,7 @@ const struct intel_ppat_entry *  intel_ppat_get(struct drm_i915_private *i915, u8 value)  {

>  	struct intel_ppat *ppat = &i915->ppat;

> -	struct intel_ppat_entry *entry;

> +	struct intel_ppat_entry *entry = NULL;

>  	unsigned int scanned, best_score;

>  	int i;

>  

> @@ -3099,7 +3099,7 @@ intel_ppat_get(struct drm_i915_private *i915, u8 value)

>  	}

>  

>  	if (scanned == ppat->max_entries) {

> -		if (!best_score)

> +		if (!entry)

>  			return ERR_PTR(-ENOSPC);

>  

>  		kref_get(&entry->ref);

> --

> 2.15.0

> 

--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 3c3a699436c9..f92a39fc511c 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -3076,7 +3076,7 @@  const struct intel_ppat_entry *  intel_ppat_get(struct drm_i915_private *i915, u8 value)  {
 	struct intel_ppat *ppat = &i915->ppat;
-	struct intel_ppat_entry *entry;
+	struct intel_ppat_entry *entry = NULL;
 	unsigned int scanned, best_score;
 	int i;
 
@@ -3099,7 +3099,7 @@  intel_ppat_get(struct drm_i915_private *i915, u8 value)
 	}