Bug 229955 - src/sys/dev/hwpmc/hwpmc_core.c:146]: (error) Uninitialized struct member: cc.pc_corepmcs
Summary: src/sys/dev/hwpmc/hwpmc_core.c:146]: (error) Uninitialized struct member: cc....
Status: Closed Not A Bug
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-22 08:32 UTC by David Binderman
Modified: 2018-07-22 18:53 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2018-07-22 08:32:49 UTC
Source code is

        cc = malloc(sizeof(struct core_cpu) + npmc * sizeof(struct pmc_hw),
            M_PMC, M_WAITOK | M_ZERO);

        ...

        for (n = 0, phw = cc->pc_corepmcs; n < npmc; n++, phw++) {
Comment 1 Conrad Meyer freebsd_committer freebsd_triage 2018-07-22 15:28:23 UTC
That's not uninitialized.  See M_ZERO.  I don't know what static analysis tool you're copying these reports from, but without basic triage the reports are more or less useless.
Comment 2 Andriy Gapon freebsd_committer freebsd_triage 2018-07-22 18:53:11 UTC
(In reply to Conrad Meyer from comment #1)
M_ZERO is even irrelevant here:
struct core_cpu {
        volatile uint32_t       pc_resync;
        volatile uint32_t       pc_iafctrl;     /* Fixed function control. */
        volatile uint64_t       pc_globalctrl;  /* Global control register. */
        struct pmc_hw           pc_corepmcs[];
};

Initial value of phw is the first element of pc_corepmcs.