summaryrefslogtreecommitdiffstats
path: root/read_fru_data.cpp
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2018-10-22 14:57:36 -0700
committerEmily Shaffer <emilyshaffer@google.com>2018-11-07 19:19:46 +0000
commitb0431c79872ad7d9ca9fcf543a769ef233f8c94c (patch)
tree7fafc0ed4658e016a95eea800b42e30fda2d9d08 /read_fru_data.cpp
parent98c7bfc12852370c03370d5cba088474aa166254 (diff)
downloadphosphor-host-ipmid-b0431c79872ad7d9ca9fcf543a769ef233f8c94c.tar.gz
phosphor-host-ipmid-b0431c79872ad7d9ca9fcf543a769ef233f8c94c.zip
read_fru_data: use std::find_if instead of raw loop
Use std::find_if to find matching item instead of using a raw loop. Change-Id: I1814d66dc8c6b33cb8ea12317105dfa70c47fe60 Signed-off-by: Patrick Venture <venture@google.com>
Diffstat (limited to 'read_fru_data.cpp')
-rw-r--r--read_fru_data.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/read_fru_data.cpp b/read_fru_data.cpp
index ee9ad41..4723308 100644
--- a/read_fru_data.cpp
+++ b/read_fru_data.cpp
@@ -6,6 +6,7 @@
#include <host-ipmid/ipmid-api.h>
+#include <algorithm>
#include <map>
#include <phosphor-logging/elog-errors.hpp>
#include <sdbusplus/message/types.hpp>
@@ -82,17 +83,13 @@ void processFruPropChange(sdbusplus::message::message& msg)
}
for (auto& fru : frus)
{
- bool found = false;
auto& instanceList = fru.second;
- for (auto& instance : instanceList)
- {
- if (instance.path == path)
- {
- found = true;
- break;
- }
- }
- if (found)
+
+ auto found = std::find_if(
+ instanceList.begin(), instanceList.end(),
+ [&path](const auto& iter) { return (iter.path == path); });
+
+ if (found != instanceList.end())
{
auto& fruId = fru.first;
OpenPOWER on IntegriCloud