summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2017-12-08 18:57:27 +0100
committerJulien Nabet <serval2412@yahoo.fr>2017-12-08 23:14:49 +0100
commit2ec698b43313c18522b45b28895cd5688a84a700 (patch)
tree13fe01cd548f8820e32435adbe1d346fd164ff34
parentb45cbaa2ea50b2b6f28e78888bbae121deb8558c (diff)
cppcheck: fix some reports
variableScope reports in comphelper/drawinglayer/editeng +filter/framework/l10ntools Change-Id: I4575428773e8b9b3efedabb44fdcd6d8175ac46a Reviewed-on: https://gerrit.libreoffice.org/46116 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
-rw-r--r--comphelper/source/misc/backupfilehelper.cxx4
-rw-r--r--comphelper/source/windows/windows_process.cxx7
-rw-r--r--drawinglayer/source/tools/converters.cxx6
-rw-r--r--editeng/source/editeng/impedit5.cxx3
-rw-r--r--filter/source/graphicfilter/ipbm/ipbm.cxx9
-rw-r--r--filter/source/graphicfilter/ipict/shape.cxx2
-rw-r--r--filter/source/graphicfilter/itiff/itiff.cxx3
-rw-r--r--filter/source/msfilter/escherex.cxx2
-rw-r--r--filter/source/msfilter/msdffimp.cxx3
-rw-r--r--framework/source/services/frame.cxx2
-rw-r--r--l10ntools/source/gConvXcu.cxx5
-rw-r--r--l10ntools/source/gConvXrm.cxx15
-rw-r--r--l10ntools/source/gL10nMem.cxx4
13 files changed, 29 insertions, 36 deletions
diff --git a/comphelper/source/misc/backupfilehelper.cxx b/comphelper/source/misc/backupfilehelper.cxx
index 614789a3bcbc..85d8b2052d44 100644
--- a/comphelper/source/misc/backupfilehelper.cxx
+++ b/comphelper/source/misc/backupfilehelper.cxx
@@ -1620,8 +1620,6 @@ namespace
bool tryPop(oslFileHandle& rHandle)
{
- bool bRetval(false);
-
if (!maPackedFileEntryVector.empty())
{
// already backups there, check if different from last entry
@@ -1630,7 +1628,7 @@ namespace
// here the uncompress flag has to be determined, true
// means to add the file compressed, false means to add it
// uncompressed
- bRetval = aLastEntry.copy_content(rHandle, true);
+ bool bRetval = aLastEntry.copy_content(rHandle, true);
if (bRetval)
{
diff --git a/comphelper/source/windows/windows_process.cxx b/comphelper/source/windows/windows_process.cxx
index e71f28be545b..f334cfc4ffbe 100644
--- a/comphelper/source/windows/windows_process.cxx
+++ b/comphelper/source/windows/windows_process.cxx
@@ -21,7 +21,6 @@
*/
static int ArgStrLen(const wchar_t *s)
{
- int backslashes = 0;
int i = wcslen(s);
BOOL hasDoubleQuote = wcschr(s, L'"') != nullptr;
// Only add doublequotes if the string contains a space or a tab
@@ -34,6 +33,7 @@ static int ArgStrLen(const wchar_t *s)
if (hasDoubleQuote)
{
+ int backslashes = 0;
while (*s)
{
if (*s == '\\')
@@ -69,7 +69,6 @@ static int ArgStrLen(const wchar_t *s)
*/
static wchar_t* ArgToString(wchar_t *d, const wchar_t *s)
{
- int backslashes = 0;
BOOL hasDoubleQuote = wcschr(s, L'"') != nullptr;
// Only add doublequotes if the string contains a space or a tab
BOOL addDoubleQuotes = wcspbrk(s, L" \t") != nullptr;
@@ -82,7 +81,7 @@ static wchar_t* ArgToString(wchar_t *d, const wchar_t *s)
if (hasDoubleQuote)
{
- int i;
+ int backslashes = 0;
while (*s)
{
if (*s == '\\')
@@ -94,7 +93,7 @@ static wchar_t* ArgToString(wchar_t *d, const wchar_t *s)
if (*s == '"')
{
// Escape the doublequote and all backslashes preceding the doublequote
- for (i = 0; i <= backslashes; ++i)
+ for (int i = 0; i <= backslashes; ++i)
{
*d = '\\';
++d;
diff --git a/drawinglayer/source/tools/converters.cxx b/drawinglayer/source/tools/converters.cxx
index ee65e2526a74..41f861bb0172 100644
--- a/drawinglayer/source/tools/converters.cxx
+++ b/drawinglayer/source/tools/converters.cxx
@@ -42,9 +42,6 @@ namespace drawinglayer
sal_uInt32 nMaxQuadratPixels)
{
BitmapEx aRetval;
-#ifdef DBG_UTIL
- static bool bDoSaveForVisualControl(false);
-#endif
if(!rSeq.empty() && nDiscreteWidth && nDiscreteHeight)
{
@@ -89,6 +86,9 @@ namespace drawinglayer
if(pContentProcessor)
{
+#ifdef DBG_UTIL
+ static bool bDoSaveForVisualControl(false);
+#endif
// render content
pContentProcessor->process(aSequence);
diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx
index 1983e28c7b64..753d26678007 100644
--- a/editeng/source/editeng/impedit5.cxx
+++ b/editeng/source/editeng/impedit5.cxx
@@ -684,7 +684,6 @@ void ImpEditEngine::RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich, bool
void ImpEditEngine::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet )
{
- bool bCheckLanguage = false;
ContentNode* pNode = aEditDoc.GetObject( nPara );
if ( !pNode )
@@ -706,7 +705,7 @@ void ImpEditEngine::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet )
}
}
- bCheckLanguage = ( rSet.GetItemState( EE_CHAR_LANGUAGE ) == SfxItemState::SET ) ||
+ bool bCheckLanguage = ( rSet.GetItemState( EE_CHAR_LANGUAGE ) == SfxItemState::SET ) ||
( rSet.GetItemState( EE_CHAR_LANGUAGE_CJK ) == SfxItemState::SET ) ||
( rSet.GetItemState( EE_CHAR_LANGUAGE_CTL ) == SfxItemState::SET );
diff --git a/filter/source/graphicfilter/ipbm/ipbm.cxx b/filter/source/graphicfilter/ipbm/ipbm.cxx
index 3228b0bdc3ee..4b230af5c0d5 100644
--- a/filter/source/graphicfilter/ipbm/ipbm.cxx
+++ b/filter/source/graphicfilter/ipbm/ipbm.cxx
@@ -265,7 +265,6 @@ bool PBMReader::ImplReadHeader()
bool PBMReader::ImplReadBody()
{
- bool bPara, bFinished = false;
sal_uInt8 nDat = 0, nCount;
sal_uLong nGrey, nRGB[3];
sal_Int32 nWidth = 0;
@@ -340,8 +339,13 @@ bool PBMReader::ImplReadBody()
break;
}
}
- else switch ( mnMode )
+ else
{
+ bool bPara = false;
+ bool bFinished = false;
+
+ switch ( mnMode )
+ {
// PBM
case 0 :
while ( !bFinished )
@@ -524,6 +528,7 @@ bool PBMReader::ImplReadBody()
return false;
}
break;
+ }
}
return mbStatus;
}
diff --git a/filter/source/graphicfilter/ipict/shape.cxx b/filter/source/graphicfilter/ipict/shape.cxx
index 7b74a5a16a02..357f4a4e2adb 100644
--- a/filter/source/graphicfilter/ipict/shape.cxx
+++ b/filter/source/graphicfilter/ipict/shape.cxx
@@ -57,10 +57,10 @@ namespace PictReaderShape {
bool horiz = dir[1] == 0;
if (!horiz && !vertic && dir[0]*dir[0]+dir[1]*dir[1] > 25) return false;
- long X[2]={ orig.X(), dest.X() }, Y[2] = { orig.Y(), dest.Y() };
using namespace basegfx;
B2DPolygon poly;
if (horiz || vertic) {
+ long X[2]={ orig.X(), dest.X() }, Y[2] = { orig.Y(), dest.Y() };
if (horiz) {
if (X[0] < X[1]) X[1]+=pSize.Width();
else X[0]+=pSize.Width();
diff --git a/filter/source/graphicfilter/itiff/itiff.cxx b/filter/source/graphicfilter/itiff/itiff.cxx
index 12e53b314478..8752e9dd98b4 100644
--- a/filter/source/graphicfilter/itiff/itiff.cxx
+++ b/filter/source/graphicfilter/itiff/itiff.cxx
@@ -579,10 +579,9 @@ bool TIFFReader::ReadMap()
aCCIDecom.StartDecompression( *pTIFF );
- bool bDifferentToPrev;
for (sal_Int32 ny = 0; ny < nImageLength; ++ny)
{
- bDifferentToPrev = ny == 0;
+ bool bDifferentToPrev = ny == 0;
for (sal_uInt32 np = 0; np < nPlanes; ++np)
{
if ( ny / GetRowsPerStrip() + np * nStripsPerPlane > nStrip )
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index 63464150d7be..2cdb6f9ab674 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -2287,7 +2287,6 @@ void EscherPropertyContainer::CreateShadowProperties(
{
css::uno::Any aAny;
- bool bHasShadow = false; // shadow is possible only if at least a fillcolor, linecolor or graphic is set
sal_uInt32 nLineFlags = 0; // default : shape has no line
sal_uInt32 nFillFlags = 0x10; // shape is filled
@@ -2302,6 +2301,7 @@ void EscherPropertyContainer::CreateShadowProperties(
{
if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, "Shadow", true ) )
{
+ bool bHasShadow = false; // shadow is possible only if at least a fillcolor, linecolor or graphic is set
if ( aAny >>= bHasShadow )
{
if ( bHasShadow )
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index c3b1a95349c4..28f151060d30 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -4424,7 +4424,6 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
aSet.Put(makeSdrTextAutoGrowHeightItem(false));
aSet.Put(makeSdrTextAutoGrowWidthItem(false));
- double fRatio = 0;
VclPtr<VirtualDevice> pDevice = VclPtr<VirtualDevice>::Create();
vcl::Font aFont = pDevice->GetFont();
aFont.SetFamilyName( aFontName );
@@ -4436,7 +4435,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
if ( nTextWidth && aObjData.eShapeType == mso_sptTextPlainText
&& aObjName.match( "PowerPlusWaterMarkObject" ) )
{
- fRatio = (double)pDevice->GetTextHeight() / nTextWidth;
+ double fRatio = (double)pDevice->GetTextHeight() / nTextWidth;
sal_Int32 nNewHeight = fRatio * aObjData.aBoundRect.getWidth();
sal_Int32 nPaddingY = aObjData.aBoundRect.getHeight() - nNewHeight;
diff --git a/framework/source/services/frame.cxx b/framework/source/services/frame.cxx
index 17efc5d0386a..04441dc5c84c 100644
--- a/framework/source/services/frame.cxx
+++ b/framework/source/services/frame.cxx
@@ -2570,7 +2570,6 @@ void SAL_CALL Frame::windowClosing( const css::lang::EventObject& )
*//*-*****************************************************************************************************/
void SAL_CALL Frame::windowShown( const css::lang::EventObject& )
{
- static bool bFirstVisibleTask = true;
static osl::Mutex aFirstVisibleLock;
/* SAFE { */
@@ -2584,6 +2583,7 @@ void SAL_CALL Frame::windowShown( const css::lang::EventObject& )
if (xDesktopCheck.is())
{
+ static bool bFirstVisibleTask = true;
osl::ClearableMutexGuard aGuard(aFirstVisibleLock);
bool bMustBeTriggered = bFirstVisibleTask;
bFirstVisibleTask = false;
diff --git a/l10ntools/source/gConvXcu.cxx b/l10ntools/source/gConvXcu.cxx
index 58f22d78493c..cae480bb77e2 100644
--- a/l10ntools/source/gConvXcu.cxx
+++ b/l10ntools/source/gConvXcu.cxx
@@ -47,14 +47,13 @@ void convert_xcu::doExecute()
void convert_xcu::pushKey(char *syyText)
{
string sKey, sTag = copySource(syyText);
- int nL, nE;
// find key in tag
- nL = sTag.find("oor:name=\"");
+ int nL = sTag.find("oor:name=\"");
if (nL != (int)string::npos) {
// find end of key
nL += 10;
- nE = sTag.find("\"", nL);
+ int nE = sTag.find("\"", nL);
if (nE != (int)string::npos)
sKey = sTag.substr(nL, nE - nL);
}
diff --git a/l10ntools/source/gConvXrm.cxx b/l10ntools/source/gConvXrm.cxx
index 1dcc558198f3..a42a90c10dad 100644
--- a/l10ntools/source/gConvXrm.cxx
+++ b/l10ntools/source/gConvXrm.cxx
@@ -49,12 +49,10 @@ void convert_xrm::doExecute()
void convert_xrm::setId(char *yytext)
{
string& sText = copySource(yytext, mbNoCollectingData);
- int nL, nE;
-
if (mbIsTag) {
- nL = sText.find("\"");
- nE = sText.find("\"", nL+1);
+ int nL = sText.find("\"");
+ int nE = sText.find("\"", nL+1);
if (nL == (int)string::npos || nE == (int)string::npos)
return;
@@ -67,17 +65,14 @@ void convert_xrm::setId(char *yytext)
void convert_xrm::setLang(char *yytext)
{
string& sText = copySource(yytext, mbNoCollectingData);
- string sLang;
- int nL, nE;
-
if (mbIsTag) {
- nL = sText.find("\"");
- nE = sText.find("\"", nL+1);
+ int nL = sText.find("\"");
+ int nE = sText.find("\"", nL+1);
if (nL == (int)string::npos || nE == (int)string::npos)
return;
- sLang = sText.substr(nL+1, nE - nL -1);
+ string sLang = sText.substr(nL+1, nE - nL -1);
if (sLang == "en-US")
mbIsLang = true;
else
diff --git a/l10ntools/source/gL10nMem.cxx b/l10ntools/source/gL10nMem.cxx
index b8668f854666..3a8647f2eb18 100644
--- a/l10ntools/source/gL10nMem.cxx
+++ b/l10ntools/source/gL10nMem.cxx
@@ -441,9 +441,9 @@ void l10nMem::convertToInetString(string& sText)
static const int replacingLen[] = { 1, 1, 1, 1, 1, 0 };
static const char *newStr[] = { "&amp;", "&apos;", "&gt;", "&lt;", "&quot;", nullptr };
static const int newLen[] = { 5, 6, 4, 4, 6, 0 };
- int i, pos;
+ int pos;
- for (i = 0; replacingStr[i]; i++) {
+ for (int i = 0; replacingStr[i]; i++) {
pos = 0;
while ((pos = sText.find(replacingStr[i], pos)) != (int)string::npos) {
sText.replace(pos, replacingLen[i], newStr[i]);