summaryrefslogtreecommitdiffstats
path: root/storageaddsel.cpp
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2018-10-13 13:51:06 -0700
committerPatrick Venture <venture@google.com>2018-10-17 23:18:55 +0000
commit2e63352fe8893a65e45690402d8681644b572e12 (patch)
tree8c0ca39736b4385dbd0ae6af34981c753425dadf /storageaddsel.cpp
parent64678b853377d60b2ff3129d087ad68df8e2bce7 (diff)
downloadphosphor-host-ipmid-2e63352fe8893a65e45690402d8681644b572e12.tar.gz
phosphor-host-ipmid-2e63352fe8893a65e45690402d8681644b572e12.zip
cleanup: transition to find_if
[utils.cpp:81]: (style) Consider using std::find_if algorithm instead of a raw loop. [storageaddsel.cpp:170]: (style) Consider using std::find_if algorithm instead of a raw loop. Change-Id: I7ebbb6428fbbae9196912837d2ac9820420b77df Signed-off-by: Patrick Venture <venture@google.com>
Diffstat (limited to 'storageaddsel.cpp')
-rw-r--r--storageaddsel.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/storageaddsel.cpp b/storageaddsel.cpp
index 41f813c..4ed22fc 100644
--- a/storageaddsel.cpp
+++ b/storageaddsel.cpp
@@ -151,11 +151,9 @@ Entry::Level create_esel_severity(const uint8_t* buffer)
int create_esel_association(const uint8_t* buffer, std::string& inventoryPath)
{
- uint8_t sensor;
-
auto p = reinterpret_cast<const ipmi_add_sel_request_t*>(buffer);
- sensor = p->sensornumber;
+ uint8_t sensor = p->sensornumber;
inventoryPath = {};
@@ -163,13 +161,13 @@ int create_esel_association(const uint8_t* buffer, std::string& inventoryPath)
* Search the sensor number to inventory path mapping to figure out the
* inventory associated with the ESEL.
*/
- for (auto const& iter : invSensors)
+ auto found = std::find_if(invSensors.begin(), invSensors.end(),
+ [&sensor](const auto& iter) {
+ return (iter.second.sensorID == sensor);
+ });
+ if (found != invSensors.end())
{
- if (iter.second.sensorID == sensor)
- {
- inventoryPath = iter.first;
- break;
- }
+ inventoryPath = found->first;
}
return 0;
OpenPOWER on IntegriCloud