lib: sbi: Resolve the uninitialized complaint in sbi_pmu
authorDong Du <Dd_nirvana@sjtu.edu.cn>
Thu, 25 Nov 2021 10:38:17 +0000 (18:38 +0800)
committerAnup Patel <anup@brainfault.org>
Tue, 30 Nov 2021 05:10:35 +0000 (10:40 +0530)
A recent commit (b28f0700) turns to read from CSR_MCOUNTINHIBIT after
checking the SBI_HART_HAS_MCOUNTINHIBIT HART feature, which leaves the
mctr_inhbt uninitialized in pmu_ctr_find_hw().
As a result, compiler will complain:
error: 'mctr_inhbt' may be used uninitialized in this function.

This commit resolves the issue by assigning an initial value to mctr_inhbt.

Signed-off-by: Dong Du <Dd_nirvana@sjtu.edu.cn>
Reviewed-by: Xiang W <wxjstz@126.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
lib/sbi/sbi_pmu.c

index a0eb359..5950a20 100644 (file)
@@ -489,7 +489,7 @@ static int pmu_ctr_find_hw(unsigned long cbase, unsigned long cmask, unsigned lo
        unsigned long ctr_mask;
        int i, ret = 0, fixed_ctr, ctr_idx = SBI_ENOTSUPP;
        struct sbi_pmu_hw_event *temp;
-       unsigned long mctr_inhbt;
+       unsigned long mctr_inhbt = 0;
        u32 hartid = current_hartid();
        struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();