diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2018-08-15 21:32:27 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-20 17:12:11 +0200 |
commit | 0787ce8814e37972a0c968f60008d4e8722b6e27 (patch) | |
tree | 9d2803ebda8813e6b3f2bc2e6f8a74953b2931c1 /xmlsecurity/source/xmlsec/nss | |
parent | d2c9c60fefb9687adbde4be61ed66a5123a2587f (diff) |
Simplify containers iterations, tdf#96099 follow-up
Use range-based loop or replace with std::any_of, std::find and
std::find_if where applicable.
Change-Id: I2f80788c49d56094c29b102eb96a7a7c079567c6
Reviewed-on: https://gerrit.libreoffice.org/59143
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmlsecurity/source/xmlsec/nss')
-rw-r--r-- | xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx index 7fb84e177dfa..3f928b05bcc8 100644 --- a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx +++ b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx @@ -113,9 +113,9 @@ SecurityEnvironment_NssImpl::~SecurityEnvironment_NssImpl() { PK11_SetPasswordFunc( nullptr ) ; - for (auto i = m_Slots.cbegin(); i != m_Slots.cend(); i++) + for (auto& slot : m_Slots) { - PK11_FreeSlot(*i); + PK11_FreeSlot(slot); } if( !m_tSymKeyList.empty() ) { @@ -185,9 +185,9 @@ const Sequence< sal_Int8>& SecurityEnvironment_NssImpl::getUnoTunnelId() { OUString SecurityEnvironment_NssImpl::getSecurityEnvironmentInformation() { OUStringBuffer buff; - for (auto is = m_Slots.cbegin(); is != m_Slots.cend(); ++is) + for (auto& slot : m_Slots) { - buff.append(OUString::createFromAscii(PK11_GetTokenName(*is))); + buff.append(OUString::createFromAscii(PK11_GetTokenName(slot))); buff.append("\n"); } return buff.makeStringAndClear(); @@ -291,9 +291,8 @@ SecurityEnvironment_NssImpl::getPersonalCertificates() updateSlots(); //firstly, we try to find private keys in slot - for (auto is = m_Slots.cbegin(); is != m_Slots.cend(); ++is) + for (auto& slot : m_Slots) { - PK11SlotInfo *slot = *is; SECKEYPrivateKeyList* priKeyList ; if( PK11_NeedLogin(slot ) ) { @@ -765,9 +764,9 @@ sal_Int32 SecurityEnvironment_NssImpl::getCertificateCharacters( } if(priKey == nullptr) { - for (auto is = m_Slots.cbegin(); is != m_Slots.cend(); ++is) + for (auto& slot : m_Slots) { - priKey = PK11_FindPrivateKeyFromCert(*is, const_cast<CERTCertificate*>(cert), nullptr); + priKey = PK11_FindPrivateKeyFromCert(slot, const_cast<CERTCertificate*>(cert), nullptr); if (priKey) break; } @@ -832,8 +831,11 @@ xmlSecKeysMngrPtr SecurityEnvironment_NssImpl::createKeysManager() { std::unique_ptr<PK11SlotInfo*[]> sarSlots(new PK11SlotInfo*[cSlots]); PK11SlotInfo** slots = sarSlots.get(); int count = 0; - for (auto islots = m_Slots.cbegin();islots != m_Slots.cend(); ++islots, ++count) - slots[count] = *islots; + for (auto& slot : m_Slots) + { + slots[count] = slot; + ++count; + } xmlSecKeysMngrPtr pKeysMngr = xmlSecKeysMngrCreate(); if (!pKeysMngr) |