summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2015-08-22 13:08:41 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2015-08-22 13:04:12 +0000
commit7e318570dc0c0878bfd2a960230a26f7e5fe2bcf (patch)
treeaa85e58d369f67297ad395addfd0dc6654dbfdee
parent25accda781bc0bc79ca2e887c54ca981068bf407 (diff)
tdf#39440 reduce scope of local variables
This addresses some cppcheck warnings. Change-Id: Ie492fb9c106b37c3fe7b0105236ad6315f4f159e Reviewed-on: https://gerrit.libreoffice.org/17921 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r--pyuno/source/module/pyuno_iterator.cxx3
-rw-r--r--sal/osl/unx/random.cxx2
-rw-r--r--sal/textenc/tcvtmb.cxx3
-rw-r--r--sax/source/tools/converter.cxx3
-rw-r--r--sc/source/core/data/compressedarray.cxx3
-rw-r--r--sc/source/core/data/document.cxx3
-rw-r--r--sc/source/core/data/dptabres.cxx6
-rw-r--r--sc/source/core/tool/addincol.cxx27
-rw-r--r--sc/source/core/tool/interpr1.cxx3
9 files changed, 24 insertions, 29 deletions
diff --git a/pyuno/source/module/pyuno_iterator.cxx b/pyuno/source/module/pyuno_iterator.cxx
index 9fa79719f093..58c6f504d6b5 100644
--- a/pyuno/source/module/pyuno_iterator.cxx
+++ b/pyuno/source/module/pyuno_iterator.cxx
@@ -63,11 +63,12 @@ PyObject* PyUNO_iterator_next( PyObject *self )
PyUNO_iterator* me = reinterpret_cast<PyUNO_iterator*>(self);
Runtime runtime;
- bool hasMoreElements = false;
Any aRet;
try
{
+ bool hasMoreElements = false;
+
{
PyThreadDetach antiguard;
diff --git a/sal/osl/unx/random.cxx b/sal/osl/unx/random.cxx
index 04333a2f3b2b..a0fb73c92867 100644
--- a/sal/osl/unx/random.cxx
+++ b/sal/osl/unx/random.cxx
@@ -14,7 +14,6 @@
int osl_get_system_random_data(char* buffer, size_t desired_len)
{
- ssize_t nb_read;
int fd;
assert(buffer);
@@ -23,6 +22,7 @@ int osl_get_system_random_data(char* buffer, size_t desired_len)
{
while(desired_len)
{
+ ssize_t nb_read;
if ((nb_read = read(fd, buffer, desired_len)) == -1)
{
if (errno != EINTR)
diff --git a/sal/textenc/tcvtmb.cxx b/sal/textenc/tcvtmb.cxx
index 75e5b7f12862..cce84c19dbed 100644
--- a/sal/textenc/tcvtmb.cxx
+++ b/sal/textenc/tcvtmb.cxx
@@ -40,7 +40,6 @@ sal_Size ImplDBCSToUnicode( const void* pData, SAL_UNUSED_PARAMETER void*,
sal_uInt32 nFlags, sal_uInt32* pInfo,
sal_Size* pSrcCvtBytes )
{
- unsigned char cLead;
unsigned char cTrail;
sal_Unicode cConv;
const ImplDBCSToUniLeadTab* pLeadEntry;
@@ -54,7 +53,7 @@ sal_Size ImplDBCSToUnicode( const void* pData, SAL_UNUSED_PARAMETER void*,
pEndSrcBuf = pSrcBuf+nSrcBytes;
while ( pSrcBuf < pEndSrcBuf )
{
- cLead = (unsigned char)*pSrcBuf;
+ unsigned char cLead = (unsigned char)*pSrcBuf;
/* get entry for the lead byte */
pLeadEntry = pLeadTab+cLead;
diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index d7adda18df2b..1ed1d8725ee8 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -2035,10 +2035,11 @@ double Converter::GetConversionFactor(OUStringBuffer& rUnit, sal_Int16 nSourceUn
double fRetval(1.0);
rUnit.setLength(0L);
- const sal_Char* psUnit = 0;
if(nSourceUnit != nTargetUnit)
{
+ const sal_Char* psUnit = 0;
+
switch(nSourceUnit)
{
case MeasureUnit::TWIP:
diff --git a/sc/source/core/data/compressedarray.cxx b/sc/source/core/data/compressedarray.cxx
index 36249d291ed6..6411fa838d31 100644
--- a/sc/source/core/data/compressedarray.cxx
+++ b/sc/source/core/data/compressedarray.cxx
@@ -89,7 +89,6 @@ size_t ScCompressedArray<A,D>::Search( A nAccess ) const
long nLo = 0;
long nHi = static_cast<long>(nCount) - 1;
long nStart = 0;
- long nEnd = 0;
long i = 0;
bool bFound = (nCount == 1);
while (!bFound && nLo <= nHi)
@@ -99,7 +98,7 @@ size_t ScCompressedArray<A,D>::Search( A nAccess ) const
nStart = static_cast<long>(pData[i - 1].nEnd);
else
nStart = -1;
- nEnd = static_cast<long>(pData[i].nEnd);
+ long nEnd = static_cast<long>(pData[i].nEnd);
if (nEnd < static_cast<long>(nAccess))
nLo = ++i;
else
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 3570386aec5e..e485885c8cf8 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -425,7 +425,6 @@ void ScDocument::CreateValidTabNames(std::vector<OUString>& aNames, SCTAB nCount
OUString aStrTable = rOpt.GetInitTabPrefix();
OUStringBuffer rName;
- bool bOk = false;
// First test if the prefix is valid, if so only avoid doubles
bool bPrefix = ValidTabName( aStrTable );
@@ -435,7 +434,7 @@ void ScDocument::CreateValidTabNames(std::vector<OUString>& aNames, SCTAB nCount
for (SCTAB j = 0; j < nCount; ++j)
{
- bOk = false;
+ bool bOk = false;
while(!bOk)
{
rName = aStrTable;
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index cda6832aeed6..7ccaa7300021 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -2756,10 +2756,9 @@ ScDPResultMember *ScDPResultDimension::FindMember( SCROW iData ) const
unsigned int i;
unsigned int nCount = maMemberArray.size();
- ScDPResultMember* pResultMember;
for( i = 0; i < nCount ; i++ )
{
- pResultMember = maMemberArray[i];
+ ScDPResultMember* pResultMember = maMemberArray[i];
if ( pResultMember->IsNamedItem( iData ) )
return pResultMember;
}
@@ -4077,10 +4076,9 @@ void ScDPResultDimension::CheckShowEmpty( bool bShow )
{
long nCount = maMemberArray.size();
- ScDPResultMember* pMember = NULL;
for (long i=0; i<nCount; i++)
{
- pMember = maMemberArray.at(i);
+ ScDPResultMember* pMember = maMemberArray.at(i);
pMember->CheckShowEmpty(bShow);
}
diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index 3dc1d498f8fc..48f060f956f7 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -1568,8 +1568,7 @@ void ScUnoAddInCall::SetResult( const uno::Any& rNewRes )
long nRowCount = pRowSeq->getLength();
const uno::Sequence<sal_Int32>* pRowArr = pRowSeq->getConstArray();
long nMaxColCount = 0;
- long nCol, nRow;
- for (nRow=0; nRow<nRowCount; nRow++)
+ for (long nRow=0; nRow<nRowCount; nRow++)
{
long nTmp = pRowArr[nRow].getLength();
if ( nTmp > nMaxColCount )
@@ -1580,15 +1579,15 @@ void ScUnoAddInCall::SetResult( const uno::Any& rNewRes )
xMatrix = new ScMatrix(
static_cast<SCSIZE>(nMaxColCount),
static_cast<SCSIZE>(nRowCount), 0.0);
- for (nRow=0; nRow<nRowCount; nRow++)
+ for (long nRow=0; nRow<nRowCount; nRow++)
{
long nColCount = pRowArr[nRow].getLength();
const sal_Int32* pColArr = pRowArr[nRow].getConstArray();
- for (nCol=0; nCol<nColCount; nCol++)
+ for (long nCol=0; nCol<nColCount; nCol++)
xMatrix->PutDouble( pColArr[nCol],
static_cast<SCSIZE>(nCol),
static_cast<SCSIZE>(nRow) );
- for (nCol=nColCount; nCol<nMaxColCount; nCol++)
+ for (long nCol=nColCount; nCol<nMaxColCount; nCol++)
xMatrix->PutDouble( 0.0,
static_cast<SCSIZE>(nCol),
static_cast<SCSIZE>(nRow) );
@@ -1610,8 +1609,7 @@ void ScUnoAddInCall::SetResult( const uno::Any& rNewRes )
long nRowCount = pRowSeq->getLength();
const uno::Sequence<double>* pRowArr = pRowSeq->getConstArray();
long nMaxColCount = 0;
- long nCol, nRow;
- for (nRow=0; nRow<nRowCount; nRow++)
+ for (long nRow=0; nRow<nRowCount; nRow++)
{
long nTmp = pRowArr[nRow].getLength();
if ( nTmp > nMaxColCount )
@@ -1622,15 +1620,15 @@ void ScUnoAddInCall::SetResult( const uno::Any& rNewRes )
xMatrix = new ScMatrix(
static_cast<SCSIZE>(nMaxColCount),
static_cast<SCSIZE>(nRowCount), 0.0);
- for (nRow=0; nRow<nRowCount; nRow++)
+ for (long nRow=0; nRow<nRowCount; nRow++)
{
long nColCount = pRowArr[nRow].getLength();
const double* pColArr = pRowArr[nRow].getConstArray();
- for (nCol=0; nCol<nColCount; nCol++)
+ for (long nCol=0; nCol<nColCount; nCol++)
xMatrix->PutDouble( pColArr[nCol],
static_cast<SCSIZE>(nCol),
static_cast<SCSIZE>(nRow) );
- for (nCol=nColCount; nCol<nMaxColCount; nCol++)
+ for (long nCol=nColCount; nCol<nMaxColCount; nCol++)
xMatrix->PutDouble( 0.0,
static_cast<SCSIZE>(nCol),
static_cast<SCSIZE>(nRow) );
@@ -1652,8 +1650,7 @@ void ScUnoAddInCall::SetResult( const uno::Any& rNewRes )
long nRowCount = pRowSeq->getLength();
const uno::Sequence<OUString>* pRowArr = pRowSeq->getConstArray();
long nMaxColCount = 0;
- long nCol, nRow;
- for (nRow=0; nRow<nRowCount; nRow++)
+ for (long nRow=0; nRow<nRowCount; nRow++)
{
long nTmp = pRowArr[nRow].getLength();
if ( nTmp > nMaxColCount )
@@ -1664,17 +1661,17 @@ void ScUnoAddInCall::SetResult( const uno::Any& rNewRes )
xMatrix = new ScMatrix(
static_cast<SCSIZE>(nMaxColCount),
static_cast<SCSIZE>(nRowCount), 0.0);
- for (nRow=0; nRow<nRowCount; nRow++)
+ for (long nRow=0; nRow<nRowCount; nRow++)
{
long nColCount = pRowArr[nRow].getLength();
const OUString* pColArr = pRowArr[nRow].getConstArray();
- for (nCol=0; nCol<nColCount; nCol++)
+ for (long nCol=0; nCol<nColCount; nCol++)
{
xMatrix->PutString(
svl::SharedString(pColArr[nCol]),
static_cast<SCSIZE>(nCol), static_cast<SCSIZE>(nRow));
}
- for (nCol=nColCount; nCol<nMaxColCount; nCol++)
+ for (long nCol=nColCount; nCol<nMaxColCount; nCol++)
{
xMatrix->PutString(
svl::SharedString(EMPTY_OUSTRING),
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index ce59e26a8cee..b596d42739e0 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -6826,7 +6826,6 @@ void ScInterpreter::DBIterator( ScIterFunc eFunc )
{
double nErg = 0.0;
double fMem = 0.0;
- bool bNull = true;
sal_uLong nCount = 0;
bool bMissingField = false;
unique_ptr<ScDBQueryParamBase> pQueryParam( GetDBParams(bMissingField) );
@@ -6848,6 +6847,8 @@ void ScInterpreter::DBIterator( ScIterFunc eFunc )
case ifMIN: nErg = MAXDOUBLE; break;
default: ; // nothing
}
+
+ bool bNull = true;
do
{
nCount++;