Re: [Intel-gfx] [PATCH] drm/i915: fix compilation warnings on maybe uninitialized pointers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Nov 28, 2016 at 06:43:19PM -0500, Jérémy Lefaure wrote:
> Two warnings are produced by gcc (tested with gcc 6.2.1):
> 
> drivers/gpu/drm/i915/intel_csr.c: In function ‘csr_load_work_fn’:
> drivers/gpu/drm/i915/intel_csr.c:400:5: error: ‘fw’ is used
> uninitialized in this function [-Werror=uninitialized]
>   if (fw)
>        ^
> and
> 
> In file included from drivers/gpu/drm/i915/i915_drv.h:47:0,
>                  from drivers/gpu/drm/i915/intel_guc_loader.c:30:
> drivers/gpu/drm/i915/intel_guc_loader.c: In function ‘intel_guc_init’:
> ./include/drm/drmP.h:228:2: error: ‘fw’ may be used uninitialized in this
> function  -Werror=maybe-uninitialized]
>   drm_printk(KERN_DEBUG, DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
>   ^~~~~~~~~~
> drivers/gpu/drm/i915/intel_guc_loader.c:595:25: note: ‘fw’ was declared here
>   const struct firmware *fw;
>                          ^~
> 
> When CONFIG_DRM_I915_WERROR is set, those warnings break the build.
> 
> Initializing fw pointer to NULL in both cases removes the warnings.
> 
> Signed-off-by: Jérémy Lefaure <jeremy.lefaure@xxxxxxxxxxxx>

Queued for -next, thanks for the patch.
-Daniel

> ---
>  drivers/gpu/drm/i915/intel_csr.c        | 2 +-
>  drivers/gpu/drm/i915/intel_guc_loader.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_csr.c b/drivers/gpu/drm/i915/intel_csr.c
> index d7a04bc..3520b3c 100644
> --- a/drivers/gpu/drm/i915/intel_csr.c
> +++ b/drivers/gpu/drm/i915/intel_csr.c
> @@ -389,7 +389,7 @@ static void csr_load_work_fn(struct work_struct *work)
>  {
>  	struct drm_i915_private *dev_priv;
>  	struct intel_csr *csr;
> -	const struct firmware *fw;
> +	const struct firmware *fw = NULL;
>  	int ret;
>  
>  	dev_priv = container_of(work, typeof(*dev_priv), csr.work);
> diff --git a/drivers/gpu/drm/i915/intel_guc_loader.c b/drivers/gpu/drm/i915/intel_guc_loader.c
> index 34d6ad2..ecfee49 100644
> --- a/drivers/gpu/drm/i915/intel_guc_loader.c
> +++ b/drivers/gpu/drm/i915/intel_guc_loader.c
> @@ -592,7 +592,7 @@ static void guc_fw_fetch(struct drm_device *dev, struct intel_guc_fw *guc_fw)
>  {
>  	struct pci_dev *pdev = dev->pdev;
>  	struct drm_i915_gem_object *obj;
> -	const struct firmware *fw;
> +	const struct firmware *fw = NULL;
>  	struct guc_css_header *css;
>  	size_t size;
>  	int err;
> -- 
> 2.10.2
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux