drm/i915: fix compilation warnings on maybe uninitialized pointers
authorJérémy Lefaure <jeremy.lefaure@lse.epita.fr>
Mon, 28 Nov 2016 23:43:19 +0000 (18:43 -0500)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 29 Nov 2016 10:31:01 +0000 (11:31 +0100)
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@lse.epita.fr>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161128234319.20800-1-jeremy.lefaure@lse.epita.fr
drivers/gpu/drm/i915/intel_csr.c
drivers/gpu/drm/i915/intel_guc_loader.c

index 10e9abcf0932f0ec949521d437572ccc2497890a..9cbb8d8363b4486cdb57d05f0c3e3c4b8db5d103 100644 (file)
@@ -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);
index 27f6fd57eb79c745c2ba512784fa1be08d914c93..a330fa4993842b9460d86528770ddc2f573db533 100644 (file)
@@ -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;