diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-10-09 12:55:21 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-10-09 13:50:37 +0200 |
commit | 6747fa4fe8a939ad877f95bc777b29a1ec242436 (patch) | |
tree | 8d2d442a6c472cda9a4fa4cc433a6804d927fc3e /vcl | |
parent | 0cab8199f345d01bfcbf2f6a0be63b34b1dbd285 (diff) |
Abstract out repeated code into lambdas
...to silence a clang-analyzer-deadcode.DeadStores on the last update of nUsed
Change-Id: Ib470f09155bd181b05bc0342543a36e59b8dd937
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/gdi/dibtools.cxx | 83 |
1 files changed, 51 insertions, 32 deletions
diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx index f4bb3c849244..d90d7bf1c882 100644 --- a/vcl/source/gdi/dibtools.cxx +++ b/vcl/source/gdi/dibtools.cxx @@ -201,43 +201,62 @@ bool ImplReadDIBInfoHeader(SvStream& rIStm, DIBV5Header& rHeader, bool& bTopDown // BITMAPCOREHEADER, BITMAPV5HEADER or unknown. Read as far as possible sal_Size nUsed(sizeof(rHeader.nSize)); + auto readUInt16 = [&nUsed, &rHeader, &rIStm](sal_uInt16 & v) { + if (nUsed < rHeader.nSize) { + rIStm.ReadUInt16(v); + nUsed += sizeof(v); + } + }; + auto readInt32 = [&nUsed, &rHeader, &rIStm](sal_Int32 & v) { + if (nUsed < rHeader.nSize) { + rIStm.ReadInt32(v); + nUsed += sizeof(v); + } + }; + auto readUInt32 = [&nUsed, &rHeader, &rIStm](sal_uInt32 & v) { + if (nUsed < rHeader.nSize) { + rIStm.ReadUInt32(v); + nUsed += sizeof(v); + } + }; + // read DIBInfoHeader entries - if(nUsed < rHeader.nSize) { rIStm.ReadInt32( rHeader.nWidth ); nUsed += sizeof(rHeader.nWidth); } - if(nUsed < rHeader.nSize) { rIStm.ReadInt32( rHeader.nHeight ); nUsed += sizeof(rHeader.nHeight); } - if(nUsed < rHeader.nSize) { rIStm.ReadUInt16( rHeader.nPlanes ); nUsed += sizeof(rHeader.nPlanes); } - if(nUsed < rHeader.nSize) { rIStm.ReadUInt16( rHeader.nBitCount ); nUsed += sizeof(rHeader.nBitCount); } - if(nUsed < rHeader.nSize) { rIStm.ReadUInt32( rHeader.nCompression ); nUsed += sizeof(rHeader.nCompression); } - if(nUsed < rHeader.nSize) { rIStm.ReadUInt32( rHeader.nSizeImage ); nUsed += sizeof(rHeader.nSizeImage); } - if(nUsed < rHeader.nSize) { rIStm.ReadInt32( rHeader.nXPelsPerMeter ); nUsed += sizeof(rHeader.nXPelsPerMeter); } - if(nUsed < rHeader.nSize) { rIStm.ReadInt32( rHeader.nYPelsPerMeter ); nUsed += sizeof(rHeader.nYPelsPerMeter); } - if(nUsed < rHeader.nSize) { rIStm.ReadUInt32( rHeader.nColsUsed ); nUsed += sizeof(rHeader.nColsUsed); } - if(nUsed < rHeader.nSize) { rIStm.ReadUInt32( rHeader.nColsImportant ); nUsed += sizeof(rHeader.nColsImportant); } + readInt32( rHeader.nWidth ); + readInt32( rHeader.nHeight ); + readUInt16( rHeader.nPlanes ); + readUInt16( rHeader.nBitCount ); + readUInt32( rHeader.nCompression ); + readUInt32( rHeader.nSizeImage ); + readInt32( rHeader.nXPelsPerMeter ); + readInt32( rHeader.nYPelsPerMeter ); + readUInt32( rHeader.nColsUsed ); + readUInt32( rHeader.nColsImportant ); // read DIBV5HEADER members - if(nUsed < rHeader.nSize) { rIStm.ReadUInt32( rHeader.nV5RedMask ); nUsed += sizeof(rHeader.nV5RedMask); } - if(nUsed < rHeader.nSize) { rIStm.ReadUInt32( rHeader.nV5GreenMask ); nUsed += sizeof(rHeader.nV5GreenMask); } - if(nUsed < rHeader.nSize) { rIStm.ReadUInt32( rHeader.nV5BlueMask ); nUsed += sizeof(rHeader.nV5BlueMask); } - if(nUsed < rHeader.nSize) { rIStm.ReadUInt32( rHeader.nV5AlphaMask ); nUsed += sizeof(rHeader.nV5AlphaMask); } - if(nUsed < rHeader.nSize) { rIStm.ReadUInt32( rHeader.nV5CSType ); nUsed += sizeof(rHeader.nV5CSType); } + readUInt32( rHeader.nV5RedMask ); + readUInt32( rHeader.nV5GreenMask ); + readUInt32( rHeader.nV5BlueMask ); + readUInt32( rHeader.nV5AlphaMask ); + readUInt32( rHeader.nV5CSType ); // read contained CIEXYZTriple's - if(nUsed < rHeader.nSize) { rIStm.ReadInt32( rHeader.aV5Endpoints.aXyzRed.aXyzX ); nUsed += sizeof(rHeader.aV5Endpoints.aXyzRed.aXyzX); } - if(nUsed < rHeader.nSize) { rIStm.ReadInt32( rHeader.aV5Endpoints.aXyzRed.aXyzY ); nUsed += sizeof(rHeader.aV5Endpoints.aXyzRed.aXyzY); } - if(nUsed < rHeader.nSize) { rIStm.ReadInt32( rHeader.aV5Endpoints.aXyzRed.aXyzZ ); nUsed += sizeof(rHeader.aV5Endpoints.aXyzRed.aXyzZ); } - if(nUsed < rHeader.nSize) { rIStm.ReadInt32( rHeader.aV5Endpoints.aXyzGreen.aXyzX ); nUsed += sizeof(rHeader.aV5Endpoints.aXyzGreen.aXyzX); } - if(nUsed < rHeader.nSize) { rIStm.ReadInt32( rHeader.aV5Endpoints.aXyzGreen.aXyzY ); nUsed += sizeof(rHeader.aV5Endpoints.aXyzGreen.aXyzY); } - if(nUsed < rHeader.nSize) { rIStm.ReadInt32( rHeader.aV5Endpoints.aXyzGreen.aXyzZ ); nUsed += sizeof(rHeader.aV5Endpoints.aXyzGreen.aXyzZ); } - if(nUsed < rHeader.nSize) { rIStm.ReadInt32( rHeader.aV5Endpoints.aXyzBlue.aXyzX ); nUsed += sizeof(rHeader.aV5Endpoints.aXyzBlue.aXyzX); } - if(nUsed < rHeader.nSize) { rIStm.ReadInt32( rHeader.aV5Endpoints.aXyzBlue.aXyzY ); nUsed += sizeof(rHeader.aV5Endpoints.aXyzBlue.aXyzY); } - if(nUsed < rHeader.nSize) { rIStm.ReadInt32( rHeader.aV5Endpoints.aXyzBlue.aXyzZ ); nUsed += sizeof(rHeader.aV5Endpoints.aXyzBlue.aXyzZ); } - - if(nUsed < rHeader.nSize) { rIStm.ReadUInt32( rHeader.nV5GammaRed ); nUsed += sizeof(rHeader.nV5GammaRed); } - if(nUsed < rHeader.nSize) { rIStm.ReadUInt32( rHeader.nV5GammaGreen ); nUsed += sizeof(rHeader.nV5GammaGreen); } - if(nUsed < rHeader.nSize) { rIStm.ReadUInt32( rHeader.nV5GammaBlue ); nUsed += sizeof(rHeader.nV5GammaBlue); } - if(nUsed < rHeader.nSize) { rIStm.ReadUInt32( rHeader.nV5Intent ); nUsed += sizeof(rHeader.nV5Intent); } - if(nUsed < rHeader.nSize) { rIStm.ReadUInt32( rHeader.nV5ProfileData ); nUsed += sizeof(rHeader.nV5ProfileData); } - if(nUsed < rHeader.nSize) { rIStm.ReadUInt32( rHeader.nV5ProfileSize ); nUsed += sizeof(rHeader.nV5ProfileSize); } - if(nUsed < rHeader.nSize) { rIStm.ReadUInt32( rHeader.nV5Reserved ); nUsed += sizeof(rHeader.nV5Reserved); } + readInt32( rHeader.aV5Endpoints.aXyzRed.aXyzX ); + readInt32( rHeader.aV5Endpoints.aXyzRed.aXyzY ); + readInt32( rHeader.aV5Endpoints.aXyzRed.aXyzZ ); + readInt32( rHeader.aV5Endpoints.aXyzGreen.aXyzX ); + readInt32( rHeader.aV5Endpoints.aXyzGreen.aXyzY ); + readInt32( rHeader.aV5Endpoints.aXyzGreen.aXyzZ ); + readInt32( rHeader.aV5Endpoints.aXyzBlue.aXyzX ); + readInt32( rHeader.aV5Endpoints.aXyzBlue.aXyzY ); + readInt32( rHeader.aV5Endpoints.aXyzBlue.aXyzZ ); + + readUInt32( rHeader.nV5GammaRed ); + readUInt32( rHeader.nV5GammaGreen ); + readUInt32( rHeader.nV5GammaBlue ); + readUInt32( rHeader.nV5Intent ); + readUInt32( rHeader.nV5ProfileData ); + readUInt32( rHeader.nV5ProfileSize ); + readUInt32( rHeader.nV5Reserved ); // seek to EndPos rIStm.Seek(aStartPos + rHeader.nSize); |