summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEd Tanous <ed.tanous@intel.com>2019-10-24 21:21:38 +0300
committerEd Tanous <ed@tanous.net>2020-08-24 19:51:50 +0300
commit0dfeda6235bde10e0aedd28ba166b9e49b074833 (patch)
treef10af4b212b1c701f6865ec34828927c1075c95e /include
parentd4d77e399526671076936e9d9dd879dad2d24a2f (diff)
downloadbmcweb-0dfeda6235bde10e0aedd28ba166b9e49b074833.tar.xz
Modernize; Move some apis to range based for loop
There were a couple places in code where we still use index based for loops. Move these to the more modern range based for loops. Tested: Needs testing. Changes made by clang-tidy. Signed-off-by: Ed Tanous <ed.tanous@intel.com> Change-Id: I30bf6fae6b2540434d5c98900a8f6bd0c8f2be93
Diffstat (limited to 'include')
-rw-r--r--include/openbmc_dbus_rest.hpp5
-rw-r--r--include/sessions.hpp12
2 files changed, 8 insertions, 9 deletions
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index f049c00915..d66c5f1728 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -744,10 +744,9 @@ inline int convertJsonToDbus(sd_bus_message* m, const std::string& arg_type,
return r;
}
- for (nlohmann::json::const_iterator it = j->begin(); it != j->end();
- ++it)
+ for (const auto& it : *j)
{
- r = convertJsonToDbus(m, containedType, *it);
+ r = convertJsonToDbus(m, containedType, it);
if (r < 0)
{
return r;
diff --git a/include/sessions.hpp b/include/sessions.hpp
index f0de8c9594..e745845d1b 100644
--- a/include/sessions.hpp
+++ b/include/sessions.hpp
@@ -233,9 +233,9 @@ class SessionStore
OpenSSLGenerator gen;
- for (size_t i = 0; i < sessionToken.size(); ++i)
+ for (char& sessionChar : sessionToken)
{
- sessionToken[i] = alphanum[dist(gen)];
+ sessionChar = alphanum[dist(gen)];
if (gen.error())
{
return nullptr;
@@ -244,9 +244,9 @@ class SessionStore
// Only need csrf tokens for cookie based auth, token doesn't matter
std::string csrfToken;
csrfToken.resize(sessionTokenSize, '0');
- for (size_t i = 0; i < csrfToken.size(); ++i)
+ for (char& csrfChar : csrfToken)
{
- csrfToken[i] = alphanum[dist(gen)];
+ csrfChar = alphanum[dist(gen)];
if (gen.error())
{
return nullptr;
@@ -255,9 +255,9 @@ class SessionStore
std::string uniqueId;
uniqueId.resize(10, '0');
- for (size_t i = 0; i < uniqueId.size(); ++i)
+ for (char& uidChar : uniqueId)
{
- uniqueId[i] = alphanum[dist(gen)];
+ uidChar = alphanum[dist(gen)];
if (gen.error())
{
return nullptr;