[Libreoffice-commits] .: Branch 'libreoffice-3-4' - 5 commits - sal/osl

Thorsten Behrens thorsten at kemper.freedesktop.org
Thu Apr 14 03:28:08 PDT 2011


 sal/osl/unx/mutex.c   |    6 +++---
 sal/osl/unx/pipe.c    |    4 +---
 sal/osl/unx/process.c |   15 +++++++++++++--
 sal/osl/unx/profile.c |   13 ++++++++-----
 sal/osl/unx/socket.c  |   12 +++---------
 5 files changed, 28 insertions(+), 22 deletions(-)

New commits:
commit a321df520200bbe8fc1c6c1e3974f53baa652c73
Author: Julien Chaffraix <julien.chaffraix at gmail.com>
Date:   Tue Apr 12 07:59:00 2011 -0700

    No need to check out execv return value.
    
    If we ever return from execv, it is an error and the code already handle that.
    This fixes a dead assignment warning under CLang++.

diff --git a/sal/osl/unx/process.c b/sal/osl/unx/process.c
index b41301c..7d65b54 100644
--- a/sal/osl/unx/process.c
+++ b/sal/osl/unx/process.c
@@ -544,8 +544,9 @@ static void ChildStatusProc(void *pData)
                 if (stdError[1] != -1) close( stdError[1] );
             }
 
-            pid=execv(data.m_pszArgs[0], (sal_Char **)data.m_pszArgs);
-
+            // No need to check the return value of execv. If we return from
+            // it, an error has occurred.
+            execv(data.m_pszArgs[0], (sal_Char **)data.m_pszArgs);
         }
 
         OSL_TRACE("Failed to exec, errno=%d (%s)\n", errno, strerror(errno));
commit 702be0bff5fb9ebbd3367ba72d472677e1b7f6eb
Author: Julien Chaffraix <julien.chaffraix at gmail.com>
Date:   Tue Apr 12 06:56:47 2011 -0700

    Fixed some false positives 'dead assignments' seen in CLang++
    
    We removed the OSL_DEBUG_LEVEL > 1 code and replace them with OSL_TRACE.
    This should provide the same coverage and remove CLang++ complains.

diff --git a/sal/osl/unx/pipe.c b/sal/osl/unx/pipe.c
index 38a1413..1ae6fb4 100644
--- a/sal/osl/unx/pipe.c
+++ b/sal/osl/unx/pipe.c
@@ -359,12 +359,10 @@ void SAL_CALL osl_closePipe( oslPipe pPipe )
         len = sizeof(addr);
 
         nRet = connect( fd, (struct sockaddr *)&addr, len);
-#if OSL_DEBUG_LEVEL > 1
         if ( nRet < 0 )
         {
-            perror("connect in osl_destroyPipe");
+            OSL_TRACE("connect in osl_destroyPipe failed with error: %s", strerror(errno));
         }
-#endif /* OSL_DEBUG_LEVEL */
         close(fd);
     }
 #endif /* LINUX */
diff --git a/sal/osl/unx/socket.c b/sal/osl/unx/socket.c
index 3f31779..b9fb92e 100644
--- a/sal/osl/unx/socket.c
+++ b/sal/osl/unx/socket.c
@@ -1705,12 +1705,10 @@ void SAL_CALL osl_closeSocket(oslSocket pSocket)
         socklen_t nSockLen = sizeof(s.aSockAddr);
 
         nRet = getsockname(nFD, &s.aSockAddr, &nSockLen);
-#if OSL_DEBUG_LEVEL > 1
         if ( nRet < 0 )
         {
-            perror("getsockname");
+            OSL_TRACE("getsockname call failed with error: %s", strerror(errno));
         }
-#endif /* OSL_DEBUG_LEVEL */
 
         if ( s.aSockAddr.sa_family == AF_INET )
         {
@@ -1720,20 +1718,16 @@ void SAL_CALL osl_closeSocket(oslSocket pSocket)
             }
 
             nConnFD = socket(AF_INET, SOCK_STREAM, 0);
-#if OSL_DEBUG_LEVEL > 1
             if ( nConnFD < 0 )
             {
-                perror("socket");
+                OSL_TRACE("socket call failed with error: %s", strerror(errno));
             }
-#endif /* OSL_DEBUG_LEVEL */
 
             nRet = connect(nConnFD, &s.aSockAddr, sizeof(s.aSockAddr));
-#if OSL_DEBUG_LEVEL > 1
             if ( nRet < 0 )
             {
-                perror("connect");
+                OSL_TRACE("connect call failed with error: %s", strerror(errno));
             }
-#endif /* OSL_DEBUG_LEVEL */
             close(nConnFD);
         }
         pSocket->m_bIsAccepting = sal_False;
commit e437226fc306041dba92b8d28c604e7f4262928d
Author: Julien Chaffraix <julien.chaffraix at gmail.com>
Date:   Tue Apr 12 06:40:24 2011 -0700

    Fixed a potential null-dereferencing error in osl_closeProfile
    
    Store the new profile in a temporary variable and assign
    it to the old profile after we have checked if it is null.
    Seen with CLang++.

diff --git a/sal/osl/unx/profile.c b/sal/osl/unx/profile.c
index 7c7b04c..c56c8bb 100644
--- a/sal/osl/unx/profile.c
+++ b/sal/osl/unx/profile.c
@@ -274,6 +274,7 @@ static oslProfile SAL_CALL osl_psz_openProfile(const sal_Char *pszProfileName, o
 sal_Bool SAL_CALL osl_closeProfile(oslProfile Profile)
 {
     osl_TProfileImpl* pProfile = (osl_TProfileImpl*)Profile;
+    osl_TProfileImpl* pTmpProfile;
 
 #ifdef TRACE_OSL_PROFILE
     OSL_TRACE("In  osl_closeProfile\n");
@@ -303,22 +304,22 @@ sal_Bool SAL_CALL osl_closeProfile(oslProfile Profile)
 
     if ( ! ( pProfile->m_Flags & osl_Profile_READLOCK ) && ( pProfile->m_Flags & FLG_MODIFIED ) )
     {
-        pProfile = acquireProfile(Profile,sal_True);
+        pTmpProfile = acquireProfile(Profile,sal_True);
 
-        if ( pProfile != 0 )
+        if ( pTmpProfile != 0 )
         {
-            sal_Bool bRet = storeProfile(pProfile, sal_True);
+            sal_Bool bRet = storeProfile(pTmpProfile, sal_True);
             OSL_ASSERT(bRet);
             (void)bRet;
         }
     }
     else
     {
-        pProfile = acquireProfile(Profile,sal_False);
+        pTmpProfile = acquireProfile(Profile,sal_False);
     }
 
 
-    if ( pProfile == 0 )
+    if ( pTmpProfile == 0 )
     {
         pthread_mutex_unlock(&(pProfile->m_AccessLock));
 #ifdef TRACE_OSL_PROFILE
@@ -327,6 +328,8 @@ sal_Bool SAL_CALL osl_closeProfile(oslProfile Profile)
         return sal_False;
     }
 
+    pProfile = pTmpProfile;
+
     if (pProfile->m_pFile != NULL)
         closeFileImpl(pProfile->m_pFile,pProfile->m_Flags);
 
commit 7d0d1f658a970574c663c46459cd2520a8696e37
Author: Julien Chaffraix <julien.chaffraix at gmail.com>
Date:   Tue Apr 12 00:00:47 2011 -0700

    Added handling for the write errors in receiveFdPipe.
    
    Fixed a dead assignment in process.c reported by CLang++

diff --git a/sal/osl/unx/process.c b/sal/osl/unx/process.c
index d21b1b7..b41301c 100644
--- a/sal/osl/unx/process.c
+++ b/sal/osl/unx/process.c
@@ -376,6 +376,16 @@ static oslSocket receiveFdPipe(int PipeFD)
     OSL_TRACE("receiveFdPipe : writing back %i",nRetCode);
     nRead=write(PipeFD,&nRetCode,sizeof(nRetCode));
 
+    if ( nRead < 0 )
+    {
+        OSL_TRACE("write failed (%s)", strerror(errno));
+    }
+    else if ( nRead != sizeof(nRetCode) )
+    {
+        // TODO: Handle this case.
+        OSL_TRACE("partial write: wrote %d out of %d)", nRead, sizeof(nRetCode));
+    }
+
 #if defined(IOCHANNEL_TRANSFER_BSD_RENO)
     free(cmptr);
 #endif
commit 7654c346ec58955e14253d13bf3bd9eb4ce4a3e6
Author: Julien Chaffraix <julien.chaffraix at gmail.com>
Date:   Thu Apr 14 12:06:02 2011 +0200

    Added error handling for pthread_mutexattr_settype.
    
    This fixes a dead assignment reported by CLang++.

diff --git a/sal/osl/unx/mutex.c b/sal/osl/unx/mutex.c
index c44b332..d4ca66d 100644
--- a/sal/osl/unx/mutex.c
+++ b/sal/osl/unx/mutex.c
@@ -72,11 +72,11 @@ oslMutex SAL_CALL osl_createMutex()
     pthread_mutexattr_init(&aMutexAttr);
 
     nRet = pthread_mutexattr_settype(&aMutexAttr, PTHREAD_MUTEX_RECURSIVE);
-    
-    nRet = pthread_mutex_init(&(pMutex->mutex), &aMutexAttr);
+    if( nRet == 0 )
+        nRet = pthread_mutex_init(&(pMutex->mutex), &aMutexAttr);
     if ( nRet != 0 )
     {
-        OSL_TRACE("osl_createMutex : mutex init failed. Errno: %d; %s\n",  
+        OSL_TRACE("osl_createMutex : mutex init/setattr failed. Errno: %d; %s\n",
                   nRet, strerror(nRet));
         
         free(pMutex);


More information about the Libreoffice-commits mailing list