[Libreoffice-commits] core.git: 10 commits - vcl/source

Stephan Bergmann sbergman at redhat.com
Fri Oct 9 04:51:01 PDT 2015


 vcl/source/filter/sgvmain.cxx      |    1 
 vcl/source/filter/sgvtext.cxx      |    6 +-
 vcl/source/filter/wmf/winwmf.cxx   |    8 +--
 vcl/source/gdi/dibtools.cxx        |   83 ++++++++++++++++++++++---------------
 vcl/source/gdi/impgraph.cxx        |    4 -
 vcl/source/gdi/pdfwriter_impl2.cxx |   11 ++--
 vcl/source/gdi/pngread.cxx         |    1 
 vcl/source/opengl/OpenGLHelper.cxx |    1 
 8 files changed, 65 insertions(+), 50 deletions(-)

New commits:
commit c43d831578e994f39fcd939ce636c0b8abaae6c3
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Oct 9 13:10:28 2015 +0200

    clang-analyzer-deadcode.DeadStores
    
    Change-Id: I8a6ea395192d31391868f44152ab3b543a07aeaa

diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index 5290f8c2..e5514f6 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -823,7 +823,6 @@ void OpenGLWatchdogThread::execute()
                 {
                     SAL_WARN("vcl.opengl", "Watchdog gave up: aborting");
                     gbWatchdogFiring = true;
-                    nUnchanged = 0;
                     std::abort();
                 }
                 // coverity[dead_error_line] - we might have caught SIGABRT and failed to exit yet
commit 1e688a945b55f5e53d06a30d97ce885e0f6bbbee
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Oct 9 13:09:23 2015 +0200

    clang-analyzer-deadcode.DeadStores
    
    Change-Id: I9e2cf9b06fcf0b0a9dfd642fa788f203ade19fe3

diff --git a/vcl/source/gdi/pngread.cxx b/vcl/source/gdi/pngread.cxx
index 87d9a3f..fd487c1 100644
--- a/vcl/source/gdi/pngread.cxx
+++ b/vcl/source/gdi/pngread.cxx
@@ -1298,7 +1298,6 @@ void PNGReaderImpl::ImplDrawScanline( sal_uInt32 nXStart, sal_uInt32 nXAdd )
                         {
                             int nLineBytes = maOrigSize.Width();
                             mpAcc->CopyScanline( nY, pTmp, BMP_FORMAT_8BIT_PAL, nLineBytes );
-                            pTmp += nLineBytes;
                         }
                         else
                         {
commit f0ae58552b2a5d27b90e382914b492f679f581b0
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Oct 9 13:04:56 2015 +0200

    clang-analyzer-deadcode.DeadStores
    
    ...assuming the success of both steps 2 and 3 should be checked (though the of
    this code is lost to history past 40d960cbdba0dbd445d624f62a523b7e78d5f5c9
    "divide pdfwriter_impl.cxx")
    
    Change-Id: Icea5de98e5a0559dbc0f837650e842fb49bc41e0

diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx
index 3650b4d..3dd7441 100644
--- a/vcl/source/gdi/pdfwriter_impl2.cxx
+++ b/vcl/source/gdi/pdfwriter_impl2.cxx
@@ -1510,13 +1510,12 @@ bool PDFWriterImpl::computeUDictionaryValue( EncHashTransporter* i_pTransporter,
                 //step6, initialize the last 16 bytes of the encrypted user password to 0
                 for(sal_uInt32 i = MD5_DIGEST_SIZE; i < sal_uInt32(io_rProperties.UValue.size()); i++)
                     io_rProperties.UValue[i] = 0;
-                //step 2
-                rtlDigestError nError = rtl_digest_updateMD5( aDigest, s_nPadString, sizeof( s_nPadString ) );
-                //step 3
-                if( nError == rtl_Digest_E_None )
-                    nError = rtl_digest_updateMD5( aDigest, &io_rProperties.DocumentIdentifier[0], sal_Int32(io_rProperties.DocumentIdentifier.size()) );
-                else
+                //steps 2 and 3
+                if (rtl_digest_updateMD5( aDigest, s_nPadString, sizeof( s_nPadString ) ) != rtl_Digest_E_None
+                    || rtl_digest_updateMD5( aDigest, &io_rProperties.DocumentIdentifier[0], sal_Int32(io_rProperties.DocumentIdentifier.size()) ) != rtl_Digest_E_None)
+                {
                     bSuccess = false;
+                }
 
                 sal_uInt8 nMD5Sum[ RTL_DIGEST_LENGTH_MD5 ];
                 rtl_digest_getMD5( aDigest, nMD5Sum, sizeof(nMD5Sum) );
commit 7ea8a4e74381de7c904ea49eabff03b4d4fd9e5f
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Oct 9 12:59:01 2015 +0200

    clang-analyzer-deadcode.DeadStores
    
    Change-Id: Ie1d3afb0b9ca59232214d9ab6da9fa761a3fd449

diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 735eab1..ecd1c8f 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -947,7 +947,6 @@ bool ImpGraphic::ImplReadEmbedded( SvStream& rIStm )
     Size            aSize;
     sal_uInt32      nId;
     sal_Int32       nType;
-    sal_Int32       nLen;
     const SvStreamEndian nOldFormat = rIStm.GetEndian();
     bool            bRet = false;
 
@@ -961,6 +960,7 @@ bool ImpGraphic::ImplReadEmbedded( SvStream& rIStm )
         VersionCompat* pCompat = new VersionCompat( rIStm, StreamMode::READ );
 
         rIStm.ReadInt32( nType );
+        sal_Int32 nLen;
         rIStm.ReadInt32( nLen );
         ReadPair( rIStm, aSize );
         ReadMapMode( rIStm, aMapMode );
@@ -976,6 +976,7 @@ bool ImpGraphic::ImplReadEmbedded( SvStream& rIStm )
 
         rIStm.SeekRel( -4L );
 
+        sal_Int32 nLen;
         rIStm.ReadInt32( nType ).ReadInt32( nLen ).ReadInt32( nWidth ).ReadInt32( nHeight );
         rIStm.ReadInt32( nMapMode ).ReadInt32( nScaleNumX ).ReadInt32( nScaleDenomX ).ReadInt32( nScaleNumY );
         rIStm.ReadInt32( nScaleDenomY ).ReadInt32( nOffsX ).ReadInt32( nOffsY );
@@ -984,7 +985,6 @@ bool ImpGraphic::ImplReadEmbedded( SvStream& rIStm )
         if( nType > 100L )
         {
             nType = OSL_SWAPDWORD( nType );
-            nLen = OSL_SWAPDWORD( nLen );
             nWidth = OSL_SWAPDWORD( nWidth );
             nHeight = OSL_SWAPDWORD( nHeight );
             nMapMode = OSL_SWAPDWORD( nMapMode );
commit 6747fa4fe8a939ad877f95bc777b29a1ec242436
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Oct 9 12:55:21 2015 +0200

    Abstract out repeated code into lambdas
    
    ...to silence a clang-analyzer-deadcode.DeadStores on the last update of nUsed
    
    Change-Id: Ib470f09155bd181b05bc0342543a36e59b8dd937

diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx
index f4bb3c8..d90d7bf 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);
commit 0cab8199f345d01bfcbf2f6a0be63b34b1dbd285
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Oct 9 12:40:36 2015 +0200

    clang-analyzer-deadcode.DeadStores
    
    nSxe, nSye were unused ever since WMFReader::GetPlaceableBound was introduced
    (seemingly, involving some copy/paste) in
    fa149f402b9222d361e79769933bc6c58101ddef "#98505# if there is no WinExt we try
    to calculate the extension instead of using (1/1) default which causes a crash
    on unix and linux"
    
    Change-Id: Ica6fb9ec1d25bd5314e73610eccef2a4df0c310f

diff --git a/vcl/source/filter/wmf/winwmf.cxx b/vcl/source/filter/wmf/winwmf.cxx
index 0566f3b..e4359ea 100644
--- a/vcl/source/filter/wmf/winwmf.cxx
+++ b/vcl/source/filter/wmf/winwmf.cxx
@@ -1697,7 +1697,7 @@ bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pStm )
                 case W_META_STRETCHDIB:
                 {
                     sal_Int32   nWinROP;
-                    sal_uInt16  nSx, nSy, nSxe, nSye, nUsage;
+                    sal_uInt16  nSx, nSy, nUsage;
                     pStm->ReadInt32( nWinROP );
 
                     if( nFunction == W_META_STRETCHDIB )
@@ -1705,9 +1705,10 @@ bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pStm )
 
                     // nSye and nSxe is the number of pixels that has to been used
                     if( nFunction == W_META_STRETCHDIB || nFunction == W_META_STRETCHBLT || nFunction == W_META_DIBSTRETCHBLT )
+                    {
+                        sal_uInt16 nSxe, nSye;
                         pStm->ReadUInt16( nSye ).ReadUInt16( nSxe );
-                    else
-                        nSye = nSxe = 0;    // set this to zero as indicator not to scale the bitmap later
+                    }
 
                     // nSy and nx is the offset of the first pixel
                     pStm->ReadUInt16( nSy ).ReadUInt16( nSx );
commit 3f74bbf4f53112db4ba9df014ee9da760898652d
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Oct 9 12:38:48 2015 +0200

    clang-analyzer-deadcode.DeadStores
    
    Change-Id: Icef974fccdc487b8abef3b1200b0b34b7be703ec

diff --git a/vcl/source/filter/wmf/winwmf.cxx b/vcl/source/filter/wmf/winwmf.cxx
index e3d59a3..0566f3b 100644
--- a/vcl/source/filter/wmf/winwmf.cxx
+++ b/vcl/source/filter/wmf/winwmf.cxx
@@ -378,7 +378,6 @@ void WMFReader::ReadRecordParams( sal_uInt16 nFunc )
             {
                 if (nPolyCount > pWMF->remainingSize() / sizeof(sal_uInt16))
                 {
-                    bRecordOk = false;
                     break;
                 }
 
commit 65cae2810d209348f92789dfc43a6abbfcaf38f9
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Oct 9 12:24:07 2015 +0200

    clang-analyzer-deadcode.DeadStores
    
    Change-Id: I4924a3cecb1e12874659eeccde51126fab4d4e45

diff --git a/vcl/source/filter/sgvtext.cxx b/vcl/source/filter/sgvtext.cxx
index 138a16e..e732eca 100644
--- a/vcl/source/filter/sgvtext.cxx
+++ b/vcl/source/filter/sgvtext.cxx
@@ -788,7 +788,7 @@ void FormatLine(UCHAR* TBuf, sal_uInt16& Index, ObjTextType& Atr0, ObjTextType&
         nChars++; Line[nChars]=R->ChrXP; // to assure AbsatzEnde is read
         Line[nChars+1]=R->ChrXP;         // as the width of CR or #0 is very small
         if (TBuf[R->Index-1]!=AbsatzEnd &&  TBuf[R->Index-1]!=TextEnd) {
-            c=GetTextChar(TBuf,R->Index,Atr0,R->Attrib,NoTrenn,false); // small correction needed, if 1st word read
+            GetTextChar(TBuf,R->Index,Atr0,R->Attrib,NoTrenn,false); // small correction needed, if 1st word read
         }
     }
 
commit 948c2d7b9fb30c5da0b0c10685828f401cb5bd03
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Oct 9 12:24:03 2015 +0200

    clang-analyzer-deadcode.DeadStores
    
    Change-Id: Ic76cf540896ba217f7df6045be31197b64298bf3

diff --git a/vcl/source/filter/sgvtext.cxx b/vcl/source/filter/sgvtext.cxx
index e05ffb3..138a16e 100644
--- a/vcl/source/filter/sgvtext.cxx
+++ b/vcl/source/filter/sgvtext.cxx
@@ -724,10 +724,10 @@ void FormatLine(UCHAR* TBuf, sal_uInt16& Index, ObjTextType& Atr0, ObjTextType&
 
     if (Border) { // separate and crush
         (*WErec0)=(*WErec); WEnChar0=WEnChar;
-        AbsEnd=false; c0=0;
+        c0=0;
         (*R)=(*WErec); nChars=WEnChar;
         (*TRrec)=(*R); TRnChar=nChars;
-        Border0=false; Border=false;
+        Border0=false;
         do {                // first check how many syllables fit
             UCHAR ct=ProcessChar(*vOut.get(),TBuf,*TRrec,Atr0,TRnChar,DoTrenn,Line,cLine);
             c=ProcessChar(*vOut.get(),TBuf,*R,Atr0,nChars,NoTrenn,Line,cLine);
commit 3589ad69d0b20d7e1f6084206f1ed577945b5427
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Oct 9 12:20:32 2015 +0200

    clang-analyzer-deadcode.DeadStores
    
    Change-Id: Iabb2d50cced788ab49d21e1aadcf5ab685107511

diff --git a/vcl/source/filter/sgvmain.cxx b/vcl/source/filter/sgvmain.cxx
index 45f69fe..67c89f4 100644
--- a/vcl/source/filter/sgvmain.cxx
+++ b/vcl/source/filter/sgvmain.cxx
@@ -816,7 +816,6 @@ bool SgfFilterSDrw( SvStream& rInp, SgfHeader&, SgfEntry&, GDIMetaFile& rMtf )
       ReadPageType( rInp, aPage );
       if(Num==1 && aPage.nList!=0L) DrawObjkList( rInp,*pOutDev );
       rInp.Seek(nCharPos);
-      nCharPos=rInp.Tell();
       ReadPageType( rInp, aPage );
     }
     if (aPage.nList!=0L) DrawObjkList(rInp,*pOutDev );


More information about the Libreoffice-commits mailing list