Fix some warnings by cppcheck

Warning message:
../../../occ_events.hpp:16:9: warning: Value stored to 'event' is never read [deadcode.DeadStores]
        event = sd_event_unref(event);
        ^       ~~~~~~~~~~~~~~~~~~~~~
../../../occ_events.hpp:26:9: warning: Value stored to 'eventSource' is never read [deadcode.DeadStores]
        eventSource = sd_event_source_unref(eventSource);

occ_dbus.cpp:34:47: performance: Searching before insertion is not necessary. [stlFindInsert]
            path, std::make_unique<SensorIntf>(utils::getBus(), path.c_str()));
                                              ^
occ_dbus.cpp:61:47: performance: Searching before insertion is not necessary. [stlFindInsert]
            path, std::make_unique<SensorIntf>(utils::getBus(), path.c_str()));
                                              ^
occ_dbus.cpp:88:47: performance: Searching before insertion is not necessary. [stlFindInsert]
            path, std::make_unique<SensorIntf>(utils::getBus(), path.c_str()));
                                              ^
occ_dbus.cpp:115:47: performance: Searching before insertion is not necessary. [stlFindInsert]
            path, std::make_unique<SensorIntf>(utils::getBus(), path.c_str()));
                                              ^
occ_dbus.cpp:158:80: performance: Searching before insertion is not necessary. [stlFindInsert]
        operationalStatus.emplace(path, std::make_unique<OperationalStatusIntf>(
                                                                               ^
occ_pass_through.hpp:42:5: style: Class 'PassThrough' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
    PassThrough(const char* path);
    ^
powercap.hpp:41:5: style: Class 'PowerCap' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
    PowerCap(Status& occStatus,
    ^
occ_manager.hpp:77:5: style: Struct 'Manager' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
    Manager(EventPtr& event) :
    ^
occ_status.hpp:307:26: style: Local variable 'path' shadows outer variable [shadowVariable]
                    auto path = fs::path(estimatedPath);
                         ^
occ_status.hpp:207:17: note: Shadowed declaration
    std::string path;
                ^
occ_status.hpp:307:26: note: Shadow variable
                    auto path = fs::path(estimatedPath);
                         ^
pldm.hpp:55:14: warning: Member variable 'Interface::OCCSensorOffset' is not initialized in the constructor. [uninitMemberVar]
    explicit Interface(
             ^
pldm.hpp:55:14: warning: Member variable 'Interface::SBESensorOffset' is not initialized in the constructor. [uninitMemberVar]
    explicit Interface(
             ^
powermode.hpp:60:5: style: Class 'PowerMode' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
    PowerMode(Status& occStatus) :
    ^
powermode.hpp:96:5: style: Class 'PowerIPS' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
    PowerIPS(Status& occStatus) :
    ^
occ_manager.cpp:321:24: style: The scope of the variable 'path' can be reduced. [variableScope]
        constexpr auto path = "/org/openpower/dump";
                       ^
occ_manager.cpp:322:24: style: The scope of the variable 'interface' can be reduced. [variableScope]
        constexpr auto interface = "xyz.openbmc_project.Dump.Create";
                       ^
occ_manager.cpp:323:24: style: The scope of the variable 'function' can be reduced. [variableScope]
        constexpr auto function = "CreateDump";
                       ^
pldm.cpp:78:16: style: Local variable 'pdr' shadows outer variable [shadowVariable]
    for (auto& pdr : pdrs)
               ^
pldm.cpp:48:10: note: Shadowed declaration
    auto pdr =
         ^
pldm.cpp:78:16: note: Shadow variable
    for (auto& pdr : pdrs)
               ^
pldm.cpp:248:16: style: Local variable 'pdr' shadows outer variable [shadowVariable]
    for (auto& pdr : pdrs)
               ^
pldm.cpp:221:10: note: Shadowed declaration
    auto pdr =
         ^
pldm.cpp:248:16: note: Shadow variable
    for (auto& pdr : pdrs)
               ^
powermode.cpp:28:22: style: Variable 'pmode' is assigned a value that is never used. [unreadVariable]
    SysPwrMode pmode = SysPwrMode::NO_CHANGE;

Tested: Use cppcheck to build successfully and eliminate the above
warning message.

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I72751dc94db684fc558b4bb57b1924be64ce6760
12 files changed