From 4491a46fb05d1d9c90fed3452157645b339b9dab Mon Sep 17 00:00:00 2001 From: Patrick Venture Date: Sat, 13 Oct 2018 13:00:42 -0700 Subject: cleanup: scope reduction [app/channel.cpp:102]: (style) The scope of the variable 'resp' can be reduced. [ipmisensor.cpp:310]: (style) The scope of the variable 'i' can be reduced. [ipmid.cpp:506]: (style) The scope of the variable 'num_handlers' can be reduced. [read_fru_data.cpp:82]: (style) The scope of the variable 'fruId' can be reduced. [sensorhandler.cpp:256]: (style) The scope of the variable 'p' can be reduced. [storageaddsel.cpp:68]: (style) The scope of the variable 'p' can be reduced. Also delete two extra vertical lines. Change-Id: I8e72f8e1d94381f456674abf523d2f2fbdd8046d Signed-off-by: Patrick Venture --- app/channel.cpp | 19 ++++++++++--------- ipmid.cpp | 3 +-- ipmisensor.cpp | 7 ++----- read_fru_data.cpp | 3 ++- sensorhandler.cpp | 3 +-- storageaddsel.cpp | 2 +- 6 files changed, 17 insertions(+), 20 deletions(-) diff --git a/app/channel.cpp b/app/channel.cpp index 6db987f..8d765c5 100644 --- a/app/channel.cpp +++ b/app/channel.cpp @@ -99,15 +99,6 @@ ipmi_ret_t ipmi_app_channel_info(ipmi_netfn_t netfn, ipmi_cmd_t cmd, ipmi_context_t context) { ipmi_ret_t rc = IPMI_CC_OK; - uint8_t resp[] = {1, - IPMI_CHANNEL_MEDIUM_TYPE_OTHER, - IPMI_CHANNEL_TYPE_IPMB, - 1, - 0x41, - 0xA7, - 0x00, - 0, - 0}; uint8_t* p = (uint8_t*)request; int channel = (*p) & CHANNEL_MASK; std::string ethdevice = ipmi::network::ChanneltoEthernet(channel); @@ -122,6 +113,16 @@ ipmi_ret_t ipmi_app_channel_info(ipmi_netfn_t netfn, ipmi_cmd_t cmd, } else { + uint8_t resp[] = {1, + IPMI_CHANNEL_MEDIUM_TYPE_OTHER, + IPMI_CHANNEL_TYPE_IPMB, + 1, + 0x41, + 0xA7, + 0x00, + 0, + 0}; + *data_len = sizeof(resp); memcpy(response, resp, *data_len); } diff --git a/ipmid.cpp b/ipmid.cpp index 2d48bfe..10b41d4 100644 --- a/ipmid.cpp +++ b/ipmid.cpp @@ -505,7 +505,6 @@ void ipmi_register_callback_handlers(const char* ipmi_lib_path) { // For walking the ipmi_lib_path struct dirent** handler_list; - int num_handlers = 0; // This is used to check and abort if someone tries to register a bad one. void* lib_handler = NULL; @@ -528,7 +527,7 @@ void ipmi_register_callback_handlers(const char* ipmi_lib_path) // already a .so, adding one more is not any harm. handler_fqdn += "/"; - num_handlers = + int num_handlers = scandir(ipmi_lib_path, &handler_list, handler_select, alphasort); if (num_handlers < 0) return; diff --git a/ipmisensor.cpp b/ipmisensor.cpp index 5a629a8..3db1d1b 100644 --- a/ipmisensor.cpp +++ b/ipmisensor.cpp @@ -283,7 +283,6 @@ int findindex(const uint8_t sensor_type, int offset, int* index) bool shouldReport(uint8_t sensorType, int offset, int* index) { - bool rc = false; if (findindex(sensorType, offset, index)) @@ -304,10 +303,9 @@ bool shouldReport(uint8_t sensorType, int offset, int* index) int updateSensorRecordFromSSRAESC(const void* record) { - auto pRec = static_cast(record); uint8_t stype; - int index, i = 0; + int index; stype = find_type_for_sensor_number(pRec->sensor_number); @@ -316,7 +314,6 @@ int updateSensorRecordFromSSRAESC(const void* record) // function if (stype == 0xC3) { - shouldReport(stype, 0x00, &index); reportSensorEventAssert(pRec, index); } @@ -324,7 +321,7 @@ int updateSensorRecordFromSSRAESC(const void* record) { // Scroll through each bit position . Determine // if any bit is either asserted or Deasserted. - for (i = 0; i < 8; i++) + for (int i = 0; i < 8; i++) { if ((ISBITSET(pRec->assert_state7_0, i)) && diff --git a/read_fru_data.cpp b/read_fru_data.cpp index 67bbf9f..ee9ad41 100644 --- a/read_fru_data.cpp +++ b/read_fru_data.cpp @@ -83,7 +83,6 @@ void processFruPropChange(sdbusplus::message::message& msg) for (auto& fru : frus) { bool found = false; - auto& fruId = fru.first; auto& instanceList = fru.second; for (auto& instance : instanceList) { @@ -95,6 +94,8 @@ void processFruPropChange(sdbusplus::message::message& msg) } if (found) { + auto& fruId = fru.first; + cache::fruMap.erase(fruId); break; } diff --git a/sensorhandler.cpp b/sensorhandler.cpp index dca9765..1058230 100644 --- a/sensorhandler.cpp +++ b/sensorhandler.cpp @@ -256,7 +256,6 @@ uint8_t dbus_to_sensor_type(char* p) uint8_t get_type_from_interface(dbus_interface_t dbus_if) { - char* p; uint8_t type; // This is where sensors that do not exist in dbus but do @@ -275,7 +274,7 @@ uint8_t get_type_from_interface(dbus_interface_t dbus_if) else { // Non InventoryItems - p = strrchr(dbus_if.path, '/'); + char* p = strrchr(dbus_if.path, '/'); type = dbus_to_sensor_type(p + 1); } diff --git a/storageaddsel.cpp b/storageaddsel.cpp index 4ed22fc..1dde2a4 100644 --- a/storageaddsel.cpp +++ b/storageaddsel.cpp @@ -65,7 +65,6 @@ int find_sensor_type_string(uint8_t sensor_number, char** s) { dbus_interface_t a; - const char* p; int r; r = find_openbmc_path(sensor_number, &a); @@ -78,6 +77,7 @@ int find_sensor_type_string(uint8_t sensor_number, char** s) } else { + const char* p; if ((p = strrchr(a.path, '/')) == NULL) { -- cgit v1.2.1