[Libreoffice-commits] core.git: onlineupdate/source sal/osl sc/source vcl/quartz

Noel Grandin noel.grandin at collabora.co.uk
Tue Jun 20 07:52:04 UTC 2017


 onlineupdate/source/update/updater/updater.cxx |    4 ----
 sal/osl/unx/file.cxx                           |   13 -------------
 sal/osl/unx/thread.cxx                         |    9 +++------
 sal/osl/w32/file.cxx                           |    6 ------
 sc/source/filter/starcalc/collect.cxx          |    2 --
 vcl/quartz/salgdicommon.cxx                    |    9 +++------
 6 files changed, 6 insertions(+), 37 deletions(-)

New commits:
commit 05f67637fc4f71750dda46fccf0bed5b3fd99233
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Jun 20 08:52:10 2017 +0200

    new cannot return nullptr
    
    unless we are using std::nothrow
    
    Change-Id: I3bdd13c8ce18f4e977f18ee5196311bf4fc62de0
    Reviewed-on: https://gerrit.libreoffice.org/38998
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/onlineupdate/source/update/updater/updater.cxx b/onlineupdate/source/update/updater/updater.cxx
index d32e6916cb12..01ca1a2475a9 100644
--- a/onlineupdate/source/update/updater/updater.cxx
+++ b/onlineupdate/source/update/updater/updater.cxx
@@ -315,10 +315,6 @@ get_full_path(const NS_tchar *relpath)
     size_t lendestpath = NS_tstrlen(destpath);
     size_t lenrelpath = NS_tstrlen(relpath);
     NS_tchar *s = new NS_tchar[lendestpath + lenrelpath + 2];
-    if (!s)
-    {
-        return nullptr;
-    }
 
     NS_tchar *c = s;
 
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index 9d7b31d3a7d4..333d2459b351 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -734,8 +734,6 @@ oslFileHandle osl::detail::createFileHandleFromFD( int fd )
         return nullptr; // EBADF
 
     FileHandle_Impl * pImpl = new FileHandle_Impl (fd);
-    if (pImpl == nullptr)
-        return nullptr; // ENOMEM
 
     // assume writeable
     pImpl->m_state |= FileHandle_Impl::STATE_WRITEABLE;
@@ -809,11 +807,6 @@ openMemoryAsFile( void *address, size_t size, oslFileHandle *pHandle, const char
 {
     oslFileError eRet;
     FileHandle_Impl * pImpl = new FileHandle_Impl (-1, FileHandle_Impl::KIND_MEM, path);
-    if (!pImpl)
-    {
-        eRet = oslTranslateFileError (OSL_FET_ERROR, ENOMEM);
-        return eRet;
-    }
     pImpl->m_size = sal::static_int_cast< sal_uInt64 >(size);
 
     *pHandle = (oslFileHandle)(pImpl);
@@ -1015,12 +1008,6 @@ openFilePath( const char *cpFilePath, oslFileHandle* pHandle, sal_uInt32 uFlags,
 
     /* allocate memory for impl structure */
     FileHandle_Impl * pImpl = new FileHandle_Impl (fd, FileHandle_Impl::KIND_FD, cpFilePath);
-    if (!pImpl)
-    {
-        eRet = oslTranslateFileError (OSL_FET_ERROR, ENOMEM);
-        (void) close(fd);
-        return eRet;
-    }
     if (flags & O_RDWR)
         pImpl->m_state |= FileHandle_Impl::STATE_WRITEABLE;
     pImpl->m_size = sal::static_int_cast< sal_uInt64 >(aFileStat.st_size);
diff --git a/sal/osl/unx/thread.cxx b/sal/osl/unx/thread.cxx
index 2fb488a48b57..3e6b36a2c8ca 100644
--- a/sal/osl/unx/thread.cxx
+++ b/sal/osl/unx/thread.cxx
@@ -148,13 +148,10 @@ static void osl_thread_init_Impl()
 Thread_Impl* osl_thread_construct_Impl()
 {
     Thread_Impl* pImpl = new Thread_Impl;
-    if (pImpl)
-    {
-        memset (pImpl, 0, sizeof(Thread_Impl));
+    memset (pImpl, 0, sizeof(Thread_Impl));
 
-        pthread_mutex_init (&(pImpl->m_Lock), PTHREAD_MUTEXATTR_DEFAULT);
-        pthread_cond_init  (&(pImpl->m_Cond), PTHREAD_CONDATTR_DEFAULT);
-    }
+    pthread_mutex_init (&(pImpl->m_Lock), PTHREAD_MUTEXATTR_DEFAULT);
+    pthread_cond_init  (&(pImpl->m_Cond), PTHREAD_CONDATTR_DEFAULT);
     return pImpl;
 }
 
diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx
index d7ef5623cd4e..97f6d8fe6d33 100644
--- a/sal/osl/w32/file.cxx
+++ b/sal/osl/w32/file.cxx
@@ -677,12 +677,6 @@ SAL_CALL osl_createFileHandleFromOSHandle (
         return nullptr; // EINVAL
 
     FileHandle_Impl * pImpl = new FileHandle_Impl(hFile);
-    if (pImpl == nullptr)
-    {
-        // cleanup and fail
-        (void) ::CloseHandle(hFile);
-        return nullptr; // ENOMEM
-    }
 
     /* check for regular file */
     if (FILE_TYPE_DISK == GetFileType(hFile))
diff --git a/sc/source/filter/starcalc/collect.cxx b/sc/source/filter/starcalc/collect.cxx
index dbb4c10f63a2..3ed51bfba774 100644
--- a/sc/source/filter/starcalc/collect.cxx
+++ b/sc/source/filter/starcalc/collect.cxx
@@ -78,8 +78,6 @@ bool ScCollection::AtInsert(sal_uInt16 nIndex, ScDataObject* pScDataObject)
         if (nCount == nLimit)
         {
             ScDataObject** pNewItems = new ScDataObject*[nLimit + nDelta];
-            if (!pNewItems)
-                return false;
             nLimit = sal::static_int_cast<sal_uInt16>( nLimit + nDelta );
             memcpy(pNewItems, pItems, nCount * sizeof(ScDataObject*));
             delete[] pItems;
diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx
index 2f36c76d4303..73cd294104ce 100644
--- a/vcl/quartz/salgdicommon.cxx
+++ b/vcl/quartz/salgdicommon.cxx
@@ -1714,13 +1714,10 @@ namespace {
 CGPoint* makeCGptArray(sal_uInt32 nPoints, const SalPoint* pPtAry)
 {
     CGPoint *CGpoints = new CGPoint[nPoints];
-    if ( CGpoints )
+    for(sal_uLong i=0;i<nPoints;i++)
     {
-        for(sal_uLong i=0;i<nPoints;i++)
-        {
-            CGpoints[i].x = pPtAry[i].mnX;
-            CGpoints[i].y = pPtAry[i].mnY;
-        }
+        CGpoints[i].x = pPtAry[i].mnX;
+        CGpoints[i].y = pPtAry[i].mnY;
     }
     return CGpoints;
 }


More information about the Libreoffice-commits mailing list