summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorNoel <noelgrandin@gmail.com>2020-10-05 09:28:37 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-10-05 14:41:59 +0200
commit8ec183056dd7a954d9af7b26432d7680a31e9896 (patch)
tree5d6e9a7ee435f3e9fc50b9b34373de1722f0f68b /sal
parentb65d21596b5773d744b242716a78308d2c3714d0 (diff)
loplugin:reducevarscope in sal
Change-Id: I2ce95de07b8e0952a1e778e65940b30597396aa6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103949 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/unx/profile.cxx6
-rw-r--r--sal/qa/osl/pipe/osl_Pipe.cxx3
-rw-r--r--sal/rtl/byteseq.cxx7
-rw-r--r--sal/rtl/ustring.cxx4
4 files changed, 9 insertions, 11 deletions
diff --git a/sal/osl/unx/profile.cxx b/sal/osl/unx/profile.cxx
index 31cfc8575f73..354fe626f390 100644
--- a/sal/osl/unx/profile.cxx
+++ b/sal/osl/unx/profile.cxx
@@ -488,12 +488,10 @@ sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile,
const char* pszEntry,
const char* pszString)
{
- sal_uInt32 i;
bool bRet = false;
sal_uInt32 NoEntry;
char* pStr;
char* Line = nullptr;
- osl_TProfileSection* pSec;
osl_TProfileImpl* pProfile = nullptr;
osl_TProfileImpl* pTmpProfile = static_cast<osl_TProfileImpl*>(Profile);
@@ -525,6 +523,7 @@ sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile,
if (! (pProfile->m_Flags & osl_Profile_SYSTEM))
{
+ osl_TProfileSection* pSec;
if ((pSec = findEntry(pProfile, pszSection, pszEntry, &NoEntry)) == nullptr)
{
Line[0] = '\0';
@@ -559,6 +558,7 @@ sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile,
if (NoEntry >= pSec->m_NoEntries)
{
+ sal_uInt32 i;
if (pSec->m_NoEntries > 0)
i = pSec->m_Entries[pSec->m_NoEntries - 1].m_Line + 1;
else
@@ -581,7 +581,7 @@ sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile,
}
else
{
- i = pSec->m_Entries[NoEntry].m_Line;
+ sal_uInt32 i = pSec->m_Entries[NoEntry].m_Line;
free(pProfile->m_Lines[i]);
pProfile->m_Lines[i] = strdup(Line);
setEntry(pProfile, pSec, NoEntry, i, pProfile->m_Lines[i], strlen(pszEntry));
diff --git a/sal/qa/osl/pipe/osl_Pipe.cxx b/sal/qa/osl/pipe/osl_Pipe.cxx
index f9e2bb16174e..eef77e998380 100644
--- a/sal/qa/osl/pipe/osl_Pipe.cxx
+++ b/sal/qa/osl/pipe/osl_Pipe.cxx
@@ -802,7 +802,6 @@ namespace osl_StreamPipe
void SAL_CALL run( ) override
{
//create pipe.
- sal_Int32 nChars;
printf("listen\n");
if ( !aListenPipe.is() )
{
@@ -819,7 +818,7 @@ namespace osl_StreamPipe
}
printf("write\n");
// write to pipe
- nChars = aConnectionPipe.write( m_pTestString1.getStr(), m_pTestString1.getLength() + 1 );
+ sal_Int32 nChars = aConnectionPipe.write( m_pTestString1.getStr(), m_pTestString1.getLength() + 1 );
if ( nChars < 0)
{
printf("server write failed! \n");
diff --git a/sal/rtl/byteseq.cxx b/sal/rtl/byteseq.cxx
index c78a1e22f43a..3c4967d5456d 100644
--- a/sal/rtl/byteseq.cxx
+++ b/sal/rtl/byteseq.cxx
@@ -39,13 +39,14 @@ static sal_Sequence aEmpty_rtl_ByteSeq =
void SAL_CALL rtl_byte_sequence_reference2One(
sal_Sequence ** ppSequence ) SAL_THROW_EXTERN_C()
{
- sal_Sequence * pSequence, * pNew;
+ sal_Sequence * pSequence;
OSL_ENSURE( ppSequence, "### null ptr!" );
pSequence = *ppSequence;
if (pSequence->nRefCount > 1)
{
+ sal_Sequence *pNew;
sal_Int32 nElements = pSequence->nElements;
if (nElements)
{
@@ -75,7 +76,7 @@ void SAL_CALL rtl_byte_sequence_reference2One(
void SAL_CALL rtl_byte_sequence_realloc(
sal_Sequence ** ppSequence, sal_Int32 nSize ) SAL_THROW_EXTERN_C()
{
- sal_Sequence * pSequence, * pNew;
+ sal_Sequence * pSequence;
sal_Int32 nElements;
assert(ppSequence && "### null ptr!");
@@ -87,7 +88,7 @@ void SAL_CALL rtl_byte_sequence_realloc(
if (pSequence->nRefCount > 1) // split
{
- pNew = static_cast<sal_Sequence *>(malloc( SAL_SEQUENCE_HEADER_SIZE + nSize ));
+ sal_Sequence *pNew = static_cast<sal_Sequence *>(malloc( SAL_SEQUENCE_HEADER_SIZE + nSize ));
if ( pNew != nullptr )
{
diff --git a/sal/rtl/ustring.cxx b/sal/rtl/ustring.cxx
index cbadddc6a98e..7b6687f74bd5 100644
--- a/sal/rtl/ustring.cxx
+++ b/sal/rtl/ustring.cxx
@@ -1054,14 +1054,12 @@ void SAL_CALL rtl_uString_internConvert( rtl_uString ** newStr,
static void
internRelease (rtl_uString *pThis)
{
- oslMutex pPoolMutex;
-
rtl_uString *pFree = nullptr;
if ( SAL_STRING_REFCOUNT(
osl_atomic_decrement( &(pThis->refCount) ) ) == 0)
{
RTL_LOG_STRING_INTERN_DELETE(pThis);
- pPoolMutex = getInternMutex();
+ oslMutex pPoolMutex = getInternMutex();
osl_acquireMutex( pPoolMutex );
rtl_str_hash_remove (pThis);