From 2ee336fb556ceb1d7e1ee8017c27539da7fe543b Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Fri, 19 Dec 2014 11:07:02 +0100 Subject: fdo#39440 sal: reduce scope of local variables This addresses some cppcheck warnings. Change-Id: Id5f90757571e76a2c05a4cbd37020e1f6a6b2033 Reviewed-on: https://gerrit.libreoffice.org/13544 Reviewed-by: Noel Grandin Tested-by: Noel Grandin --- sal/workben/clipboardwben/testcopy/XTDataObject.cxx | 3 ++- sal/workben/testfile.cxx | 12 ++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'sal/workben') diff --git a/sal/workben/clipboardwben/testcopy/XTDataObject.cxx b/sal/workben/clipboardwben/testcopy/XTDataObject.cxx index ac7b60e27e3e..bd42b0194464 100644 --- a/sal/workben/clipboardwben/testcopy/XTDataObject.cxx +++ b/sal/workben/clipboardwben/testcopy/XTDataObject.cxx @@ -105,12 +105,13 @@ STDMETHODIMP CXTDataObject::GetData(LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium if ( CF_TEXT == pFormatetc->cfFormat ) { - char buff[] = "Hello World, How are you!"; LPSTREAM lpStream; hr = CreateStreamOnHGlobal( NULL, FALSE, &lpStream ); if ( SUCCEEDED( hr ) ) { + char buff[] = "Hello World, How are you!"; + hr = lpStream->Write( buff, sizeof( buff ) * sizeof( char ), NULL ); if ( SUCCEEDED( hr ) ) { diff --git a/sal/workben/testfile.cxx b/sal/workben/testfile.cxx index 49ec449af3b7..cbe504317197 100644 --- a/sal/workben/testfile.cxx +++ b/sal/workben/testfile.cxx @@ -114,7 +114,6 @@ sal_Bool Initialize( void ) rtl::OUString iniFileURL; File *pFile; - sal_Unicode *pExeFileCount; FileBase::RC rc; @@ -132,7 +131,7 @@ sal_Bool Initialize( void ) if ( ProcessError == osl_Process_E_None) { - pExeFileCount=rtl_uString_getStr(strExeFileURL)+rtl_uString_getLength(strExeFileURL); + sal_Unicode *pExeFileCount=rtl_uString_getStr(strExeFileURL)+rtl_uString_getLength(strExeFileURL); // Search for the last slash in the Path while (*pExeFileCount!=L'/' && pExeFileCount>rtl_uString_getStr(strExeFileURL)) @@ -1748,7 +1747,6 @@ void DirectoryFileStatusTest( void ) { FileBase::RC rc; DirectoryItem aItem; - FileStatus *pStatus; printf( "--------------------------------------------\n" ); printf( "Directory-FileStatus-Test\n" ); @@ -1765,7 +1763,7 @@ void DirectoryFileStatusTest( void ) if ( rc==FileBase::E_None ) { - pStatus=new FileStatus( osl_FileStatus_Mask_All ); + FileStatus *pStatus=new FileStatus( osl_FileStatus_Mask_All ); rc=aItem.getFileStatus( *pStatus ); FileStatusTest( pStatus ); @@ -1785,7 +1783,6 @@ void FileFileStatusTest( void ) { FileBase::RC rc; DirectoryItem aItem; - FileStatus *pStatus; printf( "--------------------------------------------\n" ); printf( "File-FileStatus-Test\n" ); @@ -1802,7 +1799,7 @@ void FileFileStatusTest( void ) if ( rc==FileBase::E_None ) { - pStatus=new FileStatus( osl_FileStatus_Mask_All ); + FileStatus *pStatus=new FileStatus( osl_FileStatus_Mask_All ); rc=aItem.getFileStatus( *pStatus ); FileStatusTest( pStatus ); @@ -1822,7 +1819,6 @@ void VolumeFileStatusTest( void ) { FileBase::RC rc; DirectoryItem aItem; - FileStatus *pStatus; printf( "--------------------------------------------\n" ); printf( "Volume-FileStatus-Test\n" ); @@ -1839,7 +1835,7 @@ void VolumeFileStatusTest( void ) if ( rc==FileBase::E_None ) { - pStatus=new FileStatus( osl_FileStatus_Mask_All) ; + FileStatus *pStatus=new FileStatus( osl_FileStatus_Mask_All) ; rc=aItem.getFileStatus( *pStatus ); FileStatusTest( pStatus ); -- cgit