[Libreoffice-commits] core.git: tools/source ucb/source unoxml/source vbahelper/source
Michael Weghorn
m.weghorn at posteo.de
Sun Jan 18 22:19:09 PST 2015
tools/source/generic/bigint.cxx | 6 ++----
tools/source/generic/poly.cxx | 5 ++---
ucb/source/sorter/sortresult.cxx | 6 ++----
ucb/source/ucp/ftp/test_ftpurl.cxx | 4 ++--
unoxml/source/xpath/xpathapi.cxx | 5 ++---
vbahelper/source/vbahelper/vbapagesetupbase.cxx | 20 ++++++++++++--------
6 files changed, 22 insertions(+), 24 deletions(-)
New commits:
commit 5901827bd44dc3600bf66c83882e6847439d59d6
Author: Michael Weghorn <m.weghorn at posteo.de>
Date: Sat Jan 17 00:37:31 2015 +0100
fdo#39440 reduce scope of local variables
This addresses some cppcheck warnings.
Change-Id: I1cd8b118e2598b8b18fb445851a3bb41e554267b
Reviewed-on: https://gerrit.libreoffice.org/13967
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
diff --git a/tools/source/generic/bigint.cxx b/tools/source/generic/bigint.cxx
index 7804597..cf0df72 100644
--- a/tools/source/generic/bigint.cxx
+++ b/tools/source/generic/bigint.cxx
@@ -310,7 +310,6 @@ void BigInt::MultLong( const BigInt& rB, BigInt& rErg ) const
void BigInt::DivLong( const BigInt& rB, BigInt& rErg ) const
{
int i, j;
- long nTmp;
sal_uInt16 nK, nQ, nMult;
short nLenB = rB.nLen;
short nLenB1 = rB.nLen - 1;
@@ -329,7 +328,7 @@ void BigInt::DivLong( const BigInt& rB, BigInt& rErg ) const
for (j = aTmpA.nLen - 1; j >= nLenB; j--)
{ // guess divisor
- nTmp = ( (long)aTmpA.nNum[j] << 16 ) + aTmpA.nNum[j - 1];
+ long nTmp = ( (long)aTmpA.nNum[j] << 16 ) + aTmpA.nNum[j - 1];
if (aTmpA.nNum[j] == aTmpB.nNum[nLenB1])
nQ = 0xFFFF;
else
@@ -379,7 +378,6 @@ void BigInt::DivLong( const BigInt& rB, BigInt& rErg ) const
void BigInt::ModLong( const BigInt& rB, BigInt& rErg ) const
{
short i, j;
- long nTmp;
sal_uInt16 nK, nQ, nMult;
short nLenB = rB.nLen;
short nLenB1 = rB.nLen - 1;
@@ -398,7 +396,7 @@ void BigInt::ModLong( const BigInt& rB, BigInt& rErg ) const
for (j = aTmpA.nLen - 1; j >= nLenB; j--)
{ // Guess divisor
- nTmp = ( (long)aTmpA.nNum[j] << 16 ) + aTmpA.nNum[j - 1];
+ long nTmp = ( (long)aTmpA.nNum[j] << 16 ) + aTmpA.nNum[j - 1];
if (aTmpA.nNum[j] == aTmpB.nNum[nLenB1])
nQ = 0xFFFF;
else
diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index e949835..5df7ef3 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -1069,7 +1069,6 @@ void Polygon::Rotate( const Point& rCenter, double fSin, double fCos )
{
ImplMakeUnique();
- long nX, nY;
long nCenterX = rCenter.X();
long nCenterY = rCenter.Y();
@@ -1077,8 +1076,8 @@ void Polygon::Rotate( const Point& rCenter, double fSin, double fCos )
{
Point& rPt = mpImplPolygon->mpPointAry[ i ];
- nX = rPt.X() - nCenterX;
- nY = rPt.Y() - nCenterY;
+ const long nX = rPt.X() - nCenterX;
+ const long nY = rPt.Y() - nCenterY;
rPt.X() = (long) FRound( fCos * nX + fSin * nY ) + nCenterX;
rPt.Y() = -(long) FRound( fSin * nX - fCos * nY ) + nCenterY;
}
diff --git a/ucb/source/sorter/sortresult.cxx b/ucb/source/sorter/sortresult.cxx
index 7e1dde0..d5fcabf 100644
--- a/ucb/source/sorter/sortresult.cxx
+++ b/ucb/source/sorter/sortresult.cxx
@@ -1278,12 +1278,11 @@ sal_IntPtr SortedResultSet::FindPos( SortListData *pEntry,
sal_IntPtr nEnd = _nEnd;
sal_IntPtr nMid = 0, nCompare = 0;
- SortListData *pMid;
while ( nStart <= nEnd )
{
nMid = ( nEnd - nStart ) / 2 + nStart;
- pMid = maS2O.GetData( nMid );
+ SortListData *pMid = maS2O.GetData( nMid );
nCompare = Compare( pEntry, pMid );
if ( !nCompare )
@@ -1771,12 +1770,11 @@ void SortedResultSet::ResortModified( EventList* pList )
void SortedResultSet::ResortNew( EventList* pList )
{
sal_IntPtr i, j, nNewPos, nVal;
- SortListData *pData;
try {
for ( i = mnLastSort; i<(sal_IntPtr)maS2O.Count(); i++ )
{
- pData = (SortListData*) maModList.GetObject( i );
+ SortListData *pData = (SortListData*) maModList.GetObject( i );
nNewPos = FindPos( pData, 1, mnLastSort );
if ( nNewPos != i )
{
diff --git a/ucb/source/ucp/ftp/test_ftpurl.cxx b/ucb/source/ucp/ftp/test_ftpurl.cxx
index bbc99ca..b93d2b0 100644
--- a/ucb/source/ucp/ftp/test_ftpurl.cxx
+++ b/ucb/source/ucp/ftp/test_ftpurl.cxx
@@ -245,7 +245,7 @@ int test_ftpopen(void)
FILE* file = url.open();
if(file) {
- int nbuf,ndest;
+ int nbuf;
const int bffsz = 256;
char buff[bffsz];
char *dest = (char*) malloc(sizeof(char));
@@ -254,7 +254,7 @@ int test_ftpopen(void)
memset((void*)buff, 0, bffsz);
fread(buff,bffsz-1,1,file);
nbuf = strlen(buff);
- ndest = strlen(dest);
+ int ndest = strlen(dest);
dest = (char*)realloc(dest,ndest + nbuf + 1);
strncat(dest,buff,nbuf);
} while(nbuf == bffsz-1);
diff --git a/unoxml/source/xpath/xpathapi.cxx b/unoxml/source/xpath/xpathapi.cxx
index a7346b9..915d666 100644
--- a/unoxml/source/xpath/xpathapi.cxx
+++ b/unoxml/source/xpath/xpathapi.cxx
@@ -126,13 +126,12 @@ namespace XPath
{
nsmap_t::const_iterator i = nsmap.begin();
OString oprefix, ouri;
- xmlChar *p, *u;
while (i != nsmap.end())
{
oprefix = OUStringToOString(i->first, RTL_TEXTENCODING_UTF8);
ouri = OUStringToOString(i->second, RTL_TEXTENCODING_UTF8);
- p = (xmlChar*)oprefix.getStr();
- u = (xmlChar*)ouri.getStr();
+ xmlChar *p = (xmlChar*)oprefix.getStr();
+ xmlChar *u = (xmlChar*)ouri.getStr();
xmlXPathRegisterNs(ctx, p, u);
++i;
}
diff --git a/vbahelper/source/vbahelper/vbapagesetupbase.cxx b/vbahelper/source/vbahelper/vbapagesetupbase.cxx
index 46e8203..0148234 100644
--- a/vbahelper/source/vbahelper/vbapagesetupbase.cxx
+++ b/vbahelper/source/vbahelper/vbapagesetupbase.cxx
@@ -31,12 +31,13 @@ VbaPageSetupBase::VbaPageSetupBase(const uno::Reference< XHelperInterface >& xPa
double SAL_CALL VbaPageSetupBase::getTopMargin() throw (css::uno::RuntimeException, std::exception)
{
- bool headerOn = false;
sal_Int32 topMargin = 0;
- sal_Int32 headerHeight = 0;
try
{
+ bool headerOn = false;
+ sal_Int32 headerHeight = 0;
+
uno::Any aValue = mxPageProps->getPropertyValue( "HeaderIsOn" );
aValue >>= headerOn;
@@ -60,11 +61,12 @@ double SAL_CALL VbaPageSetupBase::getTopMargin() throw (css::uno::RuntimeExcepti
void SAL_CALL VbaPageSetupBase::setTopMargin( double margin ) throw (css::uno::RuntimeException, std::exception)
{
sal_Int32 topMargin = Millimeter::getInHundredthsOfOneMillimeter( margin );
- bool headerOn = false;
- sal_Int32 headerHeight = 0;
try
{
+ bool headerOn = false;
+ sal_Int32 headerHeight = 0;
+
uno::Any aValue = mxPageProps->getPropertyValue( "HeaderIsOn" );
aValue >>= headerOn;
@@ -85,12 +87,13 @@ void SAL_CALL VbaPageSetupBase::setTopMargin( double margin ) throw (css::uno::R
double SAL_CALL VbaPageSetupBase::getBottomMargin() throw (css::uno::RuntimeException, std::exception)
{
- bool footerOn = false;
sal_Int32 bottomMargin = 0;
- sal_Int32 footerHeight = 0;
try
{
+ bool footerOn = false;
+ sal_Int32 footerHeight = 0;
+
uno::Any aValue = mxPageProps->getPropertyValue( "FooterIsOn" );
aValue >>= footerOn;
@@ -114,11 +117,12 @@ double SAL_CALL VbaPageSetupBase::getBottomMargin() throw (css::uno::RuntimeExce
void SAL_CALL VbaPageSetupBase::setBottomMargin( double margin ) throw (css::uno::RuntimeException, std::exception)
{
sal_Int32 bottomMargin = Millimeter::getInHundredthsOfOneMillimeter( margin );
- bool footerOn = false;
- sal_Int32 footerHeight = 0;
try
{
+ bool footerOn = false;
+ sal_Int32 footerHeight = 0;
+
uno::Any aValue = mxPageProps->getPropertyValue( "FooterIsOn" );
aValue >>= footerOn;
More information about the Libreoffice-commits
mailing list