[Libreoffice-commits] core.git: 10 commits - opencl/source package/source registry/source sal/qa sccomp/source sot/source vcl/workben xmloff/source xmlsecurity/source

Stephan Bergmann sbergman at redhat.com
Wed Oct 7 06:44:08 PDT 2015


 opencl/source/opencl_device.cxx                 |    4 -
 package/source/zippackage/ZipPackage.cxx        |    5 +
 registry/source/reflwrit.cxx                    |   31 ++++------
 sal/qa/osl/file/osl_File.cxx                    |    4 -
 sccomp/source/solver/CoinMPSolver.cxx           |   23 +++++---
 sot/source/sdstor/stgstrms.cxx                  |    7 +-
 vcl/workben/svpclient.cxx                       |    5 -
 xmloff/source/forms/elementexport.cxx           |    1 
 xmloff/source/style/numehelp.cxx                |   68 ++++++------------------
 xmlsecurity/source/xmlsec/nss/ciphercontext.cxx |    2 
 10 files changed, 61 insertions(+), 89 deletions(-)

New commits:
commit d638ad81f8063fdf0a2133f935f2d2dfccc3db79
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 7 15:28:30 2015 +0200

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

diff --git a/vcl/workben/svpclient.cxx b/vcl/workben/svpclient.cxx
index 85ece06..ee22e60 100644
--- a/vcl/workben/svpclient.cxx
+++ b/vcl/workben/svpclient.cxx
@@ -214,9 +214,8 @@ OString MyWin::processCommand( const OString& rCommand )
         else
         {
             ssize_t nBytes = 0;
-            nBytes = write( nSocket, rCommand.getStr(), rCommand.getLength() );
-            nBytes = write( nSocket, "\n", 1 );
-            nBytes = 0;
+            write( nSocket, rCommand.getStr(), rCommand.getLength() );
+            write( nSocket, "\n", 1 );
             char buf[256];
             do
             {
commit bd60974b0a420e02fe21dbee2e50623191d0cbb1
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 7 15:27:20 2015 +0200

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

diff --git a/xmloff/source/style/numehelp.cxx b/xmloff/source/style/numehelp.cxx
index def5eec..ca01ffe 100644
--- a/xmloff/source/style/numehelp.cxx
+++ b/xmloff/source/style/numehelp.cxx
@@ -134,7 +134,6 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes(SvXMLExport& rXMLExp
                 rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_CURRENCY);
                 if (!rCurrency.isEmpty())
                     rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_CURRENCY, rCurrency);
-                bWasSetTypeAttribute = true;
             }
 
             if (bExportValue)
@@ -149,11 +148,7 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes(SvXMLExport& rXMLExp
     case util::NumberFormat::DATE:
     case util::NumberFormat::DATETIME:
         {
-            if (!bWasSetTypeAttribute)
-            {
-                rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_DATE);
-                bWasSetTypeAttribute = true;
-            }
+            rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_DATE);
             if (bExportValue)
             {
                 if ( rXMLExport.SetNullDateOnUnitConverter() )
@@ -167,11 +162,7 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes(SvXMLExport& rXMLExp
         break;
     case util::NumberFormat::TIME:
         {
-            if (!bWasSetTypeAttribute)
-            {
-                rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_TIME);
-                bWasSetTypeAttribute = true;
-            }
+            rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_TIME);
             if (bExportValue)
             {
                 OUStringBuffer sBuffer;
@@ -182,11 +173,7 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes(SvXMLExport& rXMLExp
         break;
     case util::NumberFormat::LOGICAL:
         {
-            if (!bWasSetTypeAttribute)
-            {
-                rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_BOOLEAN);
-                bWasSetTypeAttribute = true;
-            }
+            rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_BOOLEAN);
             if (bExportValue)
             {
                 double fTempValue = rValue;
@@ -215,16 +202,13 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes(SvXMLExport& rXMLExp
         break;
     case util::NumberFormat::TEXT:
         {
-            if (!bWasSetTypeAttribute)
+            rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_FLOAT);
+            if (bExportValue)
             {
-                rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_FLOAT);
-                if (bExportValue)
-                {
-                    OUString sValue( ::rtl::math::doubleToUString( rValue,
-                                rtl_math_StringFormat_Automatic,
-                                rtl_math_DecimalPlaces_Max, '.', true));
-                    rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE, sValue);
-                }
+                OUString sValue( ::rtl::math::doubleToUString( rValue,
+                            rtl_math_StringFormat_Automatic,
+                            rtl_math_DecimalPlaces_Max, '.', true));
+                rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE, sValue);
             }
         }
         break;
@@ -417,7 +401,6 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes(
                 pExport->AddAttribute(sAttrValType, XML_CURRENCY);
                 if (!rCurrency.isEmpty())
                     pExport->AddAttribute(sAttrCurrency, rCurrency);
-                bWasSetTypeAttribute = true;
             }
 
             if (bExportValue)
@@ -432,11 +415,7 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes(
     case util::NumberFormat::DATE:
     case util::NumberFormat::DATETIME:
         {
-            if (!bWasSetTypeAttribute)
-            {
-                pExport->AddAttribute(sAttrValType, XML_DATE);
-                bWasSetTypeAttribute = true;
-            }
+            pExport->AddAttribute(sAttrValType, XML_DATE);
             if (bExportValue)
             {
                 if ( pExport->SetNullDateOnUnitConverter() )
@@ -450,11 +429,7 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes(
         break;
     case util::NumberFormat::TIME:
         {
-            if (!bWasSetTypeAttribute)
-            {
-                pExport->AddAttribute(sAttrValType, XML_TIME);
-                bWasSetTypeAttribute = true;
-            }
+            pExport->AddAttribute(sAttrValType, XML_TIME);
             if (bExportValue)
             {
                 OUStringBuffer sBuffer;
@@ -465,11 +440,7 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes(
         break;
     case util::NumberFormat::LOGICAL:
         {
-            if (!bWasSetTypeAttribute)
-            {
-                pExport->AddAttribute(sAttrValType, XML_BOOLEAN);
-                bWasSetTypeAttribute = true;
-            }
+            pExport->AddAttribute(sAttrValType, XML_BOOLEAN);
             if (bExportValue)
             {
                 double fTempValue = rValue;
@@ -498,16 +469,13 @@ void XMLNumberFormatAttributesExportHelper::WriteAttributes(
         break;
     case util::NumberFormat::TEXT:
         {
-            if (!bWasSetTypeAttribute)
+            pExport->AddAttribute(sAttrValType, XML_FLOAT);
+            if (bExportValue)
             {
-                pExport->AddAttribute(sAttrValType, XML_FLOAT);
-                if (bExportValue)
-                {
-                    OUString sValue( ::rtl::math::doubleToUString( rValue,
-                                rtl_math_StringFormat_Automatic,
-                                rtl_math_DecimalPlaces_Max, '.', true));
-                    pExport->AddAttribute(sAttrValue, sValue);
-                }
+                OUString sValue( ::rtl::math::doubleToUString( rValue,
+                            rtl_math_StringFormat_Automatic,
+                            rtl_math_DecimalPlaces_Max, '.', true));
+                pExport->AddAttribute(sAttrValue, sValue);
             }
         }
         break;
commit 4c8fa775c54eb3b70972e7055dd0a2d6b760bbe1
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 7 15:18:40 2015 +0200

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

diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx
index 317afe6..a94265c 100644
--- a/xmloff/source/forms/elementexport.cxx
+++ b/xmloff/source/forms/elementexport.cxx
@@ -1512,7 +1512,6 @@ namespace xmloff
                                 m_eType = TEXT;
                         }
                     }
-                    knownType = true;
                 }
 
                 // attributes which are common to all the types:
commit 4c18bec7ed39675b9747eae51c1bcb3b26f12992
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 7 15:16:28 2015 +0200

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

diff --git a/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx b/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx
index a261627..807fe78 100644
--- a/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx
+++ b/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx
@@ -108,7 +108,7 @@ uno::Sequence< ::sal_Int8 > SAL_CALL OCipherContext::convertWithCipherContext( c
         OSL_ENSURE( nOldLastBlockLen <= m_nBlockSize, "Unexpected last block size!" );
 
         sal_Int32 nAvailableData = nOldLastBlockLen + aData.getLength();
-        sal_Int32 nToConvertLen = nAvailableData;
+        sal_Int32 nToConvertLen;
         if ( m_bEncryption || !m_bW3CPadding )
         {
             if ( nAvailableData % m_nBlockSize == 0 )
commit 1edb2a1040a7f71e8ac5e4e8e8df176b18b37d07
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 7 15:13:59 2015 +0200

    clang-analyzer-deadcode.DeadStores
    
    ...introduced with dc5383e2fa487a7599f2e317bba409dc3cde8339 "fdo#84229 - don't
    set error when seeking beyond end of valid data."
    
    Change-Id: Ic26872ce47ff27a0e1170ebc66cdf10587334192

diff --git a/sot/source/sdstor/stgstrms.cxx b/sot/source/sdstor/stgstrms.cxx
index c913beb..2471c00 100644
--- a/sot/source/sdstor/stgstrms.cxx
+++ b/sot/source/sdstor/stgstrms.cxx
@@ -431,12 +431,13 @@ bool StgStrm::Pos2Page( sal_Int32 nBytePos )
         SAL_WARN("sot", "seek to index " << nIdx <<
                  " beyond page cache size " << m_aPagesCache.size());
         // fdo#84229 - handle seek to end and back as eg. XclImpStream expects
-        nIdx = m_aPagesCache.size();
         nPage = STG_EOF;
         nOffset = 0;
         // Intriguingly in the past we didn't reset nPos to match the real
-        // length of the stream thus: nPos = nPageSize * nIdx; so retain
-        // this behavior for now.
+        // length of the stream thus:
+        //   nIdx = m_aPagesCache.size();
+        //   nPos = nPageSize * nIdx;
+        // so retain this behavior for now.
         return false;
     }
 
commit bdf9ece338b3e50ddb17b4f94fb9e7f7d8e54398
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 7 15:05:53 2015 +0200

    Actually check the return values of the various Coin* calls
    
    ...the code had been like this ever since it got introduced with
    6d492447a37ec268fb5924e7fc5631c29c67325d "118160: Use CoinMP as replacement for
    lp_solve," but it looks more plausible that the return values should be checked
    rather than be ignored.  At least, CppunitTest_sccomp_lpsolver keeps succeeding
    after the change (with --enable-coinmp).
    
    Change-Id: If450827ae034079c9ee69b4e49c55b480ac0de06

diff --git a/sccomp/source/solver/CoinMPSolver.cxx b/sccomp/source/solver/CoinMPSolver.cxx
index b650d06..5edf903 100644
--- a/sccomp/source/solver/CoinMPSolver.cxx
+++ b/sccomp/source/solver/CoinMPSolver.cxx
@@ -294,7 +294,10 @@ void SAL_CALL CoinMPSolver::solve() throw(uno::RuntimeException, std::exception)
                     pLowerBounds, pUpperBounds, pRowType, pRHS, NULL,
                     pMatrixBegin, pMatrixCount, pMatrixIndex, pMatrix,
                     NULL, NULL, NULL );
-    nResult = CoinLoadInteger( hProb, pColType );
+    if (nResult == SOLV_CALL_SUCCESS)
+    {
+        nResult = CoinLoadInteger( hProb, pColType );
+    }
 
     delete[] pColType;
     delete[] pMatrixIndex;
@@ -314,15 +317,21 @@ void SAL_CALL CoinMPSolver::solve() throw(uno::RuntimeException, std::exception)
 
     // solve model
 
-    nResult = CoinCheckProblem( hProb );
-
-    try
+    if (nResult == SOLV_CALL_SUCCESS)
     {
-        nResult = CoinOptimizeProblem( hProb, 0 );
+        nResult = CoinCheckProblem( hProb );
     }
-    catch (const CoinError& e)
+
+    if (nResult == SOLV_CALL_SUCCESS)
     {
-        throw std::runtime_error(e.message());
+        try
+        {
+            nResult = CoinOptimizeProblem( hProb, 0 );
+        }
+        catch (const CoinError& e)
+        {
+            throw std::runtime_error(e.message());
+        }
     }
 
     mbSuccess = ( nResult == SOLV_CALL_SUCCESS );
commit 040204abd72108a9c72ad6cb56b19324d1a718d6
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 7 14:34:12 2015 +0200

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

diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx
index b391f69..a99cc15 100644
--- a/sal/qa/osl/file/osl_File.cxx
+++ b/sal/qa/osl/file/osl_File.cxx
@@ -1446,11 +1446,11 @@ namespace osl_FileStatus
 
             // testDirectory is "/tmp/PID/tmpdir/"
             ::osl::Directory testDirectory( aTmpName3 );
-                ::osl::FileBase::RC nError1 = testDirectory.open();
+            testDirectory.open();
             ::rtl::OUString aFileName ("link.file");
             bool bOk = false;
             while (true) {
-                nError1 = testDirectory.getNextItem( rItem_link, 4 );
+                osl::FileBase::RC nError1 = testDirectory.getNextItem( rItem_link, 4 );
                 if (::osl::FileBase::E_None == nError1) {
                     sal_uInt32 mask_link = osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_LinkTargetURL;
                     ::osl::FileStatus   rFileStatus( mask_link );
commit 5f66de5c492168664992bcdc800506a330fe401a
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 7 14:13:57 2015 +0200

    Abstract out repeated code into a lambda
    
    ...to silence a clang-analyzer-deadcode.DeadStores on the last update of pBuffer
    
    Change-Id: I144b64c330c178f78109fefadacf62fca3765694

diff --git a/registry/source/reflwrit.cxx b/registry/source/reflwrit.cxx
index be4b15c..febfbc6 100644
--- a/registry/source/reflwrit.cxx
+++ b/registry/source/reflwrit.cxx
@@ -1114,29 +1114,24 @@ void TypeWriter::createBlop()
         pInfo = pNextInfo;
     }
 
-    // write fields
-    pBuffer += writeUINT16(pBuffer, m_fieldCount);
-    if (blopFieldsSize)
+    auto writeList = [&pBuffer](
+        sal_uInt16 count, sal_uInt8 * data, sal_uInt32 size)
     {
-        memcpy(pBuffer, pBlopFields, blopFieldsSize);
-        pBuffer += blopFieldsSize;
-    }
+        pBuffer += writeUINT16(pBuffer, count);
+        if (size != 0) {
+            memcpy(pBuffer, data, size);
+            pBuffer += size;
+        }
+    };
+
+    // write fields
+    writeList(m_fieldCount, pBlopFields, blopFieldsSize);
 
     // write methods
-    pBuffer += writeUINT16(pBuffer, m_methodCount);
-    if (blopMethodsSize)
-    {
-        memcpy(pBuffer, pBlopMethods, blopMethodsSize);
-        pBuffer += blopMethodsSize;
-    }
+    writeList(m_methodCount, pBlopMethods, blopMethodsSize);
 
     // write references
-    pBuffer += writeUINT16(pBuffer, m_referenceCount);
-    if (blopReferenceSize)
-    {
-        memcpy(pBuffer, pBlopReferences, blopReferenceSize);
-        pBuffer += blopReferenceSize;
-    }
+    writeList(m_referenceCount, pBlopReferences, blopReferenceSize);
 
     delete[] pBlopFields;
     delete[] pBlopMethods;
commit db34ab81ae170cf9ec1c4421e0f05d65747caa3e
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 7 14:05:50 2015 +0200

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

diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 445b0df..c0d9666 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -496,12 +496,12 @@ void ZipPackage::getZipFileContents()
     ZipPackageStream *pPkgStream;
     ZipPackageFolder *pPkgFolder, *pCurrent;
     OUString sTemp, sDirName;
-    sal_Int32 nOldIndex, nIndex, nStreamIndex;
+    sal_Int32 nOldIndex, nStreamIndex;
     FolderHash::iterator aIter;
 
     while (xEnum->hasMoreElements())
     {
-        nIndex = nOldIndex = 0;
+        nOldIndex = 0;
         pCurrent = m_pRootFolder;
         const ZipEntry & rEntry = *xEnum->nextElement();
         OUString rName = rEntry.sPath;
@@ -524,6 +524,7 @@ void ZipPackage::getZipFileContents()
 
         if ( pCurrent == m_pRootFolder )
         {
+            sal_Int32 nIndex;
             while ( ( nIndex = rName.indexOf( '/', nOldIndex ) ) != -1 )
             {
                 sTemp = rName.copy ( nOldIndex, nIndex - nOldIndex );
commit 93fff4ba2ff6d70473ed81f53c438a1488e5c2c2
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 7 14:04:43 2015 +0200

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

diff --git a/opencl/source/opencl_device.cxx b/opencl/source/opencl_device.cxx
index 491323d..c04fb4b 100644
--- a/opencl/source/opencl_device.cxx
+++ b/opencl/source/opencl_device.cxx
@@ -485,9 +485,8 @@ ds_device getDeviceSelection(const char* sProfilePath, bool bForceSelection)
     if (!bIsDeviceSelected || bForceSelection)
     {
         /* Setup */
-        ds_status status;
         ds_profile* profile = NULL;
-        status = initDSProfile(&profile, "LibreOffice v0.1");
+        initDSProfile(&profile, "LibreOffice v0.1");
 
         if (!profile)
         {
@@ -499,6 +498,7 @@ ds_device getDeviceSelection(const char* sProfilePath, bool bForceSelection)
         /* Try reading scores from file */
         std::string tmpStr(sProfilePath);
         const char* fileName = tmpStr.append("sc_opencl_device_profile.dat").c_str();
+        ds_status status;
         if (!bForceSelection)
         {
             status = readProfileFromFile(profile, deserializeScore, fileName);


More information about the Libreoffice-commits mailing list