[PATCH 1/3] cppcheck: reduce the scope of variables

Takeshi Abe tabe at fixedpoint.jp
Sat Nov 27 08:28:16 PST 2010


---
 dbaccess/source/ui/misc/DExport.cxx             |    4 ++--
 dbaccess/source/ui/misc/TokenWriter.cxx         |    4 ++--
 dbaccess/source/ui/tabledesign/TEditControl.cxx |    3 +--
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/dbaccess/source/ui/misc/DExport.cxx b/dbaccess/source/ui/misc/DExport.cxx
index cd9704d..86ebda9 100644
--- a/dbaccess/source/ui/misc/DExport.cxx
+++ b/dbaccess/source/ui/misc/DExport.cxx
@@ -330,13 +330,13 @@ void ODatabaseExport::insertValueIntoColumn()
                         m_pUpdateHelper->updateNull(nPos,pField->GetType());
                     else
                     {
-                        sal_Int32 nNumberFormat = 0;
-                        double fOutNumber = 0.0;
                         OSL_ENSURE((nNewPos) < static_cast<sal_Int32>(m_vColumnTypes.size()),"Illegal index for vector");
                         if (m_vColumnTypes[nNewPos] != DataType::VARCHAR && m_vColumnTypes[nNewPos] != DataType::CHAR && m_vColumnTypes[nNewPos] != DataType::LONGVARCHAR )
                         {
                             RTL_LOGFILE_CONTEXT_TRACE( aLogger, "ODatabaseExport::insertValueIntoColumn != DataType::VARCHAR" );
                             ensureFormatter();
+                            sal_Int32 nNumberFormat = 0;
+                            double fOutNumber = 0.0;
                             bool bNumberFormatError = false;
                             if ( m_pFormatter && m_sNumToken.Len() )
                             {
diff --git a/dbaccess/source/ui/misc/TokenWriter.cxx b/dbaccess/source/ui/misc/TokenWriter.cxx
index 800394f..a92f474 100644
--- a/dbaccess/source/ui/misc/TokenWriter.cxx
+++ b/dbaccess/source/ui/misc/TokenWriter.cxx
@@ -1005,13 +1005,13 @@ void OHTMLImportExport::WriteCell( sal_Int32 nFormat,sal_Int32 nWidthPixel,sal_I
     aStrTD = aStrTD + "=";
     aStrTD = aStrTD + pChar;
 
-    double fVal = 0.0;
-
     Reference< ::com::sun::star::util::XNumberFormatsSupplier >  xSupplier = m_xFormatter->getNumberFormatsSupplier();
     SvNumberFormatsSupplierObj* pSupplierImpl = SvNumberFormatsSupplierObj::getImplementation( xSupplier );
     SvNumberFormatter* pFormatter = pSupplierImpl ? pSupplierImpl->GetNumberFormatter() : NULL;
     if(pFormatter)
     {
+        double fVal = 0.0;
+
         try
         {
             fVal = m_xFormatter->convertStringToNumber(nFormat,rValue);
diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx
index 1a1eb6f..4f4dedb 100644
--- a/dbaccess/source/ui/tabledesign/TEditControl.cxx
+++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx
@@ -1781,7 +1781,6 @@ void OTableEditorCtrl::SetPrimaryKey( sal_Bool bSet )
     // Evtl. vorhandene Primary Keys loeschen
     MultiSelection aDeletedPrimKeys;
     aDeletedPrimKeys.SetTotalRange( Range(0,GetRowCount()) );
-    long nIndex = 0;
 
     ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = m_pRowList->begin();
     ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aEnd = m_pRowList->end();
@@ -1800,7 +1799,7 @@ void OTableEditorCtrl::SetPrimaryKey( sal_Bool bSet )
     aInsertedPrimKeys.SetTotalRange( Range(0,GetRowCount()) );
     if( bSet )
     {
-        nIndex = FirstSelectedRow();
+        long nIndex = FirstSelectedRow();
         while( nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()) )
         {
             //////////////////////////////////////////////////////////////////////
-- 
1.7.2.3


----Next_Part(Sun_Nov_28_01_40_21_2010_366)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Description: 0002-cppcheck-use-as-prefix.patch
Content-Disposition: inline; filename="0002-cppcheck-use-as-prefix.patch"



More information about the LibreOffice mailing list