[PATCH 5/6] [cppchecker] unreadVar warning - unneded variable deleted

Pierre-André Jacquod pjacquod at alumni.ethz.ch
Fri Sep 9 12:52:22 PDT 2011


After deleting the different assignment that were not used, some
part of the code could be simiplified, since there is no need
any more for the logic
---
 .../shellextensions/registerextensions.cxx         |   34 ++------------------
 1 files changed, 3 insertions(+), 31 deletions(-)

diff --git a/setup_native/source/win32/customactions/shellextensions/registerextensions.cxx b/setup_native/source/win32/customactions/shellextensions/registerextensions.cxx
index 28ea399..9435118 100644
--- a/setup_native/source/win32/customactions/shellextensions/registerextensions.cxx
+++ b/setup_native/source/win32/customactions/shellextensions/registerextensions.cxx
@@ -117,7 +117,6 @@ static BOOL RemoveCompleteDirectory( std::_tstring sPath )
 {
     bool bDirectoryRemoved = true;
 
-    std::_tstring mystr;
     std::_tstring sPattern = sPath + TEXT("\\") + TEXT("*.*");
     WIN32_FIND_DATA aFindData;
 
@@ -135,8 +134,6 @@ static BOOL RemoveCompleteDirectory( std::_tstring sPath )
             std::_tstring sCurrentDir = TEXT(".");
             std::_tstring sParentDir = TEXT("..");
 
-            mystr = "Current short file: " + sFileName;
-
             if (( strcmp(sFileName.c_str(),sCurrentDir.c_str()) != 0 ) &&
                 ( strcmp(sFileName.c_str(),sParentDir.c_str()) != 0 ))
             {
@@ -144,27 +141,11 @@ static BOOL RemoveCompleteDirectory( std::_tstring sPath )
 
                 if ( aFindData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY )
                 {
-                    bool fSuccess = RemoveCompleteDirectory(sCompleteFileName);
-                    if ( fSuccess )
-                    {
-                        mystr = "Successfully removed content of dir " + sCompleteFileName;
-                    }
-                    else
-                    {
-                        mystr = "An error occurred during removing content of " + sCompleteFileName;
-                    }
+                    RemoveCompleteDirectory(sCompleteFileName);
                 }
                 else
                 {
-                    bool fSuccess = DeleteFile( sCompleteFileName.c_str() );
-                    if ( fSuccess )
-                    {
-                        mystr = "Successfully removed file " + sCompleteFileName;
-                    }
-                    else
-                    {
-                        mystr = "An error occurred during removal of file " + sCompleteFileName;
-                    }
+                    DeleteFile( sCompleteFileName.c_str() );
                 }
             }
 
@@ -178,17 +159,8 @@ static BOOL RemoveCompleteDirectory( std::_tstring sPath )
         // RemoveDirectory is only successful, if the last handle to the directory is closed
         // -> first removing content -> closing handle -> remove empty directory
 
-        bool fRemoveDirSuccess = RemoveDirectory(sPath.c_str());
-
-        if ( fRemoveDirSuccess )
-        {
-            mystr = "Successfully removed dir " + sPath;
-            // MessageBox(NULL, mystr.c_str(), "Removed Directory", MB_OK);
-        }
-        else
+        if ( ! ( RemoveDirectory(sPath.c_str()) ) )
         {
-            mystr = "An error occurred during removal of empty directory " + sPath;
-            // MessageBox(NULL, mystr.c_str(), "Error removing directory", MB_OK);
             bDirectoryRemoved = false;
         }
     }
-- 
1.7.3.4


--------------000904010106030702050302
Content-Type: text/x-patch;
 name="0004-cppchecker-unreadVar-warning-deleted-unneded-variabl.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0004-cppchecker-unreadVar-warning-deleted-unneded-variabl.pa";
 filename*1="tch"



More information about the LibreOffice mailing list