From 430e19e4f9c24985f855d5e607aaef63d110ddeb Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 10 Oct 2014 16:13:15 +0100 Subject: coverity#1241375 Uncaught exception and coverity#1241356 Uncaught exception coverity#1241415 Uncaught exception coverity#1241449 Uncaught exception coverity#1241146 Uncaught exception coverity#1241169 Uncaught exception coverity#1241408 Uncaught exception coverity#1241452 Uncaught exception coverity#1241443 Uncaught exception coverity#1241236 Uncaught exception coverity#1241157 Uncaught exception coverity#1241283 Uncaught exception coverity#1241409 Uncaught exception coverity#1241229 Uncaught exception coverity#1241387 Uncaught exception coverity#1241050 Uncaught exception coverity#1241371 Uncaught exception coverity#1241048 Uncaught exception coverity#1241112 Uncaught exception coverity#1241351 Uncaught exception coverity#1241370 Uncaught exception coverity#1241329 Uncaught exception coverity#1241162 Uncaught exception coverity#1241103 Uncaught exception coverity#1241342 Uncaught exception coverity#1241271 Uncaught exception coverity#1241219 Uncaught exception coverity#1241245 Uncaught exception Change-Id: I3418bb54b5c385110201a99a339eba0d0d3048f5 --- ucb/source/ucp/gio/gio_content.cxx | 26 ++++++++++++++++++++++++++ ucb/source/ucp/gio/gio_content.hxx | 3 +++ ucb/source/ucp/gio/gio_inputstream.cxx | 4 ++-- ucb/source/ucp/gio/gio_outputstream.cxx | 4 ++-- ucb/source/ucp/gio/gio_seekable.cxx | 6 +++--- 5 files changed, 36 insertions(+), 7 deletions(-) diff --git a/ucb/source/ucp/gio/gio_content.cxx b/ucb/source/ucp/gio/gio_content.cxx index 2f71f03d903b..96dbd72e016f 100644 --- a/ucb/source/ucp/gio/gio_content.cxx +++ b/ucb/source/ucp/gio/gio_content.cxx @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -58,6 +59,7 @@ #include #include +#include #include #include #include @@ -283,6 +285,30 @@ uno::Any convertToException(GError *pError, const uno::Reference< uno::XInterfac return aRet; } +void convertToIOException(GError *pError, const uno::Reference< uno::XInterface >& rContext) + throw( io::IOException, uno::RuntimeException, std::exception ) +{ + try + { + convertToException(pError, rContext); + } + catch (const io::IOException&) + { + throw; + } + catch (const uno::RuntimeException&) + { + throw; + } + catch (const uno::Exception& e) + { + css::uno::Any a(cppu::getCaughtException()); + throw css::lang::WrappedTargetException( + "wrapped Exception " + e.Message, + css::uno::Reference(), a); + } +} + uno::Any Content::mapGIOError( GError *pError ) { if (!pError) diff --git a/ucb/source/ucp/gio/gio_content.hxx b/ucb/source/ucp/gio/gio_content.hxx index fd40d200a234..ac42a66bd3c7 100644 --- a/ucb/source/ucp/gio/gio_content.hxx +++ b/ucb/source/ucp/gio/gio_content.hxx @@ -56,6 +56,9 @@ namespace gio com::sun::star::uno::Any convertToException(GError *pError, const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& rContext, bool bThrow=true); +void convertToIOException(GError *pError, + const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& rContext) + throw (css::io::IOException, css::uno::RuntimeException, std::exception); class ContentProvider; class Content : public ::ucbhelper::ContentImplHelper, public com::sun::star::ucb::XContentCreator diff --git a/ucb/source/ucp/gio/gio_inputstream.cxx b/ucb/source/ucp/gio/gio_inputstream.cxx index 49b6b386b3c7..4a14f22c4b15 100644 --- a/ucb/source/ucp/gio/gio_inputstream.cxx +++ b/ucb/source/ucp/gio/gio_inputstream.cxx @@ -66,7 +66,7 @@ void SAL_CALL InputStream::skipBytes( sal_Int32 nBytesToSkip ) GError *pError=NULL; if (!g_seekable_seek(G_SEEKABLE(mpStream), nBytesToSkip, G_SEEK_CUR, NULL, &pError)) - convertToException(pError, static_cast< cppu::OWeakObject * >(this)); + convertToIOException(pError, static_cast< cppu::OWeakObject * >(this)); } sal_Int32 SAL_CALL InputStream::readBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) @@ -88,7 +88,7 @@ sal_Int32 SAL_CALL InputStream::readBytes( uno::Sequence< sal_Int8 >& aData, sal gsize nBytesRead = 0; GError *pError=NULL; if (!g_input_stream_read_all(G_INPUT_STREAM(mpStream), aData.getArray(), nBytesToRead, &nBytesRead, NULL, &pError)) - convertToException(pError, static_cast< cppu::OWeakObject * >(this)); + convertToIOException(pError, static_cast< cppu::OWeakObject * >(this)); aData.realloc(nBytesRead); return nBytesRead; } diff --git a/ucb/source/ucp/gio/gio_outputstream.cxx b/ucb/source/ucp/gio/gio_outputstream.cxx index b4e4c1291392..d8cf60f9aca6 100644 --- a/ucb/source/ucp/gio/gio_outputstream.cxx +++ b/ucb/source/ucp/gio/gio_outputstream.cxx @@ -49,7 +49,7 @@ void SAL_CALL OutputStream::writeBytes( const com::sun::star::uno::Sequence< sal GError *pError=NULL; if (!g_output_stream_write_all(G_OUTPUT_STREAM(mpStream), rData.getConstArray(), rData.getLength(), NULL, NULL, &pError)) - convertToException(pError, static_cast< cppu::OWeakObject * >(this)); + convertToIOException(pError, static_cast< cppu::OWeakObject * >(this)); } void SAL_CALL OutputStream::flush( void ) @@ -61,7 +61,7 @@ void SAL_CALL OutputStream::flush( void ) GError *pError=NULL; if (!g_output_stream_flush(G_OUTPUT_STREAM(mpStream), NULL, &pError)) - convertToException(pError, static_cast< cppu::OWeakObject * >(this)); + convertToIOException(pError, static_cast< cppu::OWeakObject * >(this)); } void SAL_CALL OutputStream::closeOutput( void ) diff --git a/ucb/source/ucp/gio/gio_seekable.cxx b/ucb/source/ucp/gio/gio_seekable.cxx index ba338c02f4c9..940375dbd4e9 100644 --- a/ucb/source/ucp/gio/gio_seekable.cxx +++ b/ucb/source/ucp/gio/gio_seekable.cxx @@ -51,7 +51,7 @@ void SAL_CALL Seekable::truncate( void ) GError *pError=NULL; if (!g_seekable_truncate(mpStream, 0, NULL, &pError)) - convertToException(pError, static_cast< cppu::OWeakObject * >(this)); + convertToIOException(pError, static_cast< cppu::OWeakObject * >(this)); } void SAL_CALL Seekable::seek( sal_Int64 location ) @@ -66,7 +66,7 @@ void SAL_CALL Seekable::seek( sal_Int64 location ) GError *pError=NULL; if (!g_seekable_seek(mpStream, location, G_SEEK_SET, NULL, &pError)) - convertToException(pError, static_cast< cppu::OWeakObject * >(this)); + convertToIOException(pError, static_cast< cppu::OWeakObject * >(this)); } sal_Int64 SAL_CALL Seekable::getPosition() throw( io::IOException, uno::RuntimeException, std::exception ) @@ -104,7 +104,7 @@ sal_Int64 SAL_CALL Seekable::getLength() throw( io::IOException, uno::RuntimeExc GError *pError=NULL; sal_Int64 nCurr = getPosition(); if (!g_seekable_seek(mpStream, 0, G_SEEK_END, NULL, &pError)) - convertToException(pError, static_cast< cppu::OWeakObject * >(this)); + convertToIOException(pError, static_cast< cppu::OWeakObject * >(this)); nSize = getPosition(); seek(nCurr); bOk = true; -- cgit