[Libreoffice-commits] core.git: 2 commits - xmloff/source xmlsecurity/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Oct 20 17:54:30 UTC 2018


 xmloff/source/style/xmlexppr.cxx                       |    6 ---
 xmloff/source/style/xmlnumfe.cxx                       |    8 ++--
 xmloff/source/style/xmlnumfi.cxx                       |   32 ++++++-----------
 xmloff/source/style/xmlnumi.cxx                        |    5 --
 xmloff/source/text/txtparai.cxx                        |   10 ++---
 xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx |    7 +--
 6 files changed, 25 insertions(+), 43 deletions(-)

New commits:
commit 2efbeea3f2625f62e08e78789de25ca5783d5e5d
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Oct 19 16:39:06 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Sat Oct 20 19:54:20 2018 +0200

    pvs-studio: loop-variable-too-small
    
    Change-Id: Ie4aafecd17cf53ab3cbab2003b59da374d06e06b
    Reviewed-on: https://gerrit.libreoffice.org/62058
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/xmloff/source/style/xmlexppr.cxx b/xmloff/source/style/xmlexppr.cxx
index 4f8292ed26dd..5cb4f9b02e1d 100644
--- a/xmloff/source/style/xmlexppr.cxx
+++ b/xmloff/source/style/xmlexppr.cxx
@@ -999,13 +999,9 @@ void SvXMLExportPropertyMapper::exportElementItems(
         SvXmlExportFlags nFlags,
         const std::vector<sal_uInt16>& rIndexArray ) const
 {
-    const sal_uInt16 nCount = rIndexArray.size();
-
     bool bItemsExported = false;
-    for( sal_uInt16 nIndex = 0; nIndex < nCount; nIndex++ )
+    for (const sal_uInt16 nElement : rIndexArray)
     {
-        const sal_uInt16 nElement = rIndexArray[nIndex];
-
         OSL_ENSURE( 0 != (mpImpl->mxPropMapper->GetEntryFlags(
                 rProperties[nElement].mnIndex ) & MID_FLAG_ELEMENT_ITEM_EXPORT),
                 "wrong mid flag!" );
diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx
index b83ae01fb358..81df9f5262a9 100644
--- a/xmloff/source/style/xmlnumfe.cxx
+++ b/xmloff/source/style/xmlnumfe.cxx
@@ -601,8 +601,8 @@ void SvXMLNumFmtExport::WriteNumberElement_Impl(
 
     //  number:embedded-text as child elements
 
-    sal_uInt16 nEntryCount = rEmbeddedEntries.size();
-    for (sal_uInt16 nEntry=0; nEntry<nEntryCount; nEntry++)
+    auto nEntryCount = rEmbeddedEntries.size();
+    for (decltype(nEntryCount) nEntry=0; nEntry < nEntryCount; ++nEntry)
     {
         const SvXMLEmbeddedTextEntry *const pObj = &rEmbeddedEntries[nEntry];
 
@@ -953,8 +953,8 @@ static OUString lcl_GetDefaultCalendar( SvNumberFormatter const * pFormatter, La
 
 static bool lcl_IsInEmbedded( const SvXMLEmbeddedTextEntryArr& rEmbeddedEntries, sal_uInt16 nPos )
 {
-    sal_uInt16 nCount = rEmbeddedEntries.size();
-    for (sal_uInt16 i=0; i<nCount; i++)
+    auto nCount = rEmbeddedEntries.size();
+    for (decltype(nCount) i=0; i<nCount; i++)
         if ( rEmbeddedEntries[i].nSourcePos == nPos )
             return true;
 
diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx
index 7afd4391e4a7..a3039cd51518 100644
--- a/xmloff/source/style/xmlnumfi.cxx
+++ b/xmloff/source/style/xmlnumfi.cxx
@@ -356,12 +356,10 @@ SvXMLNumImpData::SvXMLNumImpData(
 
 sal_uInt32 SvXMLNumImpData::GetKeyForName( const OUString& rName )
 {
-    sal_uInt16 nCount = m_NameEntries.size();
-    for (sal_uInt16 i=0; i<nCount; i++)
+    for (const auto& rObj : m_NameEntries)
     {
-        const SvXMLNumFmtEntry *const pObj = &m_NameEntries[i];
-        if ( pObj->aName == rName )
-            return pObj->nKey;              // found
+        if (rObj.aName == rName)
+            return rObj.nKey;              // found
     }
     return NUMBERFORMAT_ENTRY_NOT_FOUND;
 }
@@ -373,11 +371,9 @@ void SvXMLNumImpData::AddKey( sal_uInt32 nKey, const OUString& rName, bool bRemo
         //  if there is already an entry for this key without the bRemoveAfterUse flag,
         //  clear the flag for this entry, too
 
-        sal_uInt16 nCount = m_NameEntries.size();
-        for (sal_uInt16 i=0; i<nCount; i++)
+        for (const auto& rObj : m_NameEntries)
         {
-            SvXMLNumFmtEntry *const pObj = &m_NameEntries[i];
-            if ( pObj->nKey == nKey && !pObj->bRemoveAfterUse )
+            if (rObj.nKey == nKey && !rObj.bRemoveAfterUse)
             {
                 bRemoveAfterUse = false;        // clear flag for new entry
                 break;
@@ -395,13 +391,11 @@ void SvXMLNumImpData::AddKey( sal_uInt32 nKey, const OUString& rName, bool bRemo
 
 void SvXMLNumImpData::SetUsed( sal_uInt32 nKey )
 {
-    sal_uInt16 nCount = m_NameEntries.size();
-    for (sal_uInt16 i=0; i<nCount; i++)
+    for (auto& rObj : m_NameEntries)
     {
-        SvXMLNumFmtEntry *const pObj = &m_NameEntries[i];
-        if ( pObj->nKey == nKey )
+        if (rObj.nKey == nKey)
         {
-            pObj->bRemoveAfterUse = false;      // used -> don't remove
+            rObj.bRemoveAfterUse = false;      // used -> don't remove
 
             //  continue searching - there may be several entries for the same key
             //  (with different names), the format must not be deleted if any one of
@@ -419,15 +413,13 @@ void SvXMLNumImpData::RemoveVolatileFormats()
     if ( !pFormatter )
         return;
 
-    sal_uInt16 nCount = m_NameEntries.size();
-    for (sal_uInt16 i=0; i<nCount; i++)
+    for (const auto& rObj : m_NameEntries)
     {
-        const SvXMLNumFmtEntry *const pObj = &m_NameEntries[i];
-        if ( pObj->bRemoveAfterUse )
+        if (rObj.bRemoveAfterUse )
         {
-            const SvNumberformat* pFormat = pFormatter->GetEntry(pObj->nKey);
+            const SvNumberformat* pFormat = pFormatter->GetEntry(rObj.nKey);
             if (pFormat && (pFormat->GetType() & SvNumFormatType::DEFINED))
-                pFormatter->DeleteEntry( pObj->nKey );
+                pFormatter->DeleteEntry(rObj.nKey);
         }
     }
 }
diff --git a/xmloff/source/style/xmlnumi.cxx b/xmloff/source/style/xmlnumi.cxx
index 3b60ce724f19..6b36f2edccd2 100644
--- a/xmloff/source/style/xmlnumi.cxx
+++ b/xmloff/source/style/xmlnumi.cxx
@@ -1062,12 +1062,9 @@ void SvxXMLListStyleContext::FillUnoNumRule(
     {
         if( pLevelStyles && rNumRule.is() )
         {
-            sal_uInt16 nCount = pLevelStyles->size();
             sal_Int32 l_nLevels = rNumRule->getCount();
-            for( sal_uInt16 i=0; i < nCount; i++ )
+            for (const auto& pLevelStyle : *pLevelStyles)
             {
-                SvxXMLListLevelStyleContext_Impl *pLevelStyle =
-                    (*pLevelStyles)[i].get();
                 sal_Int32 nLevel = pLevelStyle->GetLevel();
                 if( nLevel >= 0 && nLevel < l_nLevels )
                 {
diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx
index 9134fe01cffb..48d28cd1df7c 100644
--- a/xmloff/source/text/txtparai.cxx
+++ b/xmloff/source/text/txtparai.cxx
@@ -274,10 +274,9 @@ XMLEndReferenceContext_Impl::XMLEndReferenceContext_Impl(
     if (XMLStartReferenceContext_Impl::FindName(GetImport(), xAttrList, sName))
     {
         // search for reference start
-        sal_uInt16 nCount = rHints.GetHints().size();
-        for(sal_uInt16 nPos = 0; nPos < nCount; nPos++)
+        for (const auto& rHintPtr : rHints.GetHints())
         {
-            XMLHint_Impl *const pHint = rHints.GetHints()[nPos].get();
+            XMLHint_Impl *const pHint = rHintPtr.get();
             if ( pHint->IsReference() &&
                  sName == static_cast<XMLReferenceHint_Impl *>(pHint)->GetRefName() )
             {
@@ -1099,10 +1098,9 @@ void XMLIndexMarkImportContext_Impl::StartElement(
             if (!sID.isEmpty())
             {
                 // if we have an ID, find the hint and set the end position
-                sal_uInt16 nCount = m_rHints.GetHints().size();
-                for(sal_uInt16 nPos = 0; nPos < nCount; nPos++)
+                for (const auto& rHintPtr : m_rHints.GetHints())
                 {
-                    XMLHint_Impl *const pHint = m_rHints.GetHints()[nPos].get();
+                    XMLHint_Impl *const pHint = rHintPtr.get();
                     if ( pHint->IsIndexMark() &&
                          sID == static_cast<XMLIndexMarkHint_Impl *>(pHint)->GetID() )
                     {
commit 5e8911efab74eb2519eb8ba8301b282b232c2d00
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Oct 19 16:19:58 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Sat Oct 20 19:54:08 2018 +0200

    pvs-studio: A part of conditional expression is always true: bCertValid.
    
    Change-Id: Ia70f28fece45c84b4a460e379c5447818818e114
    Reviewed-on: https://gerrit.libreoffice.org/62054
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
index 98f9bd1da127..689303e9355a 100644
--- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
+++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
@@ -645,20 +645,19 @@ void DigitalSignaturesDialog::ImplFillSignaturesBox()
             // If there is no storage, then it's pointless to check storage
             // stream references.
             else if (maSignatureManager.meSignatureMode == DocumentSignatureMode::Content
-                && bCertValid && (maSignatureManager.mxStore.is() && !DocumentSignatureHelper::isOOo3_2_Signature(
+                && (maSignatureManager.mxStore.is() && !DocumentSignatureHelper::isOOo3_2_Signature(
                 maSignatureManager.maCurrentSignatureInformations[n])))
             {
                 aImage = m_pSigsNotvalidatedImg->GetImage();
                 bAllNewSignatures = false;
             }
             else if (maSignatureManager.meSignatureMode == DocumentSignatureMode::Content
-                && bCertValid && DocumentSignatureHelper::isOOo3_2_Signature(
+                && DocumentSignatureHelper::isOOo3_2_Signature(
                 maSignatureManager.maCurrentSignatureInformations[n]))
             {
                 aImage = m_pSigsValidImg->GetImage();
             }
-            else if (maSignatureManager.meSignatureMode == DocumentSignatureMode::Macros
-                && bCertValid)
+            else if (maSignatureManager.meSignatureMode == DocumentSignatureMode::Macros)
             {
                 aImage = m_pSigsValidImg->GetImage();
             }


More information about the Libreoffice-commits mailing list