summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadu Ioan <ioan.radu.g@gmail.com>2014-01-26 15:12:53 +0200
committerMichael Stahl <mstahl@redhat.com>2014-01-29 22:18:09 +0000
commitc634faf12886228754eb59ec9bedf6cd6f631054 (patch)
treeda8144d9fec60cb93273c75bb5222e7225927534
parentcb9b6d94d805026062ebc6e2f7bdb2f659d9665a (diff)
fdo#39440 - cppcheck cleanliness
- Fixed some The scope of the variable 'x' can be reduced. Change-Id: I6b586314b2ed201249dc52469cc4bb86b99f79d2 Reviewed-on: https://gerrit.libreoffice.org/7665 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r--sc/source/core/opencl/op_math.cxx8
-rw-r--r--sc/source/core/tool/interpr3.cxx22
-rw-r--r--sc/source/core/tool/scmatrix.cxx2
-rw-r--r--sd/source/core/sdpage.cxx8
4 files changed, 23 insertions, 17 deletions
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 1c8c717fb307..c45981eb9162 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -2981,11 +2981,9 @@ void OpAverageIf::GenSlidingWindowFunction(std::stringstream &ss,
unsigned paraOneIsDoubleVector = 0;
unsigned paraOneWidth = 1;
unsigned paraTwoWidth = 1;
- unsigned paraThreeWidth = 1;
unsigned loopTimes = 0;
- unsigned loopIndex = 0;
- if(vSubArguments[0]->GetFormulaToken()->GetType() ==
- formula::svDoubleVectorRef)
+
+ if(vSubArguments[0]->GetFormulaToken()->GetType() == formula::svDoubleVectorRef)
{
paraOneIsDoubleVector = 1;
FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
@@ -3034,6 +3032,7 @@ void OpAverageIf::GenSlidingWindowFunction(std::stringstream &ss,
if(vSubArguments[paraThreeIndex]->GetFormulaToken()->GetType() ==
formula::svDoubleVectorRef)
{
+ unsigned paraThreeWidth = 1;
FormulaToken *tmpCur2 =
vSubArguments[paraThreeIndex]->GetFormulaToken();
const formula::DoubleVectorRefToken*pCurDVR2= dynamic_cast<const
@@ -3048,6 +3047,7 @@ void OpAverageIf::GenSlidingWindowFunction(std::stringstream &ss,
if(paraOneIsDoubleVector)
{
+ unsigned loopIndex = 0;
FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
const formula::DoubleVectorRefToken*pCurDVR0= dynamic_cast<const
formula::DoubleVectorRefToken *>(tmpCur0);
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 2a5d77005849..bd02398cfe34 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -2454,7 +2454,7 @@ void ScInterpreter::ScZTest()
sal_uInt8 nParamCount = GetByte();
if ( !MustHaveParamCount( nParamCount, 2, 3 ) )
return;
- double sigma = 0.0, mue, x;
+ double sigma = 0.0, x;
if (nParamCount == 3)
{
sigma = GetDouble();
@@ -2560,7 +2560,8 @@ void ScInterpreter::ScZTest()
PushError( errDivisionByZero);
else
{
- mue = fSum/rValCount;
+ double mue = fSum/rValCount;
+
if (nParamCount != 3)
{
sigma = (fSumSqr - fSum*fSum/rValCount)/(rValCount-1.0);
@@ -4138,9 +4139,7 @@ void ScInterpreter::CalculatePearsonCovar( bool _bPearson, bool _bStexy, bool _b
double fCount = 0.0;
double fSumX = 0.0;
double fSumY = 0.0;
- double fSumDeltaXDeltaY = 0.0; // sum of (ValX-MeanX)*(ValY-MeanY)
- double fSumSqrDeltaX = 0.0; // sum of (ValX-MeanX)^2
- double fSumSqrDeltaY = 0.0; // sum of (ValY-MeanY)^2
+
for (SCSIZE i = 0; i < nC1; i++)
{
for (SCSIZE j = 0; j < nR1; j++)
@@ -4159,6 +4158,9 @@ void ScInterpreter::CalculatePearsonCovar( bool _bPearson, bool _bStexy, bool _b
PushNoValue();
else
{
+ double fSumDeltaXDeltaY = 0.0; // sum of (ValX-MeanX)*(ValY-MeanY)
+ double fSumSqrDeltaX = 0.0; // sum of (ValX-MeanX)^2
+ double fSumSqrDeltaY = 0.0; // sum of (ValY-MeanY)^2
const double fMeanX = fSumX / fCount;
const double fMeanY = fSumY / fCount;
for (SCSIZE i = 0; i < nC1; i++)
@@ -4247,8 +4249,7 @@ void ScInterpreter::CalculateSlopeIntercept(bool bSlope)
double fCount = 0.0;
double fSumX = 0.0;
double fSumY = 0.0;
- double fSumDeltaXDeltaY = 0.0; // sum of (ValX-MeanX)*(ValY-MeanY)
- double fSumSqrDeltaX = 0.0; // sum of (ValX-MeanX)^2
+
for (SCSIZE i = 0; i < nC1; i++)
{
for (SCSIZE j = 0; j < nR1; j++)
@@ -4267,6 +4268,8 @@ void ScInterpreter::CalculateSlopeIntercept(bool bSlope)
PushNoValue();
else
{
+ double fSumDeltaXDeltaY = 0.0; // sum of (ValX-MeanX)*(ValY-MeanY)
+ double fSumSqrDeltaX = 0.0; // sum of (ValX-MeanX)^2
double fMeanX = fSumX / fCount;
double fMeanY = fSumY / fCount;
for (SCSIZE i = 0; i < nC1; i++)
@@ -4329,8 +4332,7 @@ void ScInterpreter::ScForecast()
double fCount = 0.0;
double fSumX = 0.0;
double fSumY = 0.0;
- double fSumDeltaXDeltaY = 0.0; // sum of (ValX-MeanX)*(ValY-MeanY)
- double fSumSqrDeltaX = 0.0; // sum of (ValX-MeanX)^2
+
for (SCSIZE i = 0; i < nC1; i++)
{
for (SCSIZE j = 0; j < nR1; j++)
@@ -4349,6 +4351,8 @@ void ScInterpreter::ScForecast()
PushNoValue();
else
{
+ double fSumDeltaXDeltaY = 0.0; // sum of (ValX-MeanX)*(ValY-MeanY)
+ double fSumSqrDeltaX = 0.0; // sum of (ValX-MeanX)^2
double fMeanX = fSumX / fCount;
double fMeanY = fSumY / fCount;
for (SCSIZE i = 0; i < nC1; i++)
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 9c929fe51762..c6a49548642c 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -1162,11 +1162,11 @@ size_t WalkAndMatchElements<double>::compare(const MatrixImplType::element_block
template<>
size_t WalkAndMatchElements<svl::SharedString>::compare(const MatrixImplType::element_block_node_type& node) const
{
- size_t nCount = 0;
switch (node.type)
{
case mdds::mtm::element_string:
{
+ size_t nCount = 0;
typedef MatrixImplType::string_block_type block_type;
block_type::const_iterator it = block_type::begin(*node.data);
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index 21ec27ec6bcf..3bd13e4dc20b 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -933,7 +933,6 @@ void getPresObjProp( const SdPage& rPage, const char* sObjKind, const char* sPag
SdrObject* SdPage::CreateDefaultPresObj(PresObjKind eObjKind, bool bInsert)
{
- double propvalue[] = {0,0,0,0};
if( eObjKind == PRESOBJ_TITLE )
{
@@ -952,6 +951,7 @@ SdrObject* SdPage::CreateDefaultPresObj(PresObjKind eObjKind, bool bInsert)
}
else if( (eObjKind == PRESOBJ_FOOTER) || (eObjKind == PRESOBJ_DATETIME) || (eObjKind == PRESOBJ_SLIDENUMBER) || (eObjKind == PRESOBJ_HEADER ) )
{
+ double propvalue[] = {0,0,0,0};
const char* sObjKind = PresObjKindVector[eObjKind];
const char* sPageKind = PageKindVector[mePageKind];
// create footer objects for standard master page
@@ -1026,10 +1026,11 @@ SdrObject* SdPage::CreateDefaultPresObj(PresObjKind eObjKind, bool bInsert)
Rectangle SdPage::GetTitleRect() const
{
Rectangle aTitleRect;
- double propvalue[] = {0,0,0,0};
if (mePageKind != PK_HANDOUT)
{
+ double propvalue[] = {0,0,0,0};
+
/******************************************************************
* standard- or note page: title area
******************************************************************/
@@ -1110,10 +1111,11 @@ Rectangle SdPage::GetTitleRect() const
Rectangle SdPage::GetLayoutRect() const
{
Rectangle aLayoutRect;
- double propvalue[] = {0,0,0,0};
if (mePageKind != PK_HANDOUT)
{
+ double propvalue[] = {0,0,0,0};
+
Point aLayoutPos ( GetLftBorder(), GetUppBorder() );
Size aLayoutSize ( GetSize() );
aLayoutSize.Width() -= GetLftBorder() + GetRgtBorder();