diff options
author | Manojkiran Eda <manojkiran.eda@gmail.com> | 2020-09-12 13:01:58 +0300 |
---|---|---|
committer | ManojKiran Eda <manojkiran.eda@gmail.com> | 2020-11-02 06:41:47 +0300 |
commit | 17a897df9fd974e7b7b15fe61c9e59179c7b9fca (patch) | |
tree | 0de904ff7e3fd39e883e19e651bc163f0dd5eac2 /redfish-core/lib/ethernet.hpp | |
parent | 313efb1c9afcb0192585579a663467c28f873286 (diff) | |
download | bmcweb-17a897df9fd974e7b7b15fe61c9e59179c7b9fca.tar.xz |
Improve loops & fix cpp check warning
- This commit improves certain while loops to range based for loops.
- This commit also fixes the cppcheck warning that mentions about
performance issues when using postfix operators on non-primitive
types.
Tested By:
- A function is unittested.
- GET on both EthernetInterfaces & certificate service
looks good without any issues.
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
Change-Id: I85420f7bf9af45a97e1a93b916f292c2516f5802
Diffstat (limited to 'redfish-core/lib/ethernet.hpp')
-rw-r--r-- | redfish-core/lib/ethernet.hpp | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp index 55f1cf50ea..48b69a22fe 100644 --- a/redfish-core/lib/ethernet.hpp +++ b/redfish-core/lib/ethernet.hpp @@ -1375,34 +1375,26 @@ class EthernetInterface : public Node boost::container::flat_set<IPv4AddressData>::const_iterator getNextStaticIpEntry( - boost::container::flat_set<IPv4AddressData>::const_iterator head, + const boost::container::flat_set<IPv4AddressData>::const_iterator& + head, const boost::container::flat_set<IPv4AddressData>::const_iterator& end) { - for (; head != end; head++) - { - if (head->origin == "Static") - { - return head; - } - } - return end; + return std::find_if(head, end, [](const IPv4AddressData& value) { + return value.origin == "Static"; + }); } boost::container::flat_set<IPv6AddressData>::const_iterator getNextStaticIpEntry( - boost::container::flat_set<IPv6AddressData>::const_iterator head, + const boost::container::flat_set<IPv6AddressData>::const_iterator& + head, const boost::container::flat_set<IPv6AddressData>::const_iterator& end) { - for (; head != end; head++) - { - if (head->origin == "Static") - { - return head; - } - } - return end; + return std::find_if(head, end, [](const IPv6AddressData& value) { + return value.origin == "Static"; + }); } void handleIPv4StaticPatch( |