summaryrefslogtreecommitdiff
path: root/xmlsecurity/source/xmlsec
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2018-09-11 23:18:20 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-09-12 21:54:06 +0200
commit8d5779bef3cb36f0db6f61b6a9f711796d487d9d (patch)
treed3caf43c323e37c14cd566ae718fd1e85e883795 /xmlsecurity/source/xmlsec
parent3778399872ad592b4416e54a154e8bcc02d73a2e (diff)
Simplify containers iterations in xmlsecurity
Use range-based loop or replace with functions from std algorithm. Change-Id: I0146186b7c42405076dfce7de7805be4228cc6d3 Reviewed-on: https://gerrit.libreoffice.org/60360 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmlsecurity/source/xmlsec')
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx8
-rw-r--r--xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx45
2 files changed, 20 insertions, 33 deletions
diff --git a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx
index 81617fc845c7..cc1ea218d844 100644
--- a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx
+++ b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx
@@ -384,12 +384,12 @@ uno::Sequence< uno::Reference < XCertificate > > SecurityEnvironment_MSCryptImpl
length = certsList.size() ;
if( length != 0 ) {
- int i ;
- std::list< X509Certificate_MSCryptImpl* >::iterator xcertIt ;
+ int i = 0;
uno::Sequence< uno::Reference< XCertificate > > certSeq( length ) ;
- for( i = 0, xcertIt = certsList.begin(); xcertIt != certsList.end(); ++xcertIt, ++i ) {
- certSeq[i] = *xcertIt ;
+ for( const auto& rXCert : certsList ) {
+ certSeq[i] = rXCert ;
+ ++i;
}
return certSeq ;
diff --git a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
index 7e19c995ae88..7ccc70c85955 100644
--- a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
@@ -120,24 +120,18 @@ SecurityEnvironment_NssImpl::~SecurityEnvironment_NssImpl() {
}
if( !m_tSymKeyList.empty() ) {
- std::list< PK11SymKey* >::iterator symKeyIt ;
-
- for( symKeyIt = m_tSymKeyList.begin() ; symKeyIt != m_tSymKeyList.end() ; ++symKeyIt )
- PK11_FreeSymKey( *symKeyIt ) ;
+ for( auto& symKey : m_tSymKeyList )
+ PK11_FreeSymKey( symKey ) ;
}
if( !m_tPubKeyList.empty() ) {
- std::list< SECKEYPublicKey* >::iterator pubKeyIt ;
-
- for( pubKeyIt = m_tPubKeyList.begin() ; pubKeyIt != m_tPubKeyList.end() ; ++pubKeyIt )
- SECKEY_DestroyPublicKey( *pubKeyIt ) ;
+ for( auto& pubKeyIt : m_tPubKeyList )
+ SECKEY_DestroyPublicKey( pubKeyIt ) ;
}
if( !m_tPriKeyList.empty() ) {
- std::list< SECKEYPrivateKey* >::iterator priKeyIt ;
-
- for( priKeyIt = m_tPriKeyList.begin() ; priKeyIt != m_tPriKeyList.end() ; ++priKeyIt )
- SECKEY_DestroyPrivateKey( *priKeyIt ) ;
+ for( auto& priKey : m_tPriKeyList )
+ SECKEY_DestroyPrivateKey( priKey ) ;
}
}
@@ -206,14 +200,10 @@ void SecurityEnvironment_NssImpl::setCertDb( CERTCertDBHandle* aCertDb ) {
}
void SecurityEnvironment_NssImpl::adoptSymKey( PK11SymKey* aSymKey ) {
- std::list< PK11SymKey* >::iterator keyIt ;
-
if( aSymKey != nullptr ) {
//First try to find the key in the list
- for( keyIt = m_tSymKeyList.begin() ; keyIt != m_tSymKeyList.end() ; ++keyIt ) {
- if( *keyIt == aSymKey )
- return ;
- }
+ if (std::find(m_tSymKeyList.begin(), m_tSymKeyList.end(), aSymKey) != m_tSymKeyList.end())
+ return;
//If we do not find the key in the list, add a new node
PK11SymKey* symkey = PK11_ReferenceSymKey( aSymKey ) ;
@@ -325,10 +315,8 @@ SecurityEnvironment_NssImpl::getPersonalCertificates()
//secondly, we try to find certificate from registered private keys.
if( !m_tPriKeyList.empty() ) {
- std::list< SECKEYPrivateKey* >::iterator priKeyIt ;
-
- for( priKeyIt = m_tPriKeyList.begin() ; priKeyIt != m_tPriKeyList.end() ; ++priKeyIt ) {
- xcert = NssPrivKeyToXCert( *priKeyIt ) ;
+ for( const auto& priKey : m_tPriKeyList ) {
+ xcert = NssPrivKeyToXCert( priKey ) ;
if( xcert != nullptr )
certsList.push_back( xcert ) ;
}
@@ -336,12 +324,12 @@ SecurityEnvironment_NssImpl::getPersonalCertificates()
length = certsList.size() ;
if( length != 0 ) {
- int i ;
- std::list< X509Certificate_NssImpl* >::iterator xcertIt ;
+ int i = 0;
Sequence< Reference< XCertificate > > certSeq( length ) ;
- for( i = 0, xcertIt = certsList.begin(); xcertIt != certsList.end(); ++xcertIt, ++i ) {
- certSeq[i] = *xcertIt ;
+ for( const auto& rXCert : certsList ) {
+ certSeq[i] = rXCert ;
+ ++i;
}
return certSeq ;
@@ -712,11 +700,10 @@ verifyCertificate( const Reference< csss::XCertificate >& aCert,
}
//Destroying the temporary certificates
- std::vector<CERTCertificate*>::const_iterator cert_i;
- for (cert_i = vecTmpNSSCertificates.begin(); cert_i != vecTmpNSSCertificates.end(); ++cert_i)
+ for (auto& tmpCert : vecTmpNSSCertificates)
{
SAL_INFO("xmlsecurity.xmlsec", "Destroying temporary certificate");
- CERT_DestroyCertificate(*cert_i);
+ CERT_DestroyCertificate(tmpCert);
}
return validity ;
}