[Libreoffice-commits] core.git: package/source

Michael Stahl mstahl at redhat.com
Fri Oct 24 05:03:41 PDT 2014


 package/source/xstor/ocompinstream.cxx |   31 ++-----------------------------
 package/source/xstor/oseekinstream.cxx |   14 ++++----------
 2 files changed, 6 insertions(+), 39 deletions(-)

New commits:
commit 95c798409acf491cd43530215ade8f403ad96579
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Oct 24 13:57:23 2014 +0200

    package: OInputCompStream::m_xStream is never null
    
    ... as proven by the un-checked dereference in the dispose() method
    called from the dtor; simplify based on that and assert in ctor.
    
    Change-Id: Id369b80bd89fa59d99b209796c33acb39cbb10f3

diff --git a/package/source/xstor/ocompinstream.cxx b/package/source/xstor/ocompinstream.cxx
index bf6b186..dad94aa 100644
--- a/package/source/xstor/ocompinstream.cxx
+++ b/package/source/xstor/ocompinstream.cxx
@@ -43,7 +43,7 @@ OInputCompStream::OInputCompStream( OWriteStream_Impl& aImpl,
     if ( !m_pImpl->m_rMutexRef.Is() )
         throw uno::RuntimeException(); // just a disaster
 
-    OSL_ENSURE( xStream.is(), "No stream is provided!\n" );
+    assert(m_xStream.is());
 }
 
 OInputCompStream::OInputCompStream( uno::Reference < io::XInputStream > xStream,
@@ -57,7 +57,7 @@ OInputCompStream::OInputCompStream( uno::Reference < io::XInputStream > xStream,
 , m_bDisposed( false )
 , m_nStorageType( nStorageType )
 {
-    OSL_ENSURE( xStream.is(), "No stream is provided!\n" );
+    assert(m_xStream.is());
 }
 
 OInputCompStream::~OInputCompStream()
@@ -119,12 +119,6 @@ sal_Int32 SAL_CALL OInputCompStream::readBytes( uno::Sequence< sal_Int8 >& aData
         throw lang::DisposedException();
     }
 
-    if ( !m_xStream.is() )
-    {
-        SAL_INFO("package.xstor", "No stream!");
-        throw uno::RuntimeException();
-    }
-
     return m_xStream->readBytes( aData, nBytesToRead );
 }
 
@@ -141,12 +135,6 @@ sal_Int32 SAL_CALL OInputCompStream::readSomeBytes( uno::Sequence< sal_Int8 >& a
         throw lang::DisposedException();
     }
 
-    if ( !m_xStream.is() )
-    {
-        SAL_INFO("package.xstor", "No stream!");
-        throw uno::RuntimeException();
-    }
-
     return m_xStream->readSomeBytes( aData, nMaxBytesToRead );
 
 }
@@ -164,12 +152,6 @@ void SAL_CALL OInputCompStream::skipBytes( sal_Int32 nBytesToSkip )
         throw lang::DisposedException();
     }
 
-    if ( !m_xStream.is() )
-    {
-        SAL_INFO("package.xstor", "No stream!");
-        throw uno::RuntimeException();
-    }
-
     m_xStream->skipBytes( nBytesToSkip );
 
 }
@@ -186,12 +168,6 @@ sal_Int32 SAL_CALL OInputCompStream::available(  )
         throw lang::DisposedException();
     }
 
-    if ( !m_xStream.is() )
-    {
-        SAL_INFO("package.xstor", "No stream!");
-        throw uno::RuntimeException();
-    }
-
     return m_xStream->available();
 
 }
@@ -214,9 +190,6 @@ uno::Reference< io::XInputStream > SAL_CALL OInputCompStream::getInputStream()
         throw lang::DisposedException();
     }
 
-    if ( !m_xStream.is() )
-        return uno::Reference< io::XInputStream >();
-
     return uno::Reference< io::XInputStream >( static_cast< io::XInputStream* >( this ), uno::UNO_QUERY );
 }
 
diff --git a/package/source/xstor/oseekinstream.cxx b/package/source/xstor/oseekinstream.cxx
index cf5db72..bdd7f60 100644
--- a/package/source/xstor/oseekinstream.cxx
+++ b/package/source/xstor/oseekinstream.cxx
@@ -32,11 +32,8 @@ OInputSeekStream::OInputSeekStream( OWriteStream_Impl& pImpl,
                                     sal_Int32 nStorageType )
 : OInputCompStream( pImpl, xStream, aProps, nStorageType )
 {
-    if ( m_xStream.is() )
-    {
-        m_xSeekable = uno::Reference< io::XSeekable >( m_xStream, uno::UNO_QUERY );
-        OSL_ENSURE( m_xSeekable.is(), "No seeking support!\n" );
-    }
+    m_xSeekable = uno::Reference< io::XSeekable >( m_xStream, uno::UNO_QUERY );
+    OSL_ENSURE( m_xSeekable.is(), "No seeking support!\n" );
 }
 
 OInputSeekStream::OInputSeekStream( uno::Reference < io::XInputStream > xStream,
@@ -44,11 +41,8 @@ OInputSeekStream::OInputSeekStream( uno::Reference < io::XInputStream > xStream,
                                     sal_Int32 nStorageType )
 : OInputCompStream( xStream, aProps, nStorageType )
 {
-    if ( m_xStream.is() )
-    {
-        m_xSeekable = uno::Reference< io::XSeekable >( m_xStream, uno::UNO_QUERY );
-        OSL_ENSURE( m_xSeekable.is(), "No seeking support!\n" );
-    }
+    m_xSeekable = uno::Reference< io::XSeekable >( m_xStream, uno::UNO_QUERY );
+    OSL_ENSURE( m_xSeekable.is(), "No seeking support!\n" );
 }
 
 OInputSeekStream::~OInputSeekStream()


More information about the Libreoffice-commits mailing list