[Libreoffice-commits] core.git: 2 commits - sal/osl sal/qa sal/rtl solenv/gdb

Jens Carl (via logerrit) logerrit at kemper.freedesktop.org
Sat Apr 13 19:15:27 UTC 2019


 sal/osl/unx/file_misc.cxx                   |    8 +---
 sal/osl/unx/mutex.cxx                       |   14 ++-----
 sal/osl/unx/profile.cxx                     |    4 --
 sal/osl/unx/socket.cxx                      |    4 --
 sal/qa/OStringBuffer/rtl_OStringBuffer.cxx  |    6 +--
 sal/qa/osl/file/osl_File.cxx                |    5 +-
 sal/qa/osl/process/osl_Thread.cxx           |   51 +++++++++-------------------
 sal/qa/osl/security/osl_Security.cxx        |    6 +--
 sal/qa/rtl/doublelock/rtl_doublelocking.cxx |   12 ++----
 sal/qa/rtl/oustring/rtl_OUString2.cxx       |    3 -
 sal/qa/rtl/process/rtl_Process.cxx          |    3 -
 sal/rtl/random.cxx                          |    4 --
 solenv/gdb/libreoffice/basegfx.py           |   41 +++++++++++++++-------
 13 files changed, 67 insertions(+), 94 deletions(-)

New commits:
commit 3b3c10cee0d38f9396fdb6cf028ceb8917822bb7
Author:     Jens Carl <j.carl43 at gmx.de>
AuthorDate: Wed Apr 10 10:50:10 2019 -0700
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Apr 13 21:14:49 2019 +0200

    Fix Python exception in gdb pretty-printer basegfx
    
    Add single quotes around the namespace::class construct, when calling
    gdb.parse_and_eval(), otherwise this exception is thrown:
    "Python Exception <class 'gdb.error'> A syntax error in expression, near `)xxx)->count($'.:"
    The reason is a possible conflict with '::' referring a static variable
    (https://sourceware.org/gdb/onlinedocs/gdb/Variables.html).
    
    Also improved the B2DPolyPolygonPrinter::children method to avoid a
    segmentation fault, when accessing member m_value.
    
    Change-Id: I1c15a4b786e1e374c67ace445d28c1ce210a4c04
    Reviewed-on: https://gerrit.libreoffice.org/70537
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/solenv/gdb/libreoffice/basegfx.py b/solenv/gdb/libreoffice/basegfx.py
index 81901fe8dae8..c14968c91eb2 100644
--- a/solenv/gdb/libreoffice/basegfx.py
+++ b/solenv/gdb/libreoffice/basegfx.py
@@ -58,15 +58,19 @@ class B2DPolygonPrinter(object):
                               self.typename)
 
     def _count(self):
+        # It's a call into the inferior (being debugged) process.
+        # Will not work with core dumps and can cause a deadlock.
         return int(gdb.parse_and_eval(
-                '((basegfx::B2DPolygon*)%d)->count()' % self.value.address))
+                "(('basegfx::B2DPolygon' *) {})->count()".format(self.value.address)))
 
     def _isEmpty(self):
         return self._count() == 0
 
     def _hasCurves(self):
+        # It's a call into the inferior (being debugged) process.
+        # Will not work with core dumps and can cause a deadlock.
         return int(gdb.parse_and_eval(
-                '((basegfx::B2DPolygon*)%d)->areControlPointsUsed()' % self.value.address)) != 0
+                "(('basegfx::B2DPolygon' *) {})->areControlPointsUsed()".format(self.value.address))) != 0
 
     def _children(self):
         if self._hasCurves():
@@ -113,12 +117,15 @@ class B2DPolygonPrinter(object):
             #currPoint = gdb.parse_and_eval(
             #        '((basegfx::B2DPolygon*)%d)->getB2DPoint(%d)' % (
             #          self.value.address, self.index))
+
+            # It's a call into the inferior (being debugged) process.
+            # Will not work with core dumps and can cause a deadlock.
             prevControl = gdb.parse_and_eval(
-                    '((basegfx::B2DPolygon*)%d)->getPrevControlPoint(%d)' % (
-                      self.value.address, self.index))
+                    "(('basegfx::B2DPolygon' *) {})->getPrevControlPoint({:d})".format(self.value.address, self.index))
+            # It's a call into the inferior (being debugged) process.
+            # Will not work with core dumps and can cause a deadlock.
             nextControl = gdb.parse_and_eval(
-                    '((basegfx::B2DPolygon*)%d)->getNextControlPoint(%d)' % (
-                      self.value.address, self.index))
+                    "(('basegfx::B2DPolygon' *) {})->getNextControlPoint({:d})".format(self.value.address, self.index))
             self.index += 1
             return ('point %d' % (self.index-1),
                     'p: (%15f, %15f) c-1: (%15f, %15f) c1: (%15f, %15f)' %
@@ -142,21 +149,31 @@ class B2DPolyPolygonPrinter(object):
                                                      self._count())
 
     def _count(self):
+        # It's a call into the inferior (being debugged) process.
+        # Will not work with core dumps and can cause a deadlock.
         return int(gdb.parse_and_eval(
-                '((basegfx::B2DPolyPolygon*)%d)->count()' % self.value.address))
+                "(('basegfx::B2DPolyPolygon' *) {})->count()".format(self.value.address)))
 
     def _isClosed(self):
+        # It's a call into the inferior (being debugged) process.
+        # Will not work with core dumps and can cause a deadlock.
         return int(gdb.parse_and_eval(
-                '((basegfx::B2DPolyPolygon*)%d)->isClosed()' % self.value.address)) != 0
+                "(('basegfx::B2DPolyPolygon' *) {})->isClosed()".format(self.value.address))) != 0
 
     def _isEmpty(self):
         return self._count() == 0
 
     def children(self):
-        impl = self.value['mpPolyPolygon']['m_pimpl']
-        vector = self.value['mpPolyPolygon']['m_pimpl'].dereference()['m_value']['maPolygons']
-        import libstdcxx.v6.printers as std
-        return std.StdVectorPrinter("std::vector", vector).children()
+        if self.value['mpPolyPolygon']['m_pimpl'].type.code in (gdb.TYPE_CODE_PTR, gdb.TYPE_CODE_MEMBERPTR):
+            if self.value['mpPolyPolygon']['m_pimpl']:
+                try:
+                    vector = self.value['mpPolyPolygon']['m_pimpl'].dereference()['m_value']['maPolygons']
+                    import libstdcxx.v6.printers as std
+                    return std.StdVectorPrinter("std::vector", vector).children()
+                except RuntimeError:
+                    gdb.write("Cannot access memory at address " + str(self.value['mpPolyPolygon']['m_pimpl'].address))
+
+        return None
 
 printer = None
 
commit acb0cdeedafc5fd38703d4a0a545a33058f1673f
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Sat Apr 13 14:57:07 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Apr 13 21:14:34 2019 +0200

    loplugin:sequentialassign in sal
    
    Change-Id: I7bd1511a6acc105ab5b42c698c7578cfb9ce06b4
    Reviewed-on: https://gerrit.libreoffice.org/70708
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx
index 167877e5d670..31641593e781 100644
--- a/sal/osl/unx/file_misc.cxx
+++ b/sal/osl/unx/file_misc.cxx
@@ -482,9 +482,7 @@ oslFileError osl_psz_createDirectory(char const * pszPath, sal_uInt32 flags)
 
 static oslFileError osl_psz_removeDirectory( const sal_Char* pszPath )
 {
-    int nRet=0;
-
-    nRet = rmdir(pszPath);
+    int nRet = rmdir(pszPath);
 
     if ( nRet < 0 )
     {
@@ -724,9 +722,7 @@ static oslFileError osl_unlinkFile(const sal_Char* pszPath)
 
 static oslFileError osl_psz_moveFile(const sal_Char* pszPath, const sal_Char* pszDestPath)
 {
-    int nRet = 0;
-
-    nRet = rename(pszPath,pszDestPath);
+    int nRet = rename(pszPath,pszDestPath);
 
     if (nRet < 0)
     {
diff --git a/sal/osl/unx/mutex.cxx b/sal/osl/unx/mutex.cxx
index 3f7fda0c7099..72bcc370eebb 100644
--- a/sal/osl/unx/mutex.cxx
+++ b/sal/osl/unx/mutex.cxx
@@ -75,9 +75,7 @@ void SAL_CALL osl_destroyMutex(oslMutex pMutex)
 
     if ( pMutex != nullptr )
     {
-        int nRet=0;
-
-        nRet = pthread_mutex_destroy(&(pMutex->mutex));
+        int nRet = pthread_mutex_destroy(&(pMutex->mutex));
         if ( nRet != 0 )
         {
             SAL_WARN("sal.osl.mutex", "pthread_mutex_destroy failed: " << UnixErrnoString(nRet));
@@ -93,9 +91,7 @@ sal_Bool SAL_CALL osl_acquireMutex(oslMutex pMutex)
 
     if ( pMutex != nullptr )
     {
-        int nRet=0;
-
-        nRet = pthread_mutex_lock(&(pMutex->mutex));
+        int nRet = pthread_mutex_lock(&(pMutex->mutex));
         if ( nRet != 0 )
         {
             SAL_WARN("sal.osl.mutex", "pthread_mutex_lock failed: " << UnixErrnoString(nRet));
@@ -116,8 +112,7 @@ sal_Bool SAL_CALL osl_tryToAcquireMutex(oslMutex pMutex)
 
     if ( pMutex )
     {
-        int nRet = 0;
-        nRet = pthread_mutex_trylock(&(pMutex->mutex));
+        int nRet = pthread_mutex_trylock(&(pMutex->mutex));
         if ( nRet == 0  )
             result = true;
     }
@@ -131,8 +126,7 @@ sal_Bool SAL_CALL osl_releaseMutex(oslMutex pMutex)
 
     if ( pMutex )
     {
-        int nRet=0;
-        nRet = pthread_mutex_unlock(&(pMutex->mutex));
+        int nRet = pthread_mutex_unlock(&(pMutex->mutex));
         if ( nRet != 0 )
         {
             SAL_WARN("sal.osl.mutex", "pthread_mutex_unlock failed: " << UnixErrnoString(nRet));
diff --git a/sal/osl/unx/profile.cxx b/sal/osl/unx/profile.cxx
index e06ff82aef32..44e7243c4b13 100644
--- a/sal/osl/unx/profile.cxx
+++ b/sal/osl/unx/profile.cxx
@@ -491,9 +491,7 @@ sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile,
     sal_Char*       Line = nullptr;
     osl_TProfileSection* pSec;
     osl_TProfileImpl*    pProfile = nullptr;
-    osl_TProfileImpl*    pTmpProfile = nullptr;
-
-    pTmpProfile = static_cast<osl_TProfileImpl*>(Profile);
+    osl_TProfileImpl*    pTmpProfile = static_cast<osl_TProfileImpl*>(Profile);
 
     if ( pTmpProfile == nullptr )
     {
diff --git a/sal/osl/unx/socket.cxx b/sal/osl/unx/socket.cxx
index 1dd62e330029..0984acb86aae 100644
--- a/sal/osl/unx/socket.cxx
+++ b/sal/osl/unx/socket.cxx
@@ -832,9 +832,7 @@ void SAL_CALL osl_getHostnameOfHostAddr (
     const oslHostAddr   Addr,
     rtl_uString       **ustrHostname)
 {
-    const sal_Char* pHostname=nullptr;
-
-    pHostname = osl_psz_getHostnameOfHostAddr(Addr);
+    const sal_Char* pHostname = osl_psz_getHostnameOfHostAddr(Addr);
 
     rtl_uString_newFromAscii (ustrHostname, pHostname);
 }
diff --git a/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx b/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx
index a2111854850a..6d6d2034d188 100644
--- a/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx
+++ b/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx
@@ -14235,8 +14235,7 @@ namespace rtl_OStringBuffer
     public:
         bool checkIfStrBufContainAtPosTheFloat(OStringBuffer const& _sStrBuf, sal_Int32 _nLen, float _nFloat)
             {
-                OString sFloatValue;
-                sFloatValue = OString::number(_nFloat);
+                OString sFloatValue = OString::number(_nFloat);
 
                 OString sBufferString(_sStrBuf.getStr());
                 sal_Int32 nPos = sBufferString.indexOf(sFloatValue);
@@ -15385,8 +15384,7 @@ namespace rtl_OStringBuffer
     public:
         bool checkIfStrBufContainAtPosTheDouble(OStringBuffer const& _sStrBuf, sal_Int32 _nLen, double _nDouble)
             {
-                OString sDoubleValue;
-                sDoubleValue = OString::number(_nDouble);
+                OString sDoubleValue = OString::number(_nDouble);
 
                 OString sBufferString(_sStrBuf.getStr());
                 sal_Int32 nPos = sBufferString.indexOf(sDoubleValue);
diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx
index 23ae3359961d..66aa45ad35a8 100644
--- a/sal/qa/osl/file/osl_File.cxx
+++ b/sal/qa/osl/file/osl_File.cxx
@@ -3762,7 +3762,7 @@ namespace osl_DirectoryItem
             CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, nError1);
 
             DirectoryItem copyItem;
-            copyItem = rItem;               // assinment operator
+            copyItem = rItem;               // assignment operator
             FileStatus rFileStatus(osl_FileStatus_Mask_FileName);
             nError1 = copyItem.getFileStatus(rFileStatus);
             CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, nError1);
@@ -4568,8 +4568,7 @@ namespace osl_Directory
             if (_nMask == osl_VolumeInfo_Mask_FileSystemName)
             {
                 // get file system name
-                OUString aFileSysName(aNullURL);
-                aFileSysName = _aVolumeInfo.getFileSystemName();
+                OUString aFileSysName = _aVolumeInfo.getFileSystemName();
 
                 bool bRes2 = compareFileName(aFileSysName, aNullURL);
                 CPPUNIT_ASSERT_EQUAL_MESSAGE("test for getVolumeInfo function: getVolumeInfo of root directory.",
diff --git a/sal/qa/osl/process/osl_Thread.cxx b/sal/qa/osl/process/osl_Thread.cxx
index bfd17db06174..5d63f64032b6 100644
--- a/sal/qa/osl/process/osl_Thread.cxx
+++ b/sal/qa/osl/process/osl_Thread.cxx
@@ -989,11 +989,9 @@ namespace osl_Thread
                 pThread->terminate();
                 p2Thread->terminate();
 
-                sal_Int32 nValueNormal = 0;
-                nValueNormal = pThread->getValue();
+                sal_Int32 nValueNormal = pThread->getValue();
 
-                sal_Int32 nValueNormal2 = 0;
-                nValueNormal2 = p2Thread->getValue();
+                sal_Int32 nValueNormal2 = p2Thread->getValue();
 
                 OString sPrio = getPrioName(_aPriority);
                 t_print("After 10 tenth seconds\n");
@@ -1088,14 +1086,11 @@ namespace osl_Thread
                 //aBelowNormalThread->terminate();
                 //aLowestThread->terminate();
 
-                sal_Int32 nValueHighest = 0;
-                nValueHighest = aHighestThread.getValue();
+                sal_Int32 nValueHighest = aHighestThread.getValue();
 
-                sal_Int32 nValueAboveNormal = 0;
-                nValueAboveNormal = aAboveNormalThread.getValue();
+                sal_Int32 nValueAboveNormal = aAboveNormalThread.getValue();
 
-                sal_Int32 nValueNormal = 0;
-                nValueNormal = aNormalThread.getValue();
+                sal_Int32 nValueNormal = aNormalThread.getValue();
 
                 t_print("After 10 tenth seconds\n");
                 t_print("nValue in Highest Prio Thread is %d\n", static_cast<int>(nValueHighest));
@@ -1163,20 +1158,15 @@ namespace osl_Thread
                 termAndJoinThread(&pBelowNormalThread);
                 termAndJoinThread(&pLowestThread);
 
-                sal_Int32 nValueHighest = 0;
-                nValueHighest = pHighestThread.getValue();
+                sal_Int32 nValueHighest = pHighestThread.getValue();
 
-                sal_Int32 nValueAboveNormal = 0;
-                nValueAboveNormal = pAboveNormalThread.getValue();
+                sal_Int32 nValueAboveNormal = pAboveNormalThread.getValue();
 
-                sal_Int32 nValueNormal = 0;
-                nValueNormal = pNormalThread.getValue();
+                sal_Int32 nValueNormal = pNormalThread.getValue();
 
-                sal_Int32 nValueBelowNormal = 0;
-                nValueBelowNormal = pBelowNormalThread.getValue();
+                sal_Int32 nValueBelowNormal = pBelowNormalThread.getValue();
 
-                sal_Int32 nValueLowest = 0;
-                nValueLowest = pLowestThread.getValue();
+                sal_Int32 nValueLowest = pLowestThread.getValue();
 
                 t_print("After 10 tenth seconds\n");
                 t_print("nValue in Highest Prio Thread is     %d\n", static_cast<int>(nValueHighest));
@@ -1251,17 +1241,13 @@ namespace osl_Thread
                 // sal_Int32 nValueHighest  = 0;
                 // nValueHighest =  pHighestThread->getValue();
 
-                sal_Int32 nValueAboveNormal = 0;
-                nValueAboveNormal = pAboveNormalThread.getValue();
+                sal_Int32 nValueAboveNormal = pAboveNormalThread.getValue();
 
-                sal_Int32 nValueNormal = 0;
-                nValueNormal = pNormalThread.getValue();
+                sal_Int32 nValueNormal = pNormalThread.getValue();
 
-                sal_Int32 nValueBelowNormal = 0;
-                nValueBelowNormal = pBelowNormalThread.getValue();
+                sal_Int32 nValueBelowNormal = pBelowNormalThread.getValue();
 
-                sal_Int32 nValueLowest = 0;
-                nValueLowest = pLowestThread.getValue();
+                sal_Int32 nValueLowest = pLowestThread.getValue();
 
                 t_print("After 5 tenth seconds\n");
                 t_print("nValue in AboveNormal Prio Thread is %d\n", static_cast<int>(nValueAboveNormal));
@@ -1339,14 +1325,11 @@ namespace osl_Thread
                 // sal_Int32 nValueAboveNormal = 0;
                 // nValueAboveNormal = pAboveNormalThread->getValue();
 
-                sal_Int32 nValueNormal = 0;
-                nValueNormal = pNormalThread.getValue();
+                sal_Int32 nValueNormal = pNormalThread.getValue();
 
-                sal_Int32 nValueBelowNormal = 0;
-                nValueBelowNormal = pBelowNormalThread.getValue();
+                sal_Int32 nValueBelowNormal = pBelowNormalThread.getValue();
 
-                sal_Int32 nValueLowest = 0;
-                nValueLowest = pLowestThread.getValue();
+                sal_Int32 nValueLowest = pLowestThread.getValue();
 
                 t_print("After 5 tenth seconds\n");
                 t_print("nValue in Normal Prio Thread is      %d\n", static_cast<int>(nValueNormal));
diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx
index 676c15a4c086..40eef7a6b940 100644
--- a/sal/qa/osl/security/osl_Security.cxx
+++ b/sal/qa/osl/security/osl_Security.cxx
@@ -36,14 +36,12 @@
 using namespace osl;
 using namespace rtl;
 
-/** print a UNI_CODE String.
+/** print a UNICODE String.
 */
 static void printUString( const OUString & str )
 {
-    OString aString;
-
     //t_print("#printUString_u# " );
-    aString = OUStringToOString( str, RTL_TEXTENCODING_ASCII_US );
+    OString aString = OUStringToOString( str, RTL_TEXTENCODING_ASCII_US );
     t_print("%s\n", aString.getStr( ) );
 }
 
diff --git a/sal/qa/rtl/doublelock/rtl_doublelocking.cxx b/sal/qa/rtl/doublelock/rtl_doublelocking.cxx
index af70e989d6b2..17e39f79cb20 100644
--- a/sal/qa/rtl/doublelock/rtl_doublelocking.cxx
+++ b/sal/qa/rtl/doublelock/rtl_doublelocking.cxx
@@ -150,19 +150,15 @@ namespace rtl_DoubleLocking
                 pThread->join();
                 p2Thread->join();
 
-                sal_Int32 nValueOK = 0;
-                nValueOK = pThread->getOK();
+                sal_Int32 nValueOK = pThread->getOK();
 
-                sal_Int32 nValueOK2 = 0;
-                nValueOK2 = p2Thread->getOK();
+                sal_Int32 nValueOK2 = p2Thread->getOK();
 
                 std::cout << "Value in Thread #1 is " << nValueOK << "\n";
                 std::cout << "Value in Thread #2 is " << nValueOK2 << "\n";
-                sal_Int32 nValueFails = 0;
-                nValueFails = pThread->getFails();
+                sal_Int32 nValueFails = pThread->getFails();
 
-                sal_Int32 nValueFails2 = 0;
-                nValueFails2 = p2Thread->getFails();
+                sal_Int32 nValueFails2 = p2Thread->getFails();
 
                 delete pThread;
                 delete p2Thread;
diff --git a/sal/qa/rtl/oustring/rtl_OUString2.cxx b/sal/qa/rtl/oustring/rtl_OUString2.cxx
index b932e371be3d..b3e972692a46 100644
--- a/sal/qa/rtl/oustring/rtl_OUString2.cxx
+++ b/sal/qa/rtl/oustring/rtl_OUString2.cxx
@@ -125,8 +125,7 @@ private:
 
     void number_double_test_impl(double _nValue)
         {
-            OUString suValue;
-            suValue = OUString::number( _nValue );
+            OUString suValue = OUString::number( _nValue );
             OString sValue;
             sValue <<= suValue;
             printf("nDouble := %.20f  sValue := %s\n", _nValue, sValue.getStr());
diff --git a/sal/qa/rtl/process/rtl_Process.cxx b/sal/qa/rtl/process/rtl_Process.cxx
index eba07659ccff..acb8f9501f08 100644
--- a/sal/qa/rtl/process/rtl_Process.cxx
+++ b/sal/qa/rtl/process/rtl_Process.cxx
@@ -45,8 +45,7 @@ static void printUString( const OUString & str, const sal_Char * msg )
     {
         printf("#%s #printUString_u# ", msg );
     }
-    OString aString;
-    aString = OUStringToOString( str, RTL_TEXTENCODING_ASCII_US );
+    OString aString = OUStringToOString( str, RTL_TEXTENCODING_ASCII_US );
     printf("%s\n", aString.getStr( ) );
 }
 
diff --git a/sal/rtl/random.cxx b/sal/rtl/random.cxx
index 836d30889b80..c9cc0f841ea9 100644
--- a/sal/rtl/random.cxx
+++ b/sal/rtl/random.cxx
@@ -237,10 +237,8 @@ static void readPool (
 
 rtlRandomPool SAL_CALL rtl_random_createPool() SAL_THROW_EXTERN_C()
 {
-    RandomPool_Impl *pImpl = nullptr;
-
     /* try to get system random number, if it fail fall back on own pool */
-    pImpl = static_cast< RandomPool_Impl* >(rtl_allocateZeroMemory(sizeof(RandomPool_Impl)));
+    RandomPool_Impl *pImpl = static_cast< RandomPool_Impl* >(rtl_allocateZeroMemory(sizeof(RandomPool_Impl)));
     if (pImpl)
     {
         char sanity[4];


More information about the Libreoffice-commits mailing list