From 1ffba0e356608fb6dbf568248e2a953b4d7fb5d6 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 28 Sep 2017 10:33:09 +0200 Subject: loplugin:flatten check for throw in then clause also make the plugin ignore the case where we have var decl's in the clause we want to flatten, which could lead to problematic extension of variable lifetime Change-Id: I3061f7104e8c6a460bf74f5eac325a516ec50c59 Reviewed-on: https://gerrit.libreoffice.org/42889 Tested-by: Jenkins Reviewed-by: Noel Grandin --- ucb/source/ucp/file/filglob.cxx | 8 ++------ ucb/source/ucp/file/filinpstr.cxx | 3 +-- ucb/source/ucp/file/filstr.cxx | 9 ++++----- 3 files changed, 7 insertions(+), 13 deletions(-) (limited to 'ucb') diff --git a/ucb/source/ucp/file/filglob.cxx b/ucb/source/ucp/file/filglob.cxx index 83c6e2ca1a9c..04bf98cce9c0 100644 --- a/ucb/source/ucp/file/filglob.cxx +++ b/ucb/source/ucp/file/filglob.cxx @@ -571,9 +571,7 @@ namespace fileaccess { excep.Message = "the name contained invalid characters"; if(isHandled) throw excep; - else { - cancelCommandExecution( Any(excep), xEnv ); - } + cancelCommandExecution( Any(excep), xEnv ); // ioErrorCode = IOErrorCode_INVALID_CHARACTER; // cancelCommandExecution( // ioErrorCode, @@ -591,9 +589,7 @@ namespace fileaccess { excep.Message = "folder exists and overwrite forbidden"; if(isHandled) throw excep; - else { - cancelCommandExecution( Any(excep), xEnv ); - } + cancelCommandExecution( Any(excep), xEnv ); // ioErrorCode = IOErrorCode_ALREADY_EXISTING; // cancelCommandExecution( // ioErrorCode, diff --git a/ucb/source/ucp/file/filinpstr.cxx b/ucb/source/ucp/file/filinpstr.cxx index 39448e16f6c9..bacdb6f6b1b9 100644 --- a/ucb/source/ucp/file/filinpstr.cxx +++ b/ucb/source/ucp/file/filinpstr.cxx @@ -197,8 +197,7 @@ XInputStream_impl::getLength() sal_uInt64 uEndPos; if ( m_aFile.getSize(uEndPos) != osl::FileBase::E_None ) throw io::IOException( THROW_WHERE ); - else - return sal_Int64( uEndPos ); + return sal_Int64( uEndPos ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/source/ucp/file/filstr.cxx b/ucb/source/ucp/file/filstr.cxx index ce92a7dd8ae9..3a57ce65ad2d 100644 --- a/ucb/source/ucp/file/filstr.cxx +++ b/ucb/source/ucp/file/filstr.cxx @@ -250,11 +250,10 @@ XStream_impl::getPosition() sal_Int64 SAL_CALL XStream_impl::getLength() { - sal_uInt64 uEndPos; - if ( m_aFile.getSize(uEndPos) != osl::FileBase::E_None ) - throw io::IOException( THROW_WHERE ); - else - return sal_Int64( uEndPos ); + sal_uInt64 uEndPos; + if ( m_aFile.getSize(uEndPos) != osl::FileBase::E_None ) + throw io::IOException( THROW_WHERE ); + return sal_Int64( uEndPos ); } void SAL_CALL -- cgit