summaryrefslogtreecommitdiff
path: root/vcl/source/gdi
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-05-27 16:33:44 +0200
committerNoel Grandin <noel@peralex.com>2015-05-28 12:49:54 +0200
commitd5129a9dd68978f9eccdd4597b5b6834557c422a (patch)
treedf43250172f784f3048ce42ce1c3410d1d449c1e /vcl/source/gdi
parentf3331f7694e74f349375c223ce7ed84838e92d89 (diff)
new clang plugin: loopvartoosmall
Idea from bubli - look for loops where the index variable is of such size that it cannot cover the range revealed by examining the length part of the condition. So far, I have only run the plugin up till the VCL module. Also the plugin deliberately excludes anything more complicated than a straightforward incrementing for loop. Change-Id: Ifced18b01c03ea537c64168465ce0b8287a42015
Diffstat (limited to 'vcl/source/gdi')
-rw-r--r--vcl/source/gdi/bitmap.cxx4
-rw-r--r--vcl/source/gdi/bitmap4.cxx8
-rw-r--r--vcl/source/gdi/bitmapex.cxx4
-rw-r--r--vcl/source/gdi/image.cxx10
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx16
-rw-r--r--vcl/source/gdi/pngread.cxx28
-rw-r--r--vcl/source/gdi/pngwrite.cxx2
-rw-r--r--vcl/source/gdi/print.cxx6
-rw-r--r--vcl/source/gdi/region.cxx4
9 files changed, 41 insertions, 41 deletions
diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx
index 51e5db80924f..db5c1e9ba7d5 100644
--- a/vcl/source/gdi/bitmap.cxx
+++ b/vcl/source/gdi/bitmap.cxx
@@ -1435,7 +1435,7 @@ vcl::Region Bitmap::CreateRegion( const Color& rColor, const Rectangle& rRect )
aSubRect.Top() = nYStart;
aSubRect.Bottom() = nY ? nY - 1 : 0;
- for(sal_uInt32 a(0); a < aLine.size();)
+ for(size_t a(0); a < aLine.size();)
{
aSubRect.Left() = aLine[a++];
aSubRect.Right() = aLine[a++];
@@ -1458,7 +1458,7 @@ vcl::Region Bitmap::CreateRegion( const Color& rColor, const Rectangle& rRect )
aSubRect.Top() = nYStart;
aSubRect.Bottom() = nY ? nY - 1 : 0;
- for(sal_uInt32 a(0); a < aLine.size();)
+ for(size_t a(0); a < aLine.size();)
{
aSubRect.Left() = aLine[a++];
aSubRect.Right() = aLine[a++];
diff --git a/vcl/source/gdi/bitmap4.cxx b/vcl/source/gdi/bitmap4.cxx
index 42ac92d0b859..24a4b08251e7 100644
--- a/vcl/source/gdi/bitmap4.cxx
+++ b/vcl/source/gdi/bitmap4.cxx
@@ -1160,9 +1160,9 @@ bool Bitmap::ImplSeparableUnsharpenFilter(const double radius) {
BitmapColor aColor, aColorBlur;
// For all pixels in original image subtract pixels values from blurred image
- for( int x = 0; x < nWidth; x++ )
+ for( long x = 0; x < nWidth; x++ )
{
- for( int y = 0; y < nHeight; y++ )
+ for( long y = 0; y < nHeight; y++ )
{
aColorBlur = pReadAccBlur->GetColor( y , x );
aColor = pReadAcc->GetColor( y , x );
@@ -1194,9 +1194,9 @@ bool Bitmap::ImplDuotoneFilter( const sal_uLong nColorOne, const sal_uLong nColo
const BitmapColor aColorOne( static_cast< sal_uInt8 >( nColorOne >> 16 ), static_cast< sal_uInt8 >( nColorOne >> 8 ), static_cast< sal_uInt8 >( nColorOne ) );
const BitmapColor aColorTwo( static_cast< sal_uInt8 >( nColorTwo >> 16 ), static_cast< sal_uInt8 >( nColorTwo >> 8 ), static_cast< sal_uInt8 >( nColorTwo ) );
- for( int x = 0; x < nWidth; x++ )
+ for( long x = 0; x < nWidth; x++ )
{
- for( int y = 0; y < nHeight; y++ )
+ for( long y = 0; y < nHeight; y++ )
{
BitmapColor aColor = pReadAcc->GetColor( y, x );
sal_uInt8 luminance = aColor.GetLuminance();
diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx
index e6fa951a0927..5b0567a0cb38 100644
--- a/vcl/source/gdi/bitmapex.cxx
+++ b/vcl/source/gdi/bitmapex.cxx
@@ -855,9 +855,9 @@ namespace
const Size aDestinationSizePixel(aDestination.GetSizePixel());
const BitmapColor aOutside(BitmapColor(0xff, 0xff, 0xff));
- for(sal_Int32 y(0L); y < aDestinationSizePixel.getHeight(); y++)
+ for(long y(0L); y < aDestinationSizePixel.getHeight(); y++)
{
- for(sal_Int32 x(0L); x < aDestinationSizePixel.getWidth(); x++)
+ for(long x(0L); x < aDestinationSizePixel.getWidth(); x++)
{
const basegfx::B2DPoint aSourceCoor(rTransform * basegfx::B2DPoint(x, y));
diff --git a/vcl/source/gdi/image.cxx b/vcl/source/gdi/image.cxx
index c57c53bb4f9b..aceb2524364e 100644
--- a/vcl/source/gdi/image.cxx
+++ b/vcl/source/gdi/image.cxx
@@ -341,7 +341,7 @@ ImageList::ImageList( const ::std::vector< OUString >& rNameVector,
ImplInit( sal::static_int_cast< sal_uInt16 >( rNameVector.size() ), Size() );
mpImplData->maPrefix = rPrefix;
- for( sal_uInt32 i = 0; i < rNameVector.size(); ++i )
+ for( size_t i = 0; i < rNameVector.size(); ++i )
{
mpImplData->AddImage( rNameVector[ i ], static_cast< sal_uInt16 >( i ) + 1, BitmapEx() );
}
@@ -515,7 +515,7 @@ void ImageList::ReplaceImage( const OUString& rImageName, const Image& rImage )
void ImageList::RemoveImage( sal_uInt16 nId )
{
- for( sal_uInt32 i = 0; i < mpImplData->maImages.size(); ++i )
+ for( size_t i = 0; i < mpImplData->maImages.size(); ++i )
{
if( mpImplData->maImages[ i ]->mnId == nId )
{
@@ -585,7 +585,7 @@ sal_uInt16 ImageList::GetImagePos( sal_uInt16 nId ) const
if( mpImplData && nId )
{
- for( sal_uInt32 i = 0; i < mpImplData->maImages.size(); ++i )
+ for( size_t i = 0; i < mpImplData->maImages.size(); ++i )
{
if (mpImplData->maImages[ i ]->mnId == nId)
return static_cast< sal_uInt16 >( i );
@@ -605,7 +605,7 @@ sal_uInt16 ImageList::GetImagePos( const OUString& rImageName ) const
if( mpImplData && !rImageName.isEmpty() )
{
- for( sal_uInt32 i = 0; i < mpImplData->maImages.size(); i++ )
+ for( size_t i = 0; i < mpImplData->maImages.size(); i++ )
{
if (mpImplData->maImages[i]->maName == rImageName)
return static_cast< sal_uInt16 >( i );
@@ -641,7 +641,7 @@ void ImageList::GetImageNames( ::std::vector< OUString >& rNames ) const
if( mpImplData )
{
- for( sal_uInt32 i = 0; i < mpImplData->maImages.size(); i++ )
+ for( size_t i = 0; i < mpImplData->maImages.size(); i++ )
{
const OUString& rName( mpImplData->maImages[ i ]->maName );
if( !rName.isEmpty())
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 37ab711f393d..fe1b8330ffb8 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -1359,7 +1359,7 @@ bool PDFWriterImpl::PDFPage::emit(sal_Int32 nParentObject )
unsigned int nStreamObjects = m_aStreamObjects.size();
if( nStreamObjects > 1 )
aLine.append( '[' );
- for( unsigned int i = 0; i < m_aStreamObjects.size(); i++ )
+ for( size_t i = 0; i < m_aStreamObjects.size(); i++ )
{
aLine.append( ' ' );
aLine.append( m_aStreamObjects[i] );
@@ -5394,7 +5394,7 @@ bool PDFWriterImpl::emitWidgetAnnotations()
if( rWidget.m_nFlags & 0x200000 ) // multiselect
{
aValue.append( "[" );
- for( unsigned int i = 0; i < rWidget.m_aSelectedEntries.size(); i++ )
+ for( size_t i = 0; i < rWidget.m_aSelectedEntries.size(); i++ )
{
sal_Int32 nEntry = rWidget.m_aSelectedEntries[i];
if( nEntry >= 0 && nEntry < sal_Int32(rWidget.m_aListEntries.size()) )
@@ -5441,7 +5441,7 @@ bool PDFWriterImpl::emitWidgetAnnotations()
if( rWidget.m_aKids.size() )
{
aLine.append( "/Kids[" );
- for( unsigned int i = 0; i < rWidget.m_aKids.size(); i++ )
+ for( size_t i = 0; i < rWidget.m_aKids.size(); i++ )
{
aLine.append( rWidget.m_aKids[i] );
aLine.append( " 0 R" );
@@ -8138,7 +8138,7 @@ bool PDFWriterImpl::emitTrailer()
if( m_aAdditionalStreams.size() > 0 )
{
aLine.append( "/AdditionalStreams [" );
- for( unsigned int i = 0; i < m_aAdditionalStreams.size(); i++ )
+ for( size_t i = 0; i < m_aAdditionalStreams.size(); i++ )
{
aLine.append( "/" );
appendName( m_aAdditionalStreams[i].m_aMimeType, aLine );
@@ -11028,7 +11028,7 @@ bool PDFWriterImpl::writeGradientFunction( GradientEmit& rObject )
default:
for( int y = aSize.Height()-1; y >= 0; y-- )
{
- for( int x = 0; x < aSize.Width(); x++ )
+ for( long x = 0; x < aSize.Width(); x++ )
{
BitmapColor aColor = pAccess->GetColor( y, x );
aCol[0] = aColor.GetRed();
@@ -11454,7 +11454,7 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask )
{
const int nScanLineBytes = 1 + ( pAccess->GetBitCount() * ( pAccess->Width() - 1 ) / 8U );
- for( int i = 0; i < pAccess->Height(); i++ )
+ for( long i = 0; i < pAccess->Height(); i++ )
{
CHECK_RETURN( writeBuffer( pAccess->GetScanline( i ), nScanLineBytes ) );
}
@@ -11463,9 +11463,9 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask )
{
const int nScanLineBytes = pAccess->Width()*3;
boost::shared_array<sal_uInt8> pCol( new sal_uInt8[ nScanLineBytes ] );
- for( int y = 0; y < pAccess->Height(); y++ )
+ for( long y = 0; y < pAccess->Height(); y++ )
{
- for( int x = 0; x < pAccess->Width(); x++ )
+ for( long x = 0; x < pAccess->Width(); x++ )
{
BitmapColor aColor = pAccess->GetColor( y, x );
pCol[3*x+0] = aColor.GetRed();
diff --git a/vcl/source/gdi/pngread.cxx b/vcl/source/gdi/pngread.cxx
index d9352a79202c..c33ea387fcd3 100644
--- a/vcl/source/gdi/pngread.cxx
+++ b/vcl/source/gdi/pngread.cxx
@@ -1268,12 +1268,12 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
{
if ( mnPngDepth == 8 ) // maybe the source is a 16 bit grayscale
{
- for ( sal_Int32 nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp += 2 )
+ for ( long nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp += 2 )
ImplSetAlphaPixel( nY, nX, pTmp[ 0 ], pTmp[ 1 ] );
}
else
{
- for ( sal_Int32 nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp += 4 )
+ for ( long nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp += 4 )
ImplSetAlphaPixel( nY, nX, pTmp[ 0 ], pTmp[ 2 ] );
}
}
@@ -1281,12 +1281,12 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
{
if ( mnPngDepth == 8 ) // maybe the source is a 16 bit grayscale
{
- for ( sal_Int32 nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp++ )
+ for ( long nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp++ )
ImplSetAlphaPixel( nY, nX, *pTmp, mpTransTab[ *pTmp ] );
}
else
{
- for ( sal_Int32 nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp += 2 )
+ for ( long nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp += 2 )
ImplSetAlphaPixel( nY, nX, *pTmp, mpTransTab[ *pTmp ] );
}
}
@@ -1302,13 +1302,13 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
}
else
{
- for ( sal_Int32 nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd )
+ for ( long nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd )
ImplSetPixel( nY, nX, *pTmp++ );
}
}
else
{
- for ( sal_Int32 nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp += 2 )
+ for ( long nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp += 2 )
ImplSetPixel( nY, nX, *pTmp );
}
}
@@ -1365,7 +1365,7 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
sal_uInt8* pScanline(mpScanline);
sal_uInt8* pScanlineAlpha(mpScanlineAlpha);
- for (sal_Int32 nX(0); nX < maOrigSize.Width(); nX++, pTmp += 4)
+ for (long nX(0); nX < maOrigSize.Width(); nX++, pTmp += 4)
{
// prepare content line as BGR by reordering when copying
// do not forget to invert alpha (source is alpha, target is opacity)
@@ -1392,7 +1392,7 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
}
else
{
- for ( sal_Int32 nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp += 4 )
+ for ( long nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp += 4 )
{
if(bCustomColorTable)
{
@@ -1422,7 +1422,7 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
else
{
// BMP_FORMAT_64BIT_TC_RGBA
- for ( sal_Int32 nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp += 8 )
+ for ( long nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp += 8 )
{
ImplSetAlphaPixel(
nY,
@@ -1441,7 +1441,7 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
// no support currently for DirectScanline, found no real usages in current PNGs, may be added on demand
if ( mnPngDepth == 8 ) // maybe the source has 16 bit per sample
{
- for ( sal_Int32 nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp += 3 )
+ for ( long nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp += 3 )
{
sal_uInt8 nRed = pTmp[ 0 ];
sal_uInt8 nGreen = pTmp[ 1 ];
@@ -1458,7 +1458,7 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
else
{
// BMP_FORMAT_48BIT_TC_RGB
- for ( sal_Int32 nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp += 6 )
+ for ( long nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp += 6 )
{
sal_uInt8 nRed = pTmp[ 0 ];
sal_uInt8 nGreen = pTmp[ 2 ];
@@ -1498,7 +1498,7 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
OSL_ENSURE(mnAllocSizeScanline >= maOrigSize.Width() * 3, "Allocated Scanline too small (!)");
sal_uInt8* pScanline(mpScanline);
- for (sal_Int32 nX(0); nX < maOrigSize.Width(); nX++, pTmp += 3)
+ for (long nX(0); nX < maOrigSize.Width(); nX++, pTmp += 3)
{
// prepare content line as BGR by reordering when copying
if(bCustomColorTable)
@@ -1521,7 +1521,7 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
}
else
{
- for ( sal_Int32 nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp += 3 )
+ for ( long nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp += 3 )
{
if(bCustomColorTable)
{
@@ -1550,7 +1550,7 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
{
// BMP_FORMAT_48BIT_TC_RGB
// no support currently for DirectScanline, found no real usages in current PNGs, may be added on demand
- for ( sal_Int32 nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp += 6 )
+ for ( long nX = nXStart; nX < maOrigSize.Width(); nX += nXAdd, pTmp += 6 )
{
ImplSetPixel(
nY,
diff --git a/vcl/source/gdi/pngwrite.cxx b/vcl/source/gdi/pngwrite.cxx
index d3ee25fbeff9..01ff6fe5be9b 100644
--- a/vcl/source/gdi/pngwrite.cxx
+++ b/vcl/source/gdi/pngwrite.cxx
@@ -334,7 +334,7 @@ void PNGWriterImpl::ImplWritePalette()
ImplOpenChunk(PNGCHUNK_PLTE);
- for ( sal_uInt16 i = 0; i < nCount; i++ )
+ for ( sal_uLong i = 0; i < nCount; i++ )
{
const BitmapColor& rColor = mpAccess->GetPaletteColor(i);
*pTmp++ = rColor.GetRed();
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index 16d3d9980af7..e5de8298cdf1 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -431,7 +431,7 @@ SalPrinterQueueInfo::~SalPrinterQueueInfo()
ImplPrnQueueList::~ImplPrnQueueList()
{
ImplSVData* pSVData = ImplGetSVData();
- for( unsigned int i = 0; i < m_aQueueInfos.size(); i++ )
+ for( size_t i = 0; i < m_aQueueInfos.size(); i++ )
{
delete m_aQueueInfos[i].mpQueueInfo;
pSVData->mpDefInst->DeletePrinterQueueInfo( m_aQueueInfos[i].mpSalQueueInfo );
@@ -908,7 +908,7 @@ SalPrinterQueueInfo* Printer::ImplGetQueueInfo( const OUString& rPrinterName,
return pInfo->mpSalQueueInfo;
// then search case insensitive
- for( unsigned int i = 0; i < pPrnList->m_aQueueInfos.size(); i++ )
+ for( size_t i = 0; i < pPrnList->m_aQueueInfos.size(); i++ )
{
if( pPrnList->m_aQueueInfos[i].mpSalQueueInfo->maPrinterName.equalsIgnoreAsciiCase( rPrinterName ) )
return pPrnList->m_aQueueInfos[i].mpSalQueueInfo;
@@ -917,7 +917,7 @@ SalPrinterQueueInfo* Printer::ImplGetQueueInfo( const OUString& rPrinterName,
// then search for driver name
if ( pDriver )
{
- for( unsigned int i = 0; i < pPrnList->m_aQueueInfos.size(); i++ )
+ for( size_t i = 0; i < pPrnList->m_aQueueInfos.size(); i++ )
{
if( pPrnList->m_aQueueInfos[i].mpSalQueueInfo->maDriver == *pDriver )
return pPrnList->m_aQueueInfos[i].mpSalQueueInfo;
diff --git a/vcl/source/gdi/region.cxx b/vcl/source/gdi/region.cxx
index 086739a62fff..1543d83d6e81 100644
--- a/vcl/source/gdi/region.cxx
+++ b/vcl/source/gdi/region.cxx
@@ -1774,7 +1774,7 @@ vcl::Region vcl::Region::GetRegionFromPolyPolygon( const tools::PolyPolygon& rPo
int nPolygonRects = 0, nPolygonPolygons = 0;
int nPolygons = rPolyPoly.Count();
- for( sal_uInt16 i = 0; i < nPolygons; i++ )
+ for( int i = 0; i < nPolygons; i++ )
{
const Polygon& rPoly = rPolyPoly[i];
@@ -1796,7 +1796,7 @@ vcl::Region vcl::Region::GetRegionFromPolyPolygon( const tools::PolyPolygon& rPo
vcl::Region aResult;
Rectangle aRect;
- for( sal_uInt16 i = 0; i < nPolygons; i++ )
+ for( int i = 0; i < nPolygons; i++ )
{
const Polygon& rPoly = rPolyPoly[i];