[Libreoffice-commits] core.git: chart2/source formula/source oox/source sc/source sw/source

Julien Nabet serval2412 at yahoo.fr
Sun Apr 16 08:37:30 UTC 2017


 chart2/source/view/charttypes/Splines.cxx |    4 ++--
 formula/source/core/api/token.cxx         |    2 +-
 oox/source/export/drawingml.cxx           |    2 +-
 sc/source/core/data/table1.cxx            |    4 ++--
 sc/source/core/data/table2.cxx            |    2 +-
 sc/source/core/tool/interpr8.cxx          |   12 ++++++------
 sw/source/core/access/accpara.cxx         |    2 +-
 7 files changed, 14 insertions(+), 14 deletions(-)

New commits:
commit 22c775b05b37a89e8d64e36d1ec2fb5dfbfa5259
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Sun Apr 16 09:14:39 2017 +0200

    cppcheck: arrayIndexThenCheck
    
    Change-Id: Ie3ca646fae94ff5a06a29fc2823a1cacafc3deb1
    Reviewed-on: https://gerrit.libreoffice.org/36575
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>
    Tested-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/chart2/source/view/charttypes/Splines.cxx b/chart2/source/view/charttypes/Splines.cxx
index ca8051155164..b3cd9a77c67f 100644
--- a/chart2/source/view/charttypes/Splines.cxx
+++ b/chart2/source/view/charttypes/Splines.cxx
@@ -379,8 +379,8 @@ double lcl_SplineCalculation::GetInterpolatedValue( double x )
     }
     else
     {
-        while( ( m_aPoints[ m_nKHigh ].first < x ) &&
-               ( m_nKHigh <= n ) )
+        while( ( m_nKHigh <= n ) &&
+               ( m_aPoints[ m_nKHigh ].first < x ) )
         {
             ++m_nKHigh;
             ++m_nKLow;
diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx
index 45031ef42ad9..ac7af181046a 100644
--- a/formula/source/core/api/token.cxx
+++ b/formula/source/core/api/token.cxx
@@ -615,7 +615,7 @@ FormulaToken* FormulaTokenArray::PeekNextNoSpaces()
     if( pCode && nIndex < nLen )
     {
         sal_uInt16 j = nIndex;
-        while ( pCode[j]->GetOpCode() == ocSpaces && j < nLen )
+        while ( j < nLen && pCode[j]->GetOpCode() == ocSpaces )
             j++;
         if ( j < nLen )
             return pCode[ j ];
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 393936cab94f..c59a2bfbf638 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2354,7 +2354,7 @@ void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, bool b
                 {
                     // If the document model doesn't have an adjustment name (e.g. shape was created from VML), then take it from the predefined list.
                     OString aAdjName;
-                    if (aAdjustmentSeq[i].Name.isEmpty() && static_cast<sal_uInt32>(i) < aAdjustments.size())
+                    if (static_cast<sal_uInt32>(i) < aAdjustments.size() && aAdjustmentSeq[i].Name.isEmpty())
                         aAdjName = aAdjustments[i];
 
                     mpFS->singleElementNS( XML_a, XML_gd,
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 87a1dde25fe8..7af1f71c53a1 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -903,11 +903,11 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, S
     if ( !bIncludeOld && !bOnlyDown )
     {
         if ( !bLeft )
-            while ( aCol[rStartCol].IsEmptyBlock(rStartRow,rEndRow) && rStartCol < (aCol.size()-1) && rStartCol < rEndCol)
+            while ( rStartCol < rEndCol && rStartCol < (aCol.size()-1) && aCol[rStartCol].IsEmptyBlock(rStartRow,rEndRow) )
                 ++rStartCol;
 
         if ( !bRight )
-            while ( aCol[rEndCol].IsEmptyBlock(rStartRow,rEndRow) && rEndCol > 0 && rStartCol < rEndCol)
+            while ( rEndCol > 0 && rStartCol < rEndCol && aCol[rEndCol].IsEmptyBlock(rStartRow,rEndRow) )
                 --rEndCol;
 
         if ( !bTop && rStartRow < MAXROW && rStartRow < rEndRow )
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index f1c51306e3d4..17f5fe0ba55d 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1646,7 +1646,7 @@ void ScTable::GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const
 {
     rCol = 0;
     rRow = MAXROW+1;
-    while (aCol[rCol].IsEmptyData() && rCol < aCol.size() - 1 )
+    while (rCol < (aCol.size() - 1) && aCol[rCol].IsEmptyData() )
         ++rCol;
     SCCOL nCol = rCol;
     while (nCol < aCol.size() && rRow > 0)
diff --git a/sc/source/core/tool/interpr8.cxx b/sc/source/core/tool/interpr8.cxx
index 3c3ace2fb8d9..534da1e12b24 100644
--- a/sc/source/core/tool/interpr8.cxx
+++ b/sc/source/core/tool/interpr8.cxx
@@ -238,14 +238,14 @@ bool ScETSForecastCalculation::PreprocessDataRange( const ScMatrixRef& rMatX, co
             switch ( nAggregation )
             {
                 case 1 : // AVERAGE (default)
-                         while ( maRange[ i ].X == maRange[ i - 1 ].X  && i < mnCount )
+                         while ( i < mnCount && maRange[ i ].X == maRange[ i - 1 ].X )
                          {
                              maRange.erase( maRange.begin() + i );
                              --mnCount;
                          }
                          break;
                 case 7 : // SUM
-                         while ( maRange[ i ].X == maRange[ i - 1 ].X  && i < mnCount )
+                         while ( i < mnCount && maRange[ i ].X == maRange[ i - 1 ].X )
                          {
                              fTmp += maRange[ i ].Y;
                              maRange.erase( maRange.begin() + i );
@@ -256,7 +256,7 @@ bool ScETSForecastCalculation::PreprocessDataRange( const ScMatrixRef& rMatX, co
 
                 case 2 : // COUNT
                 case 3 : // COUNTA (same as COUNT as there are no non-numeric Y-values)
-                         while ( maRange[ i ].X == maRange[ i - 1 ].X  && i < mnCount )
+                         while ( i < mnCount && maRange[ i ].X == maRange[ i - 1 ].X )
                          {
                              nCounter++;
                              maRange.erase( maRange.begin() + i );
@@ -266,7 +266,7 @@ bool ScETSForecastCalculation::PreprocessDataRange( const ScMatrixRef& rMatX, co
                          break;
 
                 case 4 : // MAX
-                         while ( maRange[ i ].X == maRange[ i - 1 ].X  && i < mnCount )
+                         while ( i < mnCount && maRange[ i ].X == maRange[ i - 1 ].X )
                          {
                              if ( maRange[ i ].Y > fTmp )
                                  fTmp = maRange[ i ].Y;
@@ -280,7 +280,7 @@ bool ScETSForecastCalculation::PreprocessDataRange( const ScMatrixRef& rMatX, co
                          {
                              std::vector< double > aTmp;
                              aTmp.push_back( maRange[ i - 1 ].Y );
-                             while ( maRange[ i ].X == maRange[ i - 1 ].X  && i < mnCount )
+                             while ( i < mnCount && maRange[ i ].X == maRange[ i - 1 ].X )
                              {
                                  aTmp.push_back( maRange[ i ].Y );
                                  nCounter++;
@@ -297,7 +297,7 @@ bool ScETSForecastCalculation::PreprocessDataRange( const ScMatrixRef& rMatX, co
                              break;
 
                 case 6 : // MIN
-                         while ( maRange[ i ].X == maRange[ i - 1 ].X  && i < mnCount )
+                         while ( i < mnCount && maRange[ i ].X == maRange[ i - 1 ].X )
                          {
                              if ( maRange[ i ].Y < fTmp )
                                  fTmp = maRange[ i ].Y;
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx
index 722e2bb6a6fb..2c3fe1c8ffb6 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -785,7 +785,7 @@ bool SwAccessibleParagraph::GetSentenceBoundary(
     const sal_Unicode* pStr = rText.getStr();
     if (pStr)
     {
-        while( pStr[nPos] == sal_Unicode(' ') && nPos < rText.getLength())
+        while( nPos < rText.getLength() && pStr[nPos] == sal_Unicode(' ') )
             nPos++;
     }
 


More information about the Libreoffice-commits mailing list