From 0dfeda6235bde10e0aedd28ba166b9e49b074833 Mon Sep 17 00:00:00 2001 From: Ed Tanous Date: Thu, 24 Oct 2019 11:21:38 -0700 Subject: 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 Change-Id: I30bf6fae6b2540434d5c98900a8f6bd0c8f2be93 --- include/sessions.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include/sessions.hpp') 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; -- cgit v1.2.3