Kaydet (Commit) 26ccd00b authored tarafından Tamás Zolnai's avatar Tamás Zolnai

clang-tidy: (WIP) bugprone-too-small-loop-variable findings

Change-Id: Iaa255b39928ac45dec1ed37e368c149d6027f561
Reviewed-on: https://gerrit.libreoffice.org/62701Reviewed-by: 's avatarTamás Zolnai <tamas.zolnai@collabora.com>
Tested-by: 's avatarTamás Zolnai <tamas.zolnai@collabora.com>
üst 0610c443
......@@ -1320,7 +1320,7 @@ static void lcl_Update(std::unique_ptr<SfxVoidItem> pInvalidItems[], std::unique
while(pViewFrm)
{
SfxBindings& rBind = pViewFrm->GetBindings();
for(sal_Int16 i = 0; i < nCount; i++)
for(sal_uInt16 i = 0; i < nCount; i++)
{
if(pCurrentFrm == pViewFrm)
rBind.InvalidateAll(false);
......
......@@ -849,7 +849,7 @@ void UpdateDialog::notifyMenubar( bool bPrepareOnly, bool bRecheckOnly )
if ( ! bRecheckOnly )
{
sal_Int32 nCount = 0;
for ( sal_Int16 i = 0; i < m_pUpdates->getItemCount(); ++i )
for ( sal_uInt16 i = 0; i < m_pUpdates->getItemCount(); ++i )
{
uno::Sequence< OUString > aItem(2);
......
......@@ -209,7 +209,7 @@ namespace drawinglayer
// reuse first polygon, it's the second one
aCombinedPolyPoly.remove(0);
for(sal_uInt32 a(0); a < rEntries.size() - 1; a++)
for(size_t a(0); a < rEntries.size() - 1; a++)
{
// create next inner polygon, combined with last one
basegfx::B2DPolygon aNextPoly(rUnitPolygon);
......
......@@ -170,7 +170,7 @@ BibConfig::BibConfig()
OUString sTempReal;
sal_Int16 nSetMapping = 0;
nFieldIdx = 0;
for(sal_Int16 nFieldVal = 0; nFieldVal < aAssignmentValues.getLength() / 2; nFieldVal++)
for(sal_Int32 nFieldVal = 0; nFieldVal < aAssignmentValues.getLength() / 2; nFieldVal++)
{
pAssignmentValues[nFieldIdx++] >>= sTempLogical;
pAssignmentValues[nFieldIdx++] >>= sTempReal;
......
......@@ -79,7 +79,7 @@ namespace PictReaderShape {
long origPt[4][2] = { { orig.X(), orig.Y() }, { orig.X()+pSize.Width(), orig.Y() },
{ orig.X()+pSize.Width(), orig.Y()+pSize.Height() },
{ orig.X(), orig.Y()+pSize.Height() }};
long origAvoid = dir[0] > 0 ? (dir[1] > 0 ? 2 : 1) : (dir[1] > 0 ? 3 : 0);
int origAvoid = dir[0] > 0 ? (dir[1] > 0 ? 2 : 1) : (dir[1] > 0 ? 3 : 0);
long destPt[4][2] = { { dest.X(), dest.Y() }, { dest.X()+pSize.Width(), dest.Y() },
{ dest.X()+pSize.Width(), dest.Y()+pSize.Height() },
{ dest.X(), dest.Y()+pSize.Height() }};
......
......@@ -4577,7 +4577,8 @@ sal_uInt32 EscherConnectorListEntry::GetConnectorRule( bool bFirst )
if(0 != aPolyPoly.Count())
{
sal_Int16 a, b, nIndex = 0;
sal_Int16 nIndex = 0;
sal_uInt16 a, b;
sal_uInt32 nDistance = 0xffffffff;
for ( a = 0; a < aPolyPoly.Count(); a++ )
......
......@@ -178,9 +178,9 @@ static void testTile( Document *pDocument, int max_parts,
// Estimate the maximum tiles based on the number of parts requested, if Writer.
int nMaxTiles = max_tiles;
int nTiles = 0;
for (int nY = 0; nY < nHeight - 1; nY += nTilePixelHeight)
for (long nY = 0; nY < nHeight - 1; nY += nTilePixelHeight)
{
for (int nX = 0; nX < nWidth - 1; nX += nTilePixelWidth)
for (long nX = 0; nX < nWidth - 1; nX += nTilePixelWidth)
{
if (nMaxTiles >= 0 && nTiles >= nMaxTiles)
{
......@@ -190,7 +190,7 @@ static void testTile( Document *pDocument, int max_parts,
pDocument->paintTile(pPixels, nTilePixelWidth, nTilePixelHeight,
nX, nY, nTilePixelWidth, nTilePixelHeight);
nTiles++;
fprintf (stderr, " rendered 1:1 tile %d at %d, %d\n",
fprintf (stderr, " rendered 1:1 tile %d at %ld, %ld\n",
nTiles, nX, nY);
}
}
......@@ -203,9 +203,9 @@ static void testTile( Document *pDocument, int max_parts,
if (pDocument->getDocumentType() == LOK_DOCTYPE_TEXT)
nMaxTiles = static_cast<int>(ceil(max_parts * 16128. / nTileTwipHeight) * ceil(static_cast<double>(nWidth) / nTileTwipWidth));
int nTiles = 0;
for (int nY = 0; nY < nHeight - 1; nY += nTileTwipHeight)
for (long nY = 0; nY < nHeight - 1; nY += nTileTwipHeight)
{
for (int nX = 0; nX < nWidth - 1; nX += nTileTwipWidth)
for (long nX = 0; nX < nWidth - 1; nX += nTileTwipWidth)
{
if (nMaxTiles >= 0 && nTiles >= nMaxTiles)
{
......@@ -215,7 +215,7 @@ static void testTile( Document *pDocument, int max_parts,
pDocument->paintTile(pPixels, nTilePixelWidth, nTilePixelHeight,
nX, nY, nTileTwipWidth, nTileTwipHeight);
nTiles++;
fprintf (stderr, " rendered scaled tile %d at %d, %d\n",
fprintf (stderr, " rendered scaled tile %d at %ld, %ld\n",
nTiles, nX, nY);
}
}
......
......@@ -371,7 +371,7 @@ OUString LwpNumericFormat::reencode(const OUString& sCode)
const sal_Unicode * pString = sCode.getStr();
sal_uInt16 nLen = sCode.getLength();
bool bFound = false;
sal_uInt16 i;
sal_Int32 i;
std::unique_ptr<sal_Unicode[]> pBuff( new sal_Unicode[sCode.getLength()] );
for (i=0; i< sCode.getLength() - 1; i++)
......
......@@ -410,7 +410,7 @@ ds_status pickBestDevice(std::unique_ptr<ds_profile> const & profile, int& rBest
int matchDevice(std::unique_ptr<ds_profile> const & profile, char* deviceName)
{
int deviceMatch = -1;
for (unsigned int d = 0; d < profile->devices.size() - 1; d++)
for (size_t d = 0; d < profile->devices.size() - 1; d++)
{
if (profile->devices[d].sDeviceName.indexOf(deviceName) != -1)
deviceMatch = d;
......
......@@ -1451,7 +1451,7 @@ public:
ss << "\tint i;\n\t";
ss << "int currentCount0;\n";
for (unsigned i = 0; i < vSubArguments.size() - 1; i++)
for (size_t i = 0; i < vSubArguments.size() - 1; i++)
ss << "int currentCount" << i + 1 << ";\n";
std::stringstream temp3, temp4;
int outLoopSize = UNROLLING_FACTOR;
......
......@@ -1224,7 +1224,7 @@ public:
{
if (mbFirst)
{
for (auto i = 0u; i < mpOp->size(); ++i)
for (size_t i = 0u; i < mpOp->size(); ++i)
{
(*(*mpOp)[i])(maRes[i].mfFirst, *it);
}
......@@ -1232,7 +1232,7 @@ public:
}
else
{
for (auto i = 0u; i < mpOp->size(); ++i)
for (size_t i = 0u; i < mpOp->size(); ++i)
{
(*(*mpOp)[i])(maRes[i].mfRest, *it);
}
......@@ -1251,7 +1251,7 @@ public:
{
if (mbFirst)
{
for (auto i = 0u; i < mpOp->size(); ++i)
for (size_t i = 0u; i < mpOp->size(); ++i)
{
(*(*mpOp)[i])(maRes[i].mfFirst, *it);
}
......@@ -1259,7 +1259,7 @@ public:
}
else
{
for (auto i = 0u; i < mpOp->size(); ++i)
for (size_t i = 0u; i < mpOp->size(); ++i)
{
(*(*mpOp)[i])(maRes[i].mfRest, *it);
}
......
......@@ -538,7 +538,7 @@ double GetYearFrac( sal_Int32 nNullDate, sal_Int32 nStartDate, sal_Int32 nEndDat
{
// return average of days in year between nDate1 and nDate2, inclusive
sal_Int32 nDayCount = 0;
for ( sal_Int16 i = nYear1; i <= nYear2; i++ )
for ( sal_uInt16 i = nYear1; i <= nYear2; i++ )
nDayCount += ( IsLeapYear( i ) ? 366 : 365 );
nDaysInYear = static_cast<double>(nDayCount) / static_cast<double>( nYear2 - nYear1 + 1 );
......
......@@ -237,7 +237,7 @@ OUString SAL_CALL PDFDetector::detect( uno::Sequence< beans::PropertyValue >& rF
if( nBytes > 5 )
{
const sal_Int8* pBytes = aBuf.getConstArray();
for( unsigned int i = 0; i < nBytes-5; i++ )
for( sal_uInt64 i = 0; i < nBytes-5; i++ )
{
if( pBytes[i] == '%' &&
pBytes[i+1] == 'P' &&
......
......@@ -1189,7 +1189,7 @@ static bool check_user_password( const OString& rPwd, PDFFileImplData* pData )
for( int i = 1; i <= 19; i++ ) // do it 19 times, start with 1
{
sal_uInt8 aTempKey[ENCRYPTION_KEY_LEN];
for( sal_uInt32 j = 0; j < sizeof(aTempKey); j++ )
for( size_t j = 0; j < sizeof(aTempKey); j++ )
aTempKey[j] = static_cast<sal_uInt8>( aKey[j] ^ i );
if (rtl_cipher_initARCFOUR( pData->m_aCipher, rtl_Cipher_DirectionEncode,
......@@ -1257,7 +1257,7 @@ bool PDFFile::setupDecryptionData( const OString& rPwd ) const
for( int i = 19; i >= 0; i-- )
{
sal_uInt8 nTempKey[ENCRYPTION_KEY_LEN];
for( unsigned int j = 0; j < sizeof(nTempKey); j++ )
for( size_t j = 0; j < sizeof(nTempKey); j++ )
nTempKey[j] = sal_uInt8(aKey[j] ^ i);
if (rtl_cipher_initARCFOUR( m_pData->m_aCipher, rtl_Cipher_DirectionDecode,
nTempKey, nKeyLen, nullptr, 0 )
......
......@@ -81,7 +81,7 @@ int main(int argc, char **argv)
aPwBuf[0] = 0; // mark as empty
else
{
for( unsigned int i = 0; i < sizeof(aPwBuf); i++ )
for( size_t i = 0; i < sizeof(aPwBuf); i++ )
{
if( aPwBuf[i] == '\n' )
{
......
......@@ -2215,7 +2215,7 @@ void lcl_GetOutputStringScientific(double fNumber, sal_uInt16 nCharCount,
OUString lcl_GetDenominatorString(const ImpSvNumberformatInfo &rInfo, sal_uInt16 nCnt)
{
sal_uInt16 i;
sal_Int32 i;
OUStringBuffer aDenominatorString;
for( i = 0; i < nCnt; i++ )
{
......@@ -2237,7 +2237,7 @@ OUString lcl_GetDenominatorString(const ImpSvNumberformatInfo &rInfo, sal_uInt16
OUString lcl_GetNumeratorString(const ImpSvNumberformatInfo &rInfo, sal_uInt16 nCnt)
{
sal_Int16 i;
sal_Int32 i;
OUStringBuffer aNumeratorString;
for( i = 0; i < nCnt; i++ )
{
......@@ -2255,7 +2255,7 @@ OUString lcl_GetNumeratorString(const ImpSvNumberformatInfo &rInfo, sal_uInt16 n
OUString lcl_GetFractionIntegerString(const ImpSvNumberformatInfo &rInfo, sal_uInt16 nCnt)
{
sal_Int16 i;
sal_Int32 i;
OUStringBuffer aIntegerString;
for( i = 0; i < nCnt; i++ )
{
......@@ -2274,7 +2274,7 @@ OUString lcl_GetFractionIntegerString(const ImpSvNumberformatInfo &rInfo, sal_uI
OUString lcl_GetIntegerFractionDelimiterString(const ImpSvNumberformatInfo &rInfo, sal_uInt16 nCnt)
{
sal_Int16 i;
sal_uInt16 i;
for( i = 0; i < nCnt; i++ )
{
if( rInfo.nTypeArray[i] == NF_SYMBOLTYPE_FRACBLANK )
......
......@@ -506,7 +506,7 @@ void ClassificationDialog::toggleWidgetsDependingOnCategory()
for (sal_Int32 nParagraph = 0; nParagraph < rEditEngine.GetParagraphCount(); ++nParagraph)
{
sal_uInt16 nFieldCount = rEditEngine.GetFieldCount(nParagraph);
for (sal_Int16 nField = 0; nField < nFieldCount; ++nField)
for (sal_uInt16 nField = 0; nField < nFieldCount; ++nField)
{
EFieldInfo aFieldInfo = rEditEngine.GetFieldInfo(nParagraph, nField);
if (aFieldInfo.pFieldItem)
......
......@@ -245,7 +245,7 @@ void SearchAttrItemList::Remove(size_t nPos)
if ( nPos + nLen > size() )
nLen = size() - nPos;
for ( sal_uInt16 i = nPos; i < nPos + nLen; ++i )
for ( size_t i = nPos; i < nPos + nLen; ++i )
if ( !IsInvalidItem( (*this)[i].pItem ) )
delete (*this)[i].pItem;
......
......@@ -3518,7 +3518,7 @@ long SvxRuler::CalcPropMaxRight(sal_uInt16 nCol) const
lFences = mpBorders[nCol].nWidth;
}
for(sal_uInt16 i = nStart; i < mpBorders.size() - 1; ++i)
for(size_t i = nStart; i < mpBorders.size() - 1; ++i)
{
long lWidth = mpBorders[i].nPos - lOldPos;
lColumns += lWidth;
......@@ -3599,7 +3599,7 @@ long SvxRuler::CalcPropMaxRight(sal_uInt16 nCol) const
else
{
long lWidth = 0;
for(sal_uInt16 i = nCol; i < mpBorders.size() - 1; i++)
for(size_t i = nCol; i < mpBorders.size() - 1; i++)
{
lWidth += glMinFrame + mpBorders[i].nWidth;
}
......
......@@ -1318,7 +1318,7 @@ bool FmXFormShell::canConvertCurrentSelectionToControl_Lock(const OString& rIden
void FmXFormShell::checkControlConversionSlotsForCurrentSelection_Lock(Menu& rMenu)
{
for (sal_Int16 i = 0; i < rMenu.GetItemCount(); ++i)
for (sal_uInt16 i = 0; i < rMenu.GetItemCount(); ++i)
{
// the context is already of a type that corresponds to the entry -> disable
const sal_uInt16 nId = rMenu.GetItemId(i);
......
......@@ -600,7 +600,7 @@ bool SwPostItMgr::CalcRects()
{
const unsigned long nNumberOfPages = mPages.size();
mPages.reserve(aPageNum);
for (unsigned int j=0; j<aPageNum - nNumberOfPages; ++j)
for (unsigned long j=0; j<aPageNum - nNumberOfPages; ++j)
mPages.emplace_back( new SwPostItPageItem());
}
mPages[aPageNum-1]->mvSidebarItems.push_back(pItem);
......@@ -651,7 +651,7 @@ void SwPostItMgr::PreparePageContainer()
if (lContainerSize < lPageSize)
{
mPages.reserve(lPageSize);
for (int i=0; i<lPageSize - lContainerSize;i++)
for (long i=0; i<lPageSize - lContainerSize;i++)
mPages.emplace_back( new SwPostItPageItem());
}
else if (lContainerSize > lPageSize)
......
......@@ -111,7 +111,7 @@ TestResult checkHorizontalVerticalDiagonalLines(Bitmap& rBitmap, Color aExpected
checkValue(pAccess, startX, y, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, true, nColorThresh);
checkValue(pAccess, endX, y, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, true, nColorThresh);
for (int x = startX + 1; x <= endX - 1; x++)
for (long x = startX + 1; x <= endX - 1; x++)
{
checkValue(pAccess, x, y, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, false, nColorThresh);
}
......@@ -127,7 +127,7 @@ TestResult checkHorizontalVerticalDiagonalLines(Bitmap& rBitmap, Color aExpected
checkValue(pAccess, x, startY, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, true, nColorThresh);
checkValue(pAccess, x, endY, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, true, nColorThresh);
for (int y = startY + 1; y <= endY - 1; y++)
for (long y = startY + 1; y <= endY - 1; y++)
{
checkValue(pAccess, x, y, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, false, nColorThresh);
}
......
......@@ -1657,11 +1657,11 @@ void SvpSalGraphics::drawMask( const SalTwoRect& rTR,
}
sal_Int32 nStride;
unsigned char *mask_data = aSurface.getBits(nStride);
for (sal_Int32 y = rTR.mnSrcY ; y < rTR.mnSrcY + rTR.mnSrcHeight; ++y)
for (long y = rTR.mnSrcY ; y < rTR.mnSrcY + rTR.mnSrcHeight; ++y)
{
unsigned char *row = mask_data + (nStride*y);
unsigned char *data = row + (rTR.mnSrcX * 4);
for (sal_Int32 x = rTR.mnSrcX; x < rTR.mnSrcX + rTR.mnSrcWidth; ++x)
for (long x = rTR.mnSrcX; x < rTR.mnSrcX + rTR.mnSrcWidth; ++x)
{
sal_uInt8 b = unpremultiply(data[SVP_CAIRO_BLUE], data[SVP_CAIRO_ALPHA]);
sal_uInt8 g = unpremultiply(data[SVP_CAIRO_GREEN], data[SVP_CAIRO_ALPHA]);
......
......@@ -330,7 +330,8 @@ void ImplChain::ImplEndAdd( sal_uLong nFlag )
nFirstY = nLastY = maStartPt.Y();
aArr.ImplSetSize( mnCount << 1 );
sal_uInt16 i, nPolyPos;
sal_uInt16 nPolyPos;
sal_uLong i;
for( i = 0, nPolyPos = 0; i < ( mnCount - 1 ); i++ )
{
const sal_uInt8 cMove = mpCodes[ i ];
......@@ -437,7 +438,8 @@ void ImplChain::ImplEndAdd( sal_uLong nFlag )
nFirstY = nLastY = maStartPt.Y();
aArr.ImplSetSize( mnCount << 1 );
sal_uInt16 i, nPolyPos;
sal_uInt16 nPolyPos;
sal_uLong i;
for( i = 0, nPolyPos = 0; i < ( mnCount - 1 ); i++ )
{
const sal_uInt8 cMove = mpCodes[ i ];
......
......@@ -1398,7 +1398,8 @@ bool PDFWriterImpl::computeODictionaryValue( const sal_uInt8* i_pPaddedOwnerPass
//Step 7, only if 128 bit
if( i_nKeyLength == SECUR_128BIT_KEY )
{
sal_uInt32 i, y;
sal_uInt32 i;
size_t y;
sal_uInt8 nLocalKey[ SECUR_128BIT_KEY ]; // 16 = 128 bit key
for( i = 1; i <= 19; i++ ) // do it 19 times, start with 1
......@@ -1472,7 +1473,8 @@ bool PDFWriterImpl::computeUDictionaryValue( EncHashTransporter* i_pTransporter,
rtl_cipher_encodeARCFOUR( aCipher, nMD5Sum.data(), nMD5Sum.size(), // the data to be encrypted
&io_rProperties.UValue[0], SECUR_128BIT_KEY ); //encrypted data, stored in class data member
//step 5
sal_uInt32 i, y;
sal_uInt32 i;
size_t y;
sal_uInt8 nLocalKey[SECUR_128BIT_KEY];
for( i = 1; i <= 19; i++ ) // do it 19 times, start with 1
......
......@@ -419,7 +419,7 @@ void RegionBand::CreateBandRange(long nYTop, long nYBottom)
mpLastCheckedBand = mpFirstBand;
ImplRegionBand* pBand = mpFirstBand;
for ( int i = nYTop; i <= nYBottom+1; i++ )
for ( long i = nYTop; i <= nYBottom+1; i++ )
{
// create new band
ImplRegionBand* pNewBand = new ImplRegionBand( i, i );
......
......@@ -100,7 +100,7 @@ public:
void convertScanline(sal_uInt8* pSource, sal_uInt8* pDestination)
{
for (int x = 0; x < mnScanlineSize; x += mnComponentSize)
for (long x = 0; x < mnScanlineSize; x += mnComponentSize)
{
for (int i = 0; i < mnComponentSize; ++i)
{
......
......@@ -1861,8 +1861,8 @@ static XAccessible* getTheParentOfMember(XAccessible* pXAcc)
}
Reference<XAccessibleContext> pRContext = pXAcc->getAccessibleContext();
Reference<XAccessibleRelationSet> pRrelationSet = pRContext->getAccessibleRelationSet();
long nRelations = pRrelationSet->getRelationCount();
for(int i=0 ; i<nRelations ; i++)
sal_Int32 nRelations = pRrelationSet->getRelationCount();
for(sal_Int32 i=0 ; i<nRelations ; i++)
{
AccessibleRelation accRelation = pRrelationSet->getRelation(i);
if(accRelation.RelationType == 7)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment