summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2015-08-22 11:58:11 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2015-08-22 13:02:08 +0000
commit25accda781bc0bc79ca2e887c54ca981068bf407 (patch)
tree0f551b4f516dd289df523d71bff08a26de2c3622
parent159bace378aefa5e48967f1e5089acef9a7f2378 (diff)
tdf#39440 reduce scope of local variables
This addresses some cppcheck warnings. Change-Id: I6ab170c4426494ab9fc53017f88e47fbfdbd9aad Reviewed-on: https://gerrit.libreoffice.org/17920 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r--filter/source/msfilter/escherex.cxx19
-rw-r--r--filter/source/svg/svgexport.cxx9
-rw-r--r--framework/source/classes/menumanager.cxx3
-rw-r--r--hwpfilter/source/grammar.cxx5
-rw-r--r--hwpfilter/source/hwpeq.cxx2
-rw-r--r--idlc/source/astscope.cxx6
-rw-r--r--jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx2
-rw-r--r--jvmfwk/plugins/sunmajor/pluginlib/util.cxx2
-rw-r--r--l10ntools/source/xmlparse.cxx3
-rw-r--r--onlineupdate/source/update/updater/archivereader.cxx4
-rw-r--r--onlineupdate/source/update/updater/nsWindowsRestart.cxx2
11 files changed, 27 insertions, 30 deletions
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index c18ee94f1d64..fa693fc5ad6c 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -1423,25 +1423,26 @@ bool EscherPropertyContainer::CreateGraphicProperties(
bool bRetValue = false;
bool bCreateFillStyles = false;
- bool bMirrored = false;
- bool bRotate = true;
boost::scoped_ptr<GraphicAttr> pGraphicAttr;
GraphicObject aGraphicObject;
OUString aGraphicUrl;
OString aUniqueId;
- bool bIsGraphicMtf(false);
- // #121074#
- sal_Int16 nTransparency(0);
- sal_Int16 nRed(0);
- sal_Int16 nGreen(0);
- sal_Int16 nBlue(0);
- double fGamma(1.0);
::com::sun::star::drawing::BitmapMode eBitmapMode( ::com::sun::star::drawing::BitmapMode_NO_REPEAT );
::com::sun::star::uno::Any aAny;
if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, rSource ) )
{
+ bool bMirrored = false;
+ bool bRotate = true;
+ bool bIsGraphicMtf = false;
+ // #121074#
+ sal_Int16 nTransparency(0);
+ sal_Int16 nRed(0);
+ sal_Int16 nGreen(0);
+ sal_Int16 nBlue(0);
+ double fGamma(1.0);
+
sal_uInt16 nAngle = 0;
if ( rSource == "MetaFile" )
{
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index b0ddc8c4eb97..d600fb9e5694 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -1005,10 +1005,6 @@ bool SVGFilter::implGenerateMetaData()
{
bool bBackgroundVisibility = true; // default: visible
bool bBackgroundObjectsVisibility = true; // default: visible
- bool bPageNumberVisibility = false; // default: hidden
- bool bDateTimeVisibility = true; // default: visible
- bool bFooterVisibility = true; // default: visible
- bool bDateTimeFixed = true; // default: fixed
FixedDateTimeField aFixedDateTimeField;
VariableDateTimeField aVariableDateTimeField;
@@ -1024,6 +1020,11 @@ bool SVGFilter::implGenerateMetaData()
xPropSet->getPropertyValue( "IsBackgroundObjectsVisible" ) >>= bBackgroundObjectsVisibility;
if( bBackgroundObjectsVisibility ) // visibility default value: 'visible'
{
+ bool bPageNumberVisibility = false; // default: hidden
+ bool bDateTimeVisibility = true; // default: visible
+ bool bFooterVisibility = true; // default: visible
+ bool bDateTimeFixed = true; // default: fixed
+
/*
* Page Number Field
*/
diff --git a/framework/source/classes/menumanager.cxx b/framework/source/classes/menumanager.cxx
index 6e95b4cb7be4..039871da550d 100644
--- a/framework/source/classes/menumanager.cxx
+++ b/framework/source/classes/menumanager.cxx
@@ -539,8 +539,6 @@ void MenuManager::UpdateSpecialFileMenu( Menu* pMenu )
const sal_uInt32 nCount = aNewPickVector.size();
for ( sal_uInt32 i = 0; i < nCount; i++ )
{
- char menuShortCut[5] = "~n: ";
-
OUString aMenuShortCut;
if ( i <= 9 )
{
@@ -548,6 +546,7 @@ void MenuManager::UpdateSpecialFileMenu( Menu* pMenu )
aMenuShortCut = "1~0: ";
else
{
+ char menuShortCut[5] = "~n: ";
menuShortCut[1] = (char)( '1' + i );
aMenuShortCut = OUString::createFromAscii( menuShortCut );
}
diff --git a/hwpfilter/source/grammar.cxx b/hwpfilter/source/grammar.cxx
index 77984b97c9fa..42185466b88e 100644
--- a/hwpfilter/source/grammar.cxx
+++ b/hwpfilter/source/grammar.cxx
@@ -1238,11 +1238,10 @@ void yyerror(const char * /*err*/)
{
// printf("REALKING ERR[%s]\n",err);
// if error, delete all nodes.
- Node *pNode = 0L;
int ncount = nodelist.size();
for( int i = 0 ; i < ncount ; i++){
- pNode = nodelist.front();
- nodelist.pop_front();
+ Node *pNode = nodelist.front();
+ nodelist.pop_front();
delete pNode;
}
top = 0L;
diff --git a/hwpfilter/source/hwpeq.cxx b/hwpfilter/source/hwpeq.cxx
index 393a6dbea19d..732b2299168c 100644
--- a/hwpfilter/source/hwpeq.cxx
+++ b/hwpfilter/source/hwpeq.cxx
@@ -674,12 +674,12 @@ static char eq2ltxconv(MzString& sstr, istream *strm, const char *sentinel)
MzString white, token;
char key[256];
int ch, result;
- const hwpeq *eq = 0;
while( 0 != (result = next_token(white, token, strm)) ) {
if( sentinel && (result == 1) && strchr(sentinel, token[0]) )
break;
make_keyword(key, token);
+ const hwpeq *eq = 0;
if( (eq = lookup_eqn(key)) != 0 ) {
if( eq->latex )
strcpy(key, eq->latex);
diff --git a/idlc/source/astscope.cxx b/idlc/source/astscope.cxx
index c4a84c4d8c2e..cd8a48387496 100644
--- a/idlc/source/astscope.cxx
+++ b/idlc/source/astscope.cxx
@@ -87,12 +87,11 @@ sal_uInt16 AstScope::getNodeCount(NodeType nodeType)
{
DeclList::const_iterator iter = getIteratorBegin();
DeclList::const_iterator end = getIteratorEnd();
- AstDeclaration* pDecl = NULL;
sal_uInt16 count = 0;
while ( iter != end )
{
- pDecl = *iter;
+ AstDeclaration* pDecl = *iter;
if ( pDecl->getNodeType() == nodeType )
count++;
++iter;
@@ -199,11 +198,10 @@ AstDeclaration* AstScope::lookupByNameLocal(const OString& name) const
{
DeclList::const_iterator iter(m_declarations.begin());
DeclList::const_iterator end(m_declarations.end());
- AstDeclaration* pDecl = NULL;
while ( iter != end )
{
- pDecl = *iter;
+ AstDeclaration* pDecl = *iter;
if ( pDecl->getLocalName() == name )
return pDecl;
++iter;
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
index 44a902091144..634f65ba45f6 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
@@ -117,7 +117,6 @@ OString getPluginJarPath(
}
else
{
- char sep[] = {SAL_PATHSEPARATOR, 0};
OUString sName(sLocation + "/lib/" + sName1);
OUString sPath1;
OUString sPath2;
@@ -128,6 +127,7 @@ OString getPluginJarPath(
if (osl_getSystemPathFromFileURL(sName.pData, & sPath2.pData)
== osl_File_E_None)
{
+ char sep[] = {SAL_PATHSEPARATOR, 0};
sPath = sPath1 + OUString::createFromAscii(sep) + sPath2;
}
}
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
index 9a60c3a9232a..b378dbfc0f78 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
@@ -647,11 +647,11 @@ bool getJavaInfoFromRegistry(const wchar_t* szRegKey,
OUString usHome((sal_Unicode*) szTmpPath);
// check if there is already an entry with the same JavaHomeruntime lib
// if so, we use the one with the more accurate version
- bool bAppend= true;
OUString usHomeUrl;
if (osl_getFileURLFromSystemPath(usHome.pData, & usHomeUrl.pData) ==
osl_File_E_None)
{
+ bool bAppend= true;
//iterate over the vector with java home strings
typedef vector<OUString>::iterator ItHome;
for(ItHome itHome= vecJavaHome.begin();
diff --git a/l10ntools/source/xmlparse.cxx b/l10ntools/source/xmlparse.cxx
index 0d1d9065493a..701848f4b545 100644
--- a/l10ntools/source/xmlparse.cxx
+++ b/l10ntools/source/xmlparse.cxx
@@ -441,12 +441,11 @@ void XMLFile::SearchL10NElements( XMLChildNode *pCur, int nPos )
{
case XML_NODE_TYPE_FILE:
{
- XMLChildNode* pElement;
if( GetChildList())
{
for ( size_t i = 0; i < GetChildList()->size(); i++ )
{
- pElement = (*GetChildList())[ i ];
+ XMLChildNode* pElement = (*GetChildList())[ i ];
if( pElement->GetNodeType() == XML_NODE_TYPE_ELEMENT )
SearchL10NElements( pElement , i);
}
diff --git a/onlineupdate/source/update/updater/archivereader.cxx b/onlineupdate/source/update/updater/archivereader.cxx
index 4629d330e5cc..a7884df2d8de 100644
--- a/onlineupdate/source/update/updater/archivereader.cxx
+++ b/onlineupdate/source/update/updater/archivereader.cxx
@@ -273,7 +273,7 @@ ArchiveReader::ExtractItemToStream(const MarItem *item, FILE *fp)
/* decompress the data chunk by chunk */
bz_stream strm;
- int offset, inlen, outlen, ret = OK;
+ int offset, inlen, ret = OK;
memset(&strm, 0, sizeof(strm));
if (BZ2_bzDecompressInit(&strm, 0, 0) != BZ_OK)
@@ -304,7 +304,7 @@ ArchiveReader::ExtractItemToStream(const MarItem *item, FILE *fp)
break;
}
- outlen = outbuf_size - strm.avail_out;
+ int outlen = outbuf_size - strm.avail_out;
if (outlen) {
if (fwrite(outbuf, outlen, 1, fp) != 1) {
ret = WRITE_ERROR_EXTRACT;
diff --git a/onlineupdate/source/update/updater/nsWindowsRestart.cxx b/onlineupdate/source/update/updater/nsWindowsRestart.cxx
index 5ecf70e2aac8..fbc9b863c475 100644
--- a/onlineupdate/source/update/updater/nsWindowsRestart.cxx
+++ b/onlineupdate/source/update/updater/nsWindowsRestart.cxx
@@ -345,7 +345,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;
@@ -356,6 +355,7 @@ static wchar_t* ArgToString(wchar_t *d, const wchar_t *s)
}
if (hasDoubleQuote) {
+ int backslashes = 0;
int i;
while (*s) {
if (*s == '\\') {