]> git.baikalelectronics.ru Git - kernel.git/commitdiff
powerpc/papr_scm: Ensure rc is always initialized in papr_scm_pmu_register()
authorNathan Chancellor <nathan@kernel.org>
Tue, 30 Aug 2022 15:12:56 +0000 (08:12 -0700)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 2 Sep 2022 08:55:11 +0000 (18:55 +1000)
Clang warns:

  arch/powerpc/platforms/pseries/papr_scm.c:492:6: warning: variable 'rc' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
          if (!p->stat_buffer_len)
              ^~~~~~~~~~~~~~~~~~~
  arch/powerpc/platforms/pseries/papr_scm.c:523:64: note: uninitialized use occurs here
          dev_info(&p->pdev->dev, "nvdimm pmu didn't register rc=%d\n", rc);
                                                                        ^~
  include/linux/dev_printk.h:150:67: note: expanded from macro 'dev_info'
          dev_printk_index_wrap(_dev_info, KERN_INFO, dev, dev_fmt(fmt), ##__VA_ARGS__)
                                                                          ^~~~~~~~~~~
  include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
                  _p_func(dev, fmt, ##__VA_ARGS__);                       \
                                      ^~~~~~~~~~~
  arch/powerpc/platforms/pseries/papr_scm.c:492:2: note: remove the 'if' if its condition is always false
          if (!p->stat_buffer_len)
          ^~~~~~~~~~~~~~~~~~~~~~~~
  arch/powerpc/platforms/pseries/papr_scm.c:484:8: note: initialize the variable 'rc' to silence this warning
          int rc, nodeid;
                ^
                = 0
  1 warning generated.

The call to papr_scm_pmu_check_events() was eliminated but a return code
was not added to the if statement. Add the same return code from
papr_scm_pmu_check_events() for this condition so there is no more
warning.

Fixes: c67b37bbd752 ("powerpc/papr_scm: Fix nvdimm event mappings")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://github.com/ClangBuiltLinux/linux/issues/1701
Link: https://lore.kernel.org/r/20220830151256.1473169-1-nathan@kernel.org
arch/powerpc/platforms/pseries/papr_scm.c

index 54740af21557ce47d3c13ff0329d8c1d3a1bfc72..2f8385523a1320047925af07a7219618a48c60d5 100644 (file)
@@ -489,8 +489,10 @@ static void papr_scm_pmu_register(struct papr_scm_priv *p)
                goto pmu_err_print;
        }
 
-       if (!p->stat_buffer_len)
+       if (!p->stat_buffer_len) {
+               rc = -ENOENT;
                goto pmu_check_events_err;
+       }
 
        nd_pmu->pmu.task_ctx_nr = perf_invalid_context;
        nd_pmu->pmu.name = nvdimm_name(p->nvdimm);