From d41bc0f7b328ed6c69b2c2822de00165cdc62c61 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Fri, 19 Dec 2014 08:47:29 +0100 Subject: fdo#39440 reduce scope of local variables This addresses some cppcheck warnings. Change-Id: Idcedd908c653d5a5700884f233ad134dde8be018 Reviewed-on: https://gerrit.libreoffice.org/13540 Reviewed-by: Noel Grandin Tested-by: Noel Grandin --- registry/source/regimpl.cxx | 6 ++---- registry/source/registry.cxx | 8 ++------ 2 files changed, 4 insertions(+), 10 deletions(-) (limited to 'registry') diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx index 37813095e0af..039cde3270b7 100644 --- a/registry/source/regimpl.cxx +++ b/registry/source/regimpl.cxx @@ -1616,14 +1616,13 @@ RegError ORegistry::dumpValue(const OUString& sPath, const OUString& sName, sal_ sal::static_int_cast< unsigned long >(len)); fprintf(stdout, "%s Data = ", indent); - sal_Char *pValue; for (sal_uInt32 i=0; i < len; i++) { readUINT32(pBuffer+offset, sLen); offset += 4; // 4 Bytes (sal_uInt32) fuer die Groesse des strings in Bytes - pValue = (sal_Char*)rtl_allocateMemory(sLen); + sal_Char *pValue = (sal_Char*)rtl_allocateMemory(sLen); readUtf8(pBuffer+offset, pValue, sLen); if (offset > 8) @@ -1654,7 +1653,6 @@ RegError ORegistry::dumpValue(const OUString& sPath, const OUString& sName, sal_ sal::static_int_cast< unsigned long >(len)); fprintf(stdout, "%s Data = ", indent); - sal_Unicode *pValue; OString uStr; for (sal_uInt32 i=0; i < len; i++) { @@ -1662,7 +1660,7 @@ RegError ORegistry::dumpValue(const OUString& sPath, const OUString& sName, sal_ offset += 4; // 4 Bytes (sal_uInt32) fuer die Groesse des strings in Bytes - pValue = (sal_Unicode*)rtl_allocateMemory((sLen / 2) * sizeof(sal_Unicode)); + sal_Unicode *pValue = (sal_Unicode*)rtl_allocateMemory((sLen / 2) * sizeof(sal_Unicode)); readString(pBuffer+offset, pValue, sLen); if (offset > 8) diff --git a/registry/source/registry.cxx b/registry/source/registry.cxx index 803372fa8028..3086adb44b2e 100644 --- a/registry/source/registry.cxx +++ b/registry/source/registry.cxx @@ -74,11 +74,9 @@ static void REGISTRY_CALLTYPE release(RegHandle hReg) static RegError REGISTRY_CALLTYPE getName(RegHandle hReg, rtl_uString** pName) { - ORegistry* pReg; - if (hReg) { - pReg = (ORegistry*)hReg; + ORegistry* pReg = (ORegistry*)hReg; if ( pReg->isOpen() ) { rtl_uString_assign(pName, pReg->getName().pData); @@ -580,11 +578,9 @@ REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_openRegistry(rtl_uString* registryN REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_closeRegistry(RegHandle hRegistry) { - ORegistry* pReg; - if (hRegistry) { - pReg = (ORegistry*)hRegistry; + ORegistry* pReg = (ORegistry*)hRegistry; delete(pReg); return REG_NO_ERROR; } else -- cgit