浏览代码

Clang imposed changes that should be noop and have no effect on classic compiler (2nd after 92ba1e3f0 + preceding commits)

Mostly
– explicit static global variables
– const, sign and down casts safety
– same-named variables in nested scopes
– incorrectly identified uninitialized variables
– semicolon after function implementation
– unused variables, fields, arguments and macros
– exact include filename case
– field initialization order
– typename use
– struct vs class declarations
– incorrectly identified uninitialized variables
– refactoring to solve Clang internal compiler error when using new variable in __finally block

Source commit: 3da995ff5169eefcfe3b3b7cc0d019c660096c07
Martin Prikryl 3 月之前
父节点
当前提交
74fdf539de
共有 86 个文件被更改,包括 468 次插入431 次删除
  1. 4 5
      source/WinSCP.cpp
  2. 6 6
      source/components/ThemePageControl.cpp
  3. 14 3
      source/components/UnixDirView.cpp
  4. 6 0
      source/components/UnixDirView.h
  5. 15 6
      source/components/UnixDriveView.cpp
  6. 1 1
      source/components/UnixDriveView.h
  7. 41 3
      source/core/Common.h
  8. 2 1
      source/core/Global.h
  9. 6 0
      source/core/HierarchicalStorage.cpp
  10. 1 0
      source/core/HierarchicalStorage.h
  11. 1 0
      source/dragext/DragExt.h
  12. 1 1
      source/forms/About.cpp
  13. 1 1
      source/forms/About.h
  14. 1 1
      source/forms/Authenticate.h
  15. 1 1
      source/forms/Cleanup.h
  16. 1 1
      source/forms/Console.h
  17. 1 2
      source/forms/Copy.h
  18. 1 1
      source/forms/CopyLocal.h
  19. 1 1
      source/forms/CopyParamCustom.h
  20. 1 1
      source/forms/CopyParamPreset.h
  21. 1 1
      source/forms/CopyParams.h
  22. 1 1
      source/forms/CreateDirectory.h
  23. 2 2
      source/forms/Custom.h
  24. 1 1
      source/forms/CustomCommand.h
  25. 44 43
      source/forms/CustomScpExplorer.cpp
  26. 6 5
      source/forms/CustomScpExplorer.h
  27. 1 1
      source/forms/EditMask.h
  28. 4 6
      source/forms/Editor.cpp
  29. 1 1
      source/forms/EditorPreferences.h
  30. 2 2
      source/forms/FileFind.cpp
  31. 1 1
      source/forms/FileFind.h
  32. 1 1
      source/forms/FileSystemInfo.h
  33. 1 1
      source/forms/FullSynchronize.h
  34. 1 1
      source/forms/GenerateUrl.h
  35. 1 1
      source/forms/ImportSessions.h
  36. 1 1
      source/forms/License.cpp
  37. 1 1
      source/forms/LocationProfiles.cpp
  38. 1 1
      source/forms/LocationProfiles.h
  39. 1 1
      source/forms/Login.cpp
  40. 1 1
      source/forms/Login.h
  41. 6 5
      source/forms/MessageDlg.cpp
  42. 6 5
      source/forms/NonVisual.cpp
  43. 2 2
      source/forms/OpenDirectory.cpp
  44. 1 1
      source/forms/OpenDirectory.h
  45. 7 6
      source/forms/Preferences.cpp
  46. 1 1
      source/forms/Preferences.h
  47. 2 2
      source/forms/Progress.cpp
  48. 1 3
      source/forms/Progress.h
  49. 1 1
      source/forms/Properties.h
  50. 1 1
      source/forms/RemoteTransfer.h
  51. 1 1
      source/forms/Rights.h
  52. 8 7
      source/forms/ScpCommander.cpp
  53. 0 2
      source/forms/ScpCommander.h
  54. 1 1
      source/forms/SelectMask.h
  55. 3 3
      source/forms/SiteAdvanced.cpp
  56. 1 3
      source/forms/SiteAdvanced.h
  57. 1 1
      source/forms/Symlink.h
  58. 2 2
      source/forms/Synchronize.cpp
  59. 2 2
      source/forms/Synchronize.h
  60. 2 2
      source/forms/SynchronizeChecklist.cpp
  61. 1 1
      source/forms/SynchronizeChecklist.h
  62. 1 1
      source/forms/SynchronizeProgress.h
  63. 8 3
      source/packages/filemng/CustomDirView.pas
  64. 6 7
      source/windows/ConsoleRunner.cpp
  65. 3 3
      source/windows/CustomWinConfiguration.cpp
  66. 3 3
      source/windows/CustomWinConfiguration.h
  67. 1 1
      source/windows/GUIConfiguration.cpp
  68. 20 21
      source/windows/GUITools.cpp
  69. 2 2
      source/windows/GUITools.h
  70. 1 1
      source/windows/ProgParams.cpp
  71. 4 4
      source/windows/QueueController.cpp
  72. 2 2
      source/windows/QueueController.h
  73. 15 19
      source/windows/Setup.cpp
  74. 0 1
      source/windows/SynchronizeController.h
  75. 52 47
      source/windows/TerminalManager.cpp
  76. 2 3
      source/windows/TerminalManager.h
  77. 9 11
      source/windows/Tools.cpp
  78. 1 1
      source/windows/Tools.h
  79. 1 1
      source/windows/UserInterface.cpp
  80. 6 20
      source/windows/VCLCommon.cpp
  81. 30 45
      source/windows/WinConfiguration.cpp
  82. 10 10
      source/windows/WinConfiguration.h
  83. 1 1
      source/windows/WinHelp.cpp
  84. 7 9
      source/windows/WinInterface.cpp
  85. 33 33
      source/windows/WinInterface.h
  86. 21 22
      source/windows/WinMain.cpp

+ 4 - 5
source/WinSCP.cpp

@@ -21,13 +21,13 @@ void __fastcall AppLogImpl(UnicodeString S)
   AppLog(S);
 }
 //---------------------------------------------------------------------------
-WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int)
+int WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int)
 {
   int Result = 0;
   try
   {
     TProgramParams * Params = TProgramParams::Instance();
-    ApplicationLog = new TApplicationLog();
+    TObjectReleaser<TApplicationLog> ApplicationLogReleaser(ApplicationLog, new TApplicationLog());
     UnicodeString AppLogPath;
     if (Params->FindSwitch(L"applog", AppLogPath))
     {
@@ -89,16 +89,15 @@ WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int)
     }
     __finally
     {
-      AppLog(L"Finalizing");
+      AppLogImpl(L"Finalizing"); // AppLog causes internal compiler error
       GUIFinalize();
       FinalizeSystemSettings();
       FinalizeWinHelp();
       CoreFinalize();
       WinFinalize();
       LogModules();
-      AppLog(L"Finalizing done");
+      AppLogImpl(L"Finalizing done");
       OnAppLog = NULL;
-      SAFE_DESTROY_EX(TApplicationLog, ApplicationLog);
     }
   }
   catch (Exception &E)

+ 6 - 6
source/components/ThemePageControl.cpp

@@ -181,8 +181,8 @@ int __fastcall TThemePageControl::GetTabsHeight()
   // so we want to know in case they differ.
   if (DebugAlwaysTrue(PageCount >= 0))
   {
-    TRect Rect = TabRect(0);
-    int Result2 = Rect.Bottom + 1;
+    TRect Rect2 = TabRect(0);
+    int Result2 = Rect2.Bottom + 1;
     // On Windows 10 with 200% scaling, the first is 40, the second is 42.
     // With 250% scaling it's 50 vs 53.
     // Using the larger.
@@ -411,10 +411,10 @@ void __fastcall TThemePageControl::DrawTabItem(HDC DC, int Item, TRect Rect, int
   {
     if (ATabTheme != NULL)
     {
-      SetTextColor(DC, ATabTheme->GetItemTextColor(GetItemInfo(State)));
+      SetTextColor(DC, static_cast<COLORREF>(ATabTheme->GetItemTextColor(GetItemInfo(State))));
     }
     HFONT OldFont = (HFONT)SelectObject(DC, Font->Handle);
-    wchar_t * Buf = new wchar_t[Text.Length() + 1 + 4];
+    wchar_t * Buf = new wchar_t[static_cast<size_t>(Text.Length() + 1 + 4)];
     wcscpy(Buf, Text.c_str());
     TRect TextRect(0, 0, Rect.Width(), 20);
     // Truncates too long texts with ellipsis
@@ -443,11 +443,11 @@ void __fastcall TThemePageControl::DrawTabItem(HDC DC, int Item, TRect Rect, int
       COLORREF ShapeColor;
       if (ATabTheme != NULL)
       {
-        ShapeColor = ColorToRGB(ATabTheme->GetItemTextColor(ButtonItemInfo));
+        ShapeColor = static_cast<COLORREF>(ColorToRGB(ATabTheme->GetItemTextColor(ButtonItemInfo)));
       }
       else
       {
-        ShapeColor = ColorToRGB(Font->Color);
+        ShapeColor = static_cast<COLORREF>(ColorToRGB(Font->Color));
       }
       #define BlendValue(FN) (((4 * static_cast<int>(FN(BackColor))) + static_cast<int>(FN(ShapeColor))) / 5)
       COLORREF BlendColor = RGB(BlendValue(GetRValue), BlendValue(GetGValue), BlendValue(GetBValue));

+ 14 - 3
source/components/UnixDirView.cpp

@@ -3,6 +3,8 @@
 #include <vcl.h>
 #pragma hdrstop
 
+#ifndef DESIGN_ONLY
+#endif
 #include <Common.h>
 
 #include "UnixDirView.h"
@@ -40,7 +42,9 @@ namespace Unixdirview
   }
 }
 //---------------------------------------------------------------------------
+#ifndef DESIGN_ONLY
 #define HOMEDIRECTORY L""
+#endif
 //---------------------------------------------------------------------------
 __fastcall TUnixDirView::TUnixDirView(TComponent* Owner)
         : TCustomUnixDirView(Owner)
@@ -449,7 +453,7 @@ void __fastcall TUnixDirView::GetDisplayInfo(TListItem * Item, tagLVITEMW &DispI
         case uvType: Value = File->TypeName; break;
         default: DebugFail();
       }
-      StrPLCopy(DispInfo.pszText, Value, DispInfo.cchTextMax - 1);
+      StrPLCopy(DispInfo.pszText, Value, static_cast<unsigned int>(DispInfo.cchTextMax - 1));
     }
 
     if (DispInfo.iSubItem == 0 && DispInfo.mask & LVIF_IMAGE)
@@ -761,14 +765,19 @@ void __fastcall TUnixDirView::SetPath(UnicodeString Value)
     PathChanging(true);
     Terminal->CurrentDirectory = Value;
   }
+#else
+  DebugUsedParam(Value);
 #endif
 }
 //---------------------------------------------------------------------------
 #ifndef DESIGN_ONLY
 #define COMPARE_NUMBER(Num1, Num2) ( Num1 < Num2 ? -1 : ( Num1 > Num2 ? 1 : 0) )
 //---------------------------------------------------------------------------
-int __stdcall CompareFile(TListItem * Item1, TListItem * Item2, TUnixDirView * DirView)
+int __stdcall CompareFile(INT_PTR AItem1, INT_PTR AItem2, INT_PTR ADirView)
 {
+  TListItem * Item1 = reinterpret_cast<TListItem *>(AItem1);
+  TListItem * Item2 = reinterpret_cast<TListItem *>(AItem2);
+  TUnixDirView * DirView = reinterpret_cast<TUnixDirView *>(ADirView);
   DebugAssert((Item1 != NULL) && (Item2 != NULL));
   TRemoteFile * File1 = DebugNotNull((TRemoteFile *)(Item1->Data));
   TRemoteFile * File2 = DebugNotNull((TRemoteFile *)(Item2->Data));
@@ -969,6 +978,8 @@ void __fastcall TUnixDirView::ChangeDirectory(UnicodeString Path)
       Reload(false);
     };
   }
+#else
+  DebugUsedParam(Path);
 #endif
 }
 //---------------------------------------------------------------------------
@@ -1025,6 +1036,7 @@ void __fastcall TUnixDirView::CreateDirectoryEx(UnicodeString DirName, const TRe
   }
   Terminal->CreateDirectory(DirName, Properties);
 #else
+  DebugUsedParam(DirName);
   DebugUsedParam(Properties);
 #endif
 }
@@ -1076,7 +1088,6 @@ TDateTime __fastcall TUnixDirView::ItemFileTime(TListItem * Item,
       break;
 
     case mfFull:
-    default:
       Precision = tpSecond;
       break;
   }

+ 6 - 0
source/components/UnixDirView.h

@@ -14,6 +14,12 @@ class TCustomUnixDriveView;
 class TRemoteFile;
 class TRemoteProperties;
 //---------------------------------------------------------------------------
+#ifdef DESIGN_ONLY
+class TRemoteFile
+{
+};
+#endif
+//---------------------------------------------------------------------------
 enum TTransferDirection { tdToRemote, tdToLocal };
 enum TTransferType { ttCopy, ttMove };
 typedef void __fastcall (__closure *TDDDragFileName)

+ 15 - 6
source/components/UnixDriveView.cpp

@@ -3,6 +3,9 @@
 #include <vcl.h>
 #pragma hdrstop
 
+#ifndef DESIGN_ONLY
+#endif
+
 #include <Common.h>
 
 #include "UnixDriveView.h"
@@ -153,6 +156,7 @@ bool __fastcall TCustomUnixDriveView::NodeIsHidden(const TTreeNode * Node)
     ((File != NULL) && File->IsHidden) ||
     ((File == NULL) && IsUnixHiddenFile(UnixExtractFileName(Data->Directory)));
   #else
+  DebugUsedParam(Node);
   return false;
   #endif
 }
@@ -230,11 +234,11 @@ void __fastcall TCustomUnixDriveView::UpdatePath(TTreeNode * Node, bool Force,
           int ChildIndex = ChildrenDirs->IndexOf(File->FileName);
           if (ChildIndex >= 0)
           {
-            TTreeNode * ChildNode =
+            TTreeNode * ChildNode2 =
               dynamic_cast<TTreeNode *>(ChildrenDirs->Objects[ChildIndex]);
-            TNodeData * ChildData = NodeData(ChildNode);
+            TNodeData * ChildData = NodeData(ChildNode2);
             ChildData->File = File;
-            UpdatePath(ChildNode, Force);
+            UpdatePath(ChildNode2, Force);
           }
           else
           {
@@ -253,11 +257,11 @@ void __fastcall TCustomUnixDriveView::UpdatePath(TTreeNode * Node, bool Force,
 
       for (int i = 0; i < ChildrenDirs->Count; i++)
       {
-        TTreeNode * ChildNode = dynamic_cast<TTreeNode *>(ChildrenDirs->Objects[i]);
-        TNodeData * ChildData = NodeData(ChildNode);
+        TTreeNode * ChildNode2 = dynamic_cast<TTreeNode *>(ChildrenDirs->Objects[i]);
+        TNodeData * ChildData = NodeData(ChildNode2);
         if (ChildData->File == NULL)
         {
-          NodeTryDelete(ChildNode, true);
+          NodeTryDelete(ChildNode2, true);
         }
       }
 
@@ -321,6 +325,7 @@ TTreeNode * __fastcall TCustomUnixDriveView::LoadPathEasy(TTreeNode * Parent,
   return Node;
   #else
   DebugUsedParam(Parent);
+  DebugUsedParam(Path);
   DebugUsedParam(File);
   return NULL;
   #endif
@@ -382,6 +387,7 @@ TTreeNode * __fastcall TCustomUnixDriveView::LoadPath(UnicodeString Path)
 
   return Node;
   #else
+  DebugUsedParam(Path);
   return NULL;
   #endif
 }
@@ -844,6 +850,7 @@ TTreeNode * __fastcall TCustomUnixDriveView::FindNodeToPath(UnicodeString Path)
     }
   }
   #else
+  DebugUsedParam(Path);
   Result = NULL;
   #endif
   return Result;
@@ -867,6 +874,8 @@ TTreeNode * __fastcall TCustomUnixDriveView::FindPathNode(UnicodeString Path)
     }
     while (Result == NULL);
   }
+  #else
+  DebugUsedParam(Path);
   #endif
 
   return Result;

+ 1 - 1
source/components/UnixDriveView.h

@@ -84,7 +84,7 @@ protected:
   #pragma warn -inl
   BEGIN_MESSAGE_MAP
     VCL_MESSAGE_HANDLER(CM_SHOWINGCHANGED, TMessage, CMShowingChanged)
-  END_MESSAGE_MAP(TCustomDriveView);
+  END_MESSAGE_MAP(TCustomDriveView)
   #pragma warn +inl
 
   __property TTerminal * Terminal = { read = FTerminal, write = SetTerminal };

+ 41 - 3
source/core/Common.h

@@ -290,12 +290,12 @@ UnicodeString FormatDateTimeSpan(const TDateTime & DateTime);
 UnicodeString FormatRelativeTime(const TDateTime & ANow, const TDateTime & AThen, bool DateOnly);
 TStrings * TlsCipherList();
 //---------------------------------------------------------------------------
-template<class MethodT>
-MethodT __fastcall MakeMethod(void * Data, void * Code)
+template<typename MethodT, typename FuncT>
+MethodT __fastcall MakeMethod(void * Data, FuncT Code)
 {
   MethodT Method;
   ((TMethod*)&Method)->Data = Data;
-  ((TMethod*)&Method)->Code = Code;
+  ((TMethod*)&Method)->Code = reinterpret_cast<void *>(Code);
   return Method;
 }
 //---------------------------------------------------------------------------
@@ -388,12 +388,50 @@ public:
     Release();
   }
 
+  void Set(const T & Value)
+  {
+    DebugAssert(FArmed);
+    FTarget = Value;
+  }
+
 protected:
   T & FTarget;
   T FValue;
   bool FArmed;
 };
 //---------------------------------------------------------------------------
+template<class T>
+class TObjectReleaser
+{
+public:
+  TObjectReleaser(T *& Target, T * Value) :
+    FPtr(Value),
+    FRestorer(Target, Value)
+  {
+  }
+
+  TObjectReleaser(T *& Target) :
+    FRestorer(Target)
+  {
+  }
+
+  void Set(T * Value)
+  {
+    FPtr.reset(Value);
+    FRestorer.Set(Value);
+  }
+
+  void Reset()
+  {
+    FPtr.reset(NULL);
+    FRestorer.Release();
+  }
+
+private:
+  std::unique_ptr<T> FPtr;
+  TValueRestorer<T *> FRestorer;
+};
+//---------------------------------------------------------------------------
 class TAutoNestingCounter : public TValueRestorer<int>
 {
 public:

+ 2 - 1
source/core/Global.h

@@ -13,6 +13,7 @@
 //---------------------------------------------------------------------------
 UnicodeString NormalizeString(const UnicodeString & S);
 UnicodeString DenormalizeString(const UnicodeString & S);
+#define DateTimeToVariant(DATETIME) static_cast<long double>(static_cast<double>(DATETIME))
 //---------------------------------------------------------------------------
 class TGuard
 {
@@ -48,7 +49,7 @@ private:
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 #include <assert.h>
-#define ACCESS_VIOLATION_TEST { (*((int*)NULL)) = 0; }
+#define ACCESS_VIOLATION_TEST { (*((volatile int*)NULL)) = 0; }
 #if defined(_DEBUG) && !defined(DESIGN_ONLY)
 #define DODEBUGGING
 #endif

+ 6 - 0
source/core/HierarchicalStorage.cpp

@@ -829,6 +829,12 @@ void __fastcall THierarchicalStorage::WriteInteger(const UnicodeString & Name, i
   }
 }
 //---------------------------------------------------------------------------
+// Simple alias to WriteInteger
+void __fastcall THierarchicalStorage::WriteEnum(const UnicodeString & Name, int Value)
+{
+  WriteInteger(Name, Value);
+}
+//---------------------------------------------------------------------------
 void __fastcall THierarchicalStorage::WriteInt64(const UnicodeString & Name, __int64 Value)
 {
   if (CanWrite())

+ 1 - 0
source/core/HierarchicalStorage.h

@@ -55,6 +55,7 @@ public:
   void __fastcall WriteBool(const UnicodeString & Name, bool Value);
   void __fastcall WriteStringRaw(const UnicodeString & Name, const UnicodeString & Value);
   void __fastcall WriteInteger(const UnicodeString & Name, int Value);
+  void __fastcall WriteEnum(const UnicodeString & Name, int Value);
   void __fastcall WriteInt64(const UnicodeString & Name, __int64 Value);
   void __fastcall WriteDateTime(const UnicodeString & Name, TDateTime Value);
   void __fastcall WriteFloat(const UnicodeString & Name, double Value);

+ 1 - 0
source/dragext/DragExt.h

@@ -14,6 +14,7 @@
 #pragma clang diagnostic ignored "-Wmissing-variable-declarations"
 #endif
 //---------------------------------------------------------------------------
+EXTERN_C const CLSID CLSID_ShellExtension;
 DEFINE_GUID(CLSID_ShellExtension, 0xe15e1d68, 0x0d1c, 0x49f7,
   0xbe, 0xb8, 0x81, 0x2b, 0x1e, 0x00, 0xfa, 0x60 );
 //---------------------------------------------------------------------------

+ 1 - 1
source/forms/About.cpp

@@ -53,7 +53,7 @@ void __fastcall DoAboutDialog(TConfiguration * Configuration,
   {
     DoAboutDialog(Configuration, AllowLicense, Registration, true);
   }
-  catch (EOleException & E)
+  catch (EOleException &)
   {
     // This happens particularly on Wine that does not support some
     // functionality of embedded IE we need.

+ 1 - 1
source/forms/About.h

@@ -59,7 +59,7 @@ private:
   void __fastcall ShiftControls(int From, int Diff);
 
 protected:
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 
 public:
   virtual __fastcall TAboutDialog(TComponent * AOwner,

+ 1 - 1
source/forms/Authenticate.h

@@ -133,7 +133,7 @@ private:
   int FHintIndex;
   TLabel * FContextLabel;
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 };
 //---------------------------------------------------------------------------
 #endif

+ 1 - 1
source/forms/Cleanup.h

@@ -42,7 +42,7 @@ private:
   void __fastcall AddLocation(int CaptionId, const UnicodeString & Location, TCleanupEvent Event);
   void __fastcall AddRegistryLocation(int CaptionId, const UnicodeString & Location, TCleanupEvent Event);
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 
 public:
   virtual __fastcall TCleanupDialog(TComponent * AOwner);

+ 1 - 1
source/forms/Console.h

@@ -81,7 +81,7 @@ protected:
   virtual void __fastcall Dispatch(void * Message);
   void __fastcall DoAdjustWindow();
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 
 public:
   virtual __fastcall ~TConsoleDialog();

+ 1 - 2
source/forms/Copy.h

@@ -54,7 +54,6 @@ __published:
   void __fastcall OkButtonDropDownClick(TObject *Sender);
   void __fastcall FormAfterMonitorDpiChanged(TObject *Sender, int OldDPI, int NewDPI);
 private:
-  bool FDefaultToRemote;
   bool FToRemote;
   TStrings * FFileList;
   bool FMove;
@@ -87,7 +86,7 @@ protected:
   int __fastcall ActualCopyParamAttrs();
   virtual void __fastcall CreateWnd();
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 
 public:
   __fastcall TCopyDialog(

+ 1 - 1
source/forms/CopyLocal.h

@@ -40,7 +40,7 @@ private:
   UnicodeString GetFileMask();
   void SetDirectoryAndFileMask(const UnicodeString & Directory, const UnicodeString & FileMask);
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 
 public:
   TCopyLocalDialog(TComponent * Owner, bool Move, int Options);

+ 1 - 1
source/forms/CopyParamCustom.h

@@ -24,7 +24,7 @@ public:
   bool __fastcall Execute(TCopyParamType & CopyParam);
 
 protected:
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 };
 //---------------------------------------------------------------------------
 #endif

+ 1 - 1
source/forms/CopyParamPreset.h

@@ -47,7 +47,7 @@ protected:
   TCopyParamRule * __fastcall GetRule();
   void __fastcall SetRuleData(const TCopyParamRuleData & Data);
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 
 public:
   __fastcall TCopyParamPresetDialog(TComponent * Owner,

+ 1 - 1
source/forms/CopyParams.h

@@ -77,7 +77,7 @@ protected:
   void __fastcall UpdateRightsByStr();
   virtual void __fastcall CreateWnd();
 
-  INTERFACE_HOOK_CUSTOM(TFrame);
+  INTERFACE_HOOK_CUSTOM(TFrame)
 
 public:
   __fastcall TCopyParamsFrame(TComponent* Owner);

+ 1 - 1
source/forms/CreateDirectory.h

@@ -41,7 +41,7 @@ public:
 protected:
   void __fastcall UpdateControls();
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 
 private:
   int FAllowedChanges;

+ 2 - 2
source/forms/Custom.h

@@ -6,7 +6,7 @@
 #include <Vcl.Controls.hpp>
 #include <Vcl.StdCtrls.hpp>
 //----------------------------------------------------------------------------
-#include <Windows.h>
+#include <windows.h>
 #include <GUITools.h>
 //----------------------------------------------------------------------------
 class TCustomDialog : public TForm
@@ -41,7 +41,7 @@ protected:
   virtual void __fastcall DoHelp();
   void __fastcall Change(TObject * Sender);
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 
 public:
   __fastcall TCustomDialog(UnicodeString HelpKeyword);

+ 1 - 1
source/forms/CustomCommand.h

@@ -55,7 +55,7 @@ private:
 protected:
   void __fastcall UpdateControls();
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 
 public:
   __fastcall TCustomCommandDialog(TComponent* Owner,

+ 44 - 43
source/forms/CustomScpExplorer.cpp

@@ -151,8 +151,8 @@ public:
 };
 //---------------------------------------------------------------------------
 __fastcall TCustomScpExplorerForm::TCustomScpExplorerForm(TComponent* Owner):
-    FFormRestored(false),
-    TForm(Owner)
+    TForm(Owner),
+    FFormRestored(false)
 {
   AddStartupSequence(L"F");
   FInvalid = false;
@@ -479,13 +479,13 @@ void __fastcall TCustomScpExplorerForm::WMCopyData(TMessage & Message)
 
         case TCopyDataMessage::CommandCommandLine:
           {
-            UnicodeString CommandLine(Message.CommandLine);
+            UnicodeString CommandLine(Message.Data.CommandLine);
             Result = CommandLineFromAnotherInstance(CommandLine);
           }
           break;
 
         case TCopyDataMessage::RefreshPanel:
-          RefreshPanel(Message.Refresh.Session, Message.Refresh.Path);
+          RefreshPanel(Message.Data.Refresh.Session, Message.Data.Refresh.Path);
           break;
 
         case TCopyDataMessage::MainWindowCheck:
@@ -504,7 +504,7 @@ void __fastcall TCustomScpExplorerForm::WMCopyData(TMessage & Message)
 //---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::CreateHiddenWindow()
 {
-  WNDCLASS WindowClass = {0};
+  WNDCLASS WindowClass = {};
   WindowClass.lpfnWndProc = DefWindowProc;
   WindowClass.hInstance = HInstance;
   WindowClass.lpszClassName = HIDDEN_WINDOW_NAME;
@@ -1254,7 +1254,7 @@ void __fastcall TCustomScpExplorerForm::FileColorsChanged()
 }
 //---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::FileConfigurationChanged(
-  const UnicodeString FileName, TEditedFileData * /*Data*/, TObject * Token,
+  const UnicodeString DebugUsedArg(FileName), TEditedFileData * /*Data*/, TObject * Token,
   void * /*Arg*/)
 {
   if (Token != NULL)
@@ -2099,45 +2099,39 @@ void __fastcall TCustomScpExplorerForm::RemoteCustomCommand(
     TCaptureOutputEvent OutputEvent = NULL;
 
     DebugAssert(FCapturedLog == NULL);
+    TObjectReleaser<TStrings> CapturedLogReleaser(FCapturedLog);
     if (Capture)
     {
-      FCapturedLog = new TStringList();
+      CapturedLogReleaser.Set(new TStringList());
       OutputEvent = TerminalCaptureLog;
     }
 
-    try
+    if (!RemoteCustomCommand.IsFileCommand(Command))
+    {
+      Terminal->AnyCommand(RemoteCustomCommand.Complete(Command, true),
+        OutputEvent);
+    }
+    else
+    {
+      Terminal->CustomCommandOnFiles(Command, ACommand.Params, FileList, OutputEvent);
+    }
+
+    if ((FCapturedLog != NULL) && (FCapturedLog->Count > 0))
     {
-      if (!RemoteCustomCommand.IsFileCommand(Command))
+      if (FLAGSET(ACommand.Params, ccCopyResults))
       {
-        Terminal->AnyCommand(RemoteCustomCommand.Complete(Command, true),
-          OutputEvent);
+        CopyToClipboard(FCapturedLog);
       }
-      else
+
+      if (FLAGSET(ACommand.Params, ccShowResults))
       {
-        Terminal->CustomCommandOnFiles(Command, ACommand.Params, FileList, OutputEvent);
+        DoConsoleDialog(Terminal, L"", FCapturedLog);
       }
-
-      if ((FCapturedLog != NULL) && (FCapturedLog->Count > 0))
+      else if (FLAGSET(ACommand.Params, ccShowResultsInMsgBox))
       {
-        if (FLAGSET(ACommand.Params, ccCopyResults))
-        {
-          CopyToClipboard(FCapturedLog);
-        }
-
-        if (FLAGSET(ACommand.Params, ccShowResults))
-        {
-          DoConsoleDialog(Terminal, L"", FCapturedLog);
-        }
-        else if (FLAGSET(ACommand.Params, ccShowResultsInMsgBox))
-        {
-          MessageDialog(FCapturedLog->Text, qtInformation, qaOK);
-        }
+        MessageDialog(FCapturedLog->Text, qtInformation, qaOK);
       }
     }
-    __finally
-    {
-      SAFE_DESTROY(FCapturedLog);
-    }
   }
 }
 //---------------------------------------------------------------------------
@@ -2775,7 +2769,7 @@ void __fastcall TCustomScpExplorerForm::RemoteDirViewContextPopup(
   Handled = true;
 }
 //---------------------------------------------------------------------------
-void __fastcall TCustomScpExplorerForm::ReloadLocalDirectory(const UnicodeString Directory)
+void __fastcall TCustomScpExplorerForm::ReloadLocalDirectory(const UnicodeString DebugUsedArg(Directory))
 {
 }
 //---------------------------------------------------------------------------
@@ -3088,6 +3082,7 @@ bool __fastcall TCustomScpExplorerForm::ExecuteFileOperation(TFileOperation Oper
   else
   {
     DebugFail();
+    Result = false; // shut up
   }
   return Result;
 }
@@ -3114,6 +3109,7 @@ TOperationSide TCustomScpExplorerForm::GetOtherSide(TOperationSide Side)
       Result = osLocal;
       break;
     default:
+      Result = osCurrent; // shut up
       DebugFail();
       Abort();
   }
@@ -6187,9 +6183,9 @@ void __fastcall TCustomScpExplorerForm::Synchronize(const UnicodeString LocalDir
   bool AnyOperation = false;
   TDateTime StartTime = Now();
   TSynchronizeChecklist * AChecklist = NULL;
+  TObjectReleaser<TSynchronizeProgressForm> SynchronizeProgressFormReleaser(FSynchronizeProgressForm, new TSynchronizeProgressForm(Application, true, -1));
   try
   {
-    FSynchronizeProgressForm = new TSynchronizeProgressForm(Application, true, -1);
     if (FLAGCLEAR(Params, TTerminal::spDelayProgress))
     {
       FSynchronizeProgressForm->Start();
@@ -6234,7 +6230,7 @@ void __fastcall TCustomScpExplorerForm::Synchronize(const UnicodeString LocalDir
     }
 
     FAutoOperation = false;
-    SAFE_DESTROY(FSynchronizeProgressForm);
+    SynchronizeProgressFormReleaser.Reset();
     BatchEnd(BatchStorage);
     ReloadLocalDirectory();
     if (AnyOperation)
@@ -7384,7 +7380,7 @@ void __fastcall TCustomScpExplorerForm::TerminalRemoved(TObject * Sender)
 }
 //---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::FileTerminalReplaced(
-  const UnicodeString FileName, TEditedFileData * Data, TObject * /*Token*/, void * Arg)
+  const UnicodeString DebugUsedArg(FileName), TEditedFileData * Data, TObject * /*Token*/, void * Arg)
 {
   TManagedTerminal * ATerminal = static_cast<TManagedTerminal *>(Arg);
 
@@ -7566,7 +7562,7 @@ void TCustomScpExplorerForm::UpdateSessionTab(TThemeTabSheet * TabSheet)
     TManagedTerminal * ASession = GetSessionTabSession(TabSheet);
     if (DebugAlwaysTrue(ASession != NULL))
     {
-      TColor Color = (ASession == Terminal) ? FSessionColor : ASession->StateData->Color;
+      TColor Color = (ASession == Terminal) ? FSessionColor : static_cast<TColor>(ASession->StateData->Color);
       if (ASession->LocalBrowser)
       {
         TabSheet->ImageIndex = FLocalBrowserTabImageIndex;
@@ -8700,7 +8696,7 @@ TQueueOperation __fastcall TCustomScpExplorerForm::DefaultQueueOperation()
 }
 //---------------------------------------------------------------------------
 bool __fastcall TCustomScpExplorerForm::AllowQueueOperation(
-  TQueueOperation Operation, void ** Param)
+  TQueueOperation Operation, unsigned long * Param)
 {
   switch (Operation)
   {
@@ -8727,7 +8723,7 @@ void __fastcall TCustomScpExplorerForm::GoToQueue()
 }
 //---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::ExecuteQueueOperation(
-  TQueueOperation Operation, void * Param)
+  TQueueOperation Operation, unsigned long Param)
 {
   if (Operation == qoGoTo)
   {
@@ -9574,11 +9570,11 @@ void __fastcall TCustomScpExplorerForm::StartUpdates()
     {
       Period = Updates.Period;
     }
-    AppLogFmt(L"Updates check period: %.2f", (double(Period)));
+    AppLogFmt(L"Updates check period: %.2f", (DateTimeToVariant(Period)));
     if (double(Period) > 0)
     {
       TDateTime Interval = Now() - Updates.LastCheck;
-      AppLogFmt(L"Interval since the last updates check: %.2f", (double(Interval)));
+      AppLogFmt(L"Interval since the last updates check: %.2f", (DateTimeToVariant(Interval)));
       if (Interval >= Period)
       {
         StartUpdateThread(UpdatesChecked);
@@ -11588,6 +11584,12 @@ void __fastcall TCustomScpExplorerForm::ClipboardDownload(const UnicodeString &
   ExecuteFileOperation(foCopy, osRemote, FClipboardFileList.get(), NoConfirmation, &Params);
 }
 //---------------------------------------------------------------------------
+void TCustomScpExplorerForm::PasteFilesCleanupRetry(const UnicodeString & Target)
+{
+  bool Removed = RemoveDir(ApiPath(Target));
+  AppLogFmt(L"Second attempt to delete pasted fake clipboard directory \"%s\" - %d", (Target, int(Removed)));
+}
+//---------------------------------------------------------------------------
 void TCustomScpExplorerForm::PasteFiles()
 {
   // Guard against possible race conditions
@@ -11621,8 +11623,7 @@ void TCustomScpExplorerForm::PasteFiles()
     {
       if (!Removed)
       {
-        Removed = RemoveDir(ApiPath(Target));
-        AppLogFmt(L"Second attempt to delete pasted fake clipboard directory \"%s\" - %d", (Target, int(Removed)));
+        PasteFilesCleanupRetry(Target);
       }
     }
   }

+ 6 - 5
source/forms/CustomScpExplorer.h

@@ -44,14 +44,14 @@ class TQueueItemProxy;
 class TQueueController;
 class TSynchronizeController;
 class TEditorManager;
-class TEditorData;
+struct TEditorData;
 class TTransferPresetNoteData;
 struct TEditedFileData;
-class ITaskbarList3;
+struct ITaskbarList3;
 struct TSynchronizeParams;
 class TBookmark;
 class TManagedTerminal;
-class TCalculateSizeOperation;
+struct TCalculateSizeOperation;
 class TThumbnailDownloadQueueItem;
 //---------------------------------------------------------------------------
 enum TActionAllowed { aaShortCut, aaUpdate, aaExecute };
@@ -772,6 +772,7 @@ protected:
   bool CanCalculateChecksum();
   void RegenerateSessionColorsImageList();
   void WMQueueCallback(TMessage & Message);
+  void PasteFilesCleanupRetry(const UnicodeString & Target);
 
 public:
   virtual __fastcall ~TCustomScpExplorerForm();
@@ -847,8 +848,8 @@ public:
     bool OnFocused = false);
   void __fastcall ExecuteCurrentFileWith(bool OnFocused);
   void __fastcall EditNew(TOperationSide Side);
-  bool __fastcall AllowQueueOperation(TQueueOperation Operation, void ** Param = NULL);
-  void __fastcall ExecuteQueueOperation(TQueueOperation Operation, void * Param = NULL);
+  bool __fastcall AllowQueueOperation(TQueueOperation Operation, unsigned long * Param = NULL);
+  void __fastcall ExecuteQueueOperation(TQueueOperation Operation, unsigned long Param = 0);
   TQueueOperation __fastcall DefaultQueueOperation();
   bool __fastcall GetQueueEnabled();
   void __fastcall ToggleQueueEnabled();

+ 1 - 1
source/forms/EditMask.h

@@ -54,7 +54,7 @@ protected:
   void __fastcall LoadFileMasks(TMemo * Memo, TStrings * MasksStr);
   void __fastcall UpdateControls();
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 
 private:
   UnicodeString FExcludeDirectoryMasks;

+ 4 - 6
source/forms/Editor.cpp

@@ -179,7 +179,6 @@ protected:
   DYNAMIC void __fastcall KeyDown(Word & Key, TShiftState Shift);
 
 private:
-  HINSTANCE FLibrary;
   bool FWordWrap;
   unsigned int FTabSize;
   bool FInitialized;
@@ -192,9 +191,8 @@ private:
 //---------------------------------------------------------------------------
 __fastcall TEditorRichEdit::TEditorRichEdit(TComponent * AOwner) :
   TRichEdit(AOwner),
-  FLibrary(0),
-  FTabSize(0),
   FWordWrap(true),
+  FTabSize(0),
   FInitialized(false),
   FLoadedWithPreamble(false)
 {
@@ -391,7 +389,7 @@ struct TStreamLoadInfo
 // VCLCOPY Vcl.ComCtrls.pas,
 // WORKAROUND for bug in BCB XE2-XE6 VCL
 // Fixes conversion from UTF-8, when read buffer ends in the middle of UTF-8 char
-static unsigned long __stdcall StreamLoad(DWORD_PTR Cookie, unsigned char * Buff, long Read, long * WasRead)
+unsigned long __stdcall StreamLoad(DWORD_PTR Cookie, unsigned char * Buff, long Read, long * WasRead)
 {
   TStreamLoadInfo * LoadInfo = reinterpret_cast<TStreamLoadInfo *>(Cookie);
   unsigned long Result =
@@ -604,13 +602,13 @@ bool __stdcall TEditorRichEdit::StreamLoad(
 
     Result = true;
   }
-  catch (EEncodingError & E)
+  catch (EEncodingError &)
   {
     FStreamLoadError = true;
     FStreamLoadEncodingError = true;
     Result = false;
   }
-  catch (Exception & E)
+  catch (Exception &)
   {
     FStreamLoadError = true;
     Result = false;

+ 1 - 1
source/forms/EditorPreferences.h

@@ -54,7 +54,7 @@ private:
   UnicodeString FSystemExternalEditor;
   TEditorData FExternalEditorDefaults;
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 };
 //---------------------------------------------------------------------------
 #endif

+ 2 - 2
source/forms/FileFind.cpp

@@ -20,7 +20,7 @@
 #pragma link "PngImageList"
 #pragma resource "*.dfm"
 //---------------------------------------------------------------------------
-TFileFindDialog * FileFindDialog = NULL;
+static TFileFindDialog * FileFindDialog = NULL;
 static const int NoSort = 1;
 //---------------------------------------------------------------------------
 void __fastcall ShowFileFindDialog(
@@ -281,7 +281,7 @@ void __fastcall TFileFindDialog::Start()
 }
 //---------------------------------------------------------------------------
 void __fastcall TFileFindDialog::FileFound(TTerminal * /*Terminal*/,
-  const UnicodeString FileName, const TRemoteFile * AFile, bool & Cancel)
+  const UnicodeString DebugUsedArg(FileName), const TRemoteFile * AFile, bool & Cancel)
 {
   TListItem * Item;
   int Count = FileView2->Items->Count;

+ 1 - 1
source/forms/FileFind.h

@@ -140,7 +140,7 @@ private:
   TIEListViewColProperties * GetColProperties();
   int FilesCompare(const TRemoteFile * File1, const TRemoteFile * File2);
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 };
 //---------------------------------------------------------------------------
 #endif

+ 1 - 1
source/forms/FileSystemInfo.h

@@ -101,7 +101,7 @@ private:
   bool __fastcall SpaceAvailableSupported();
   void __fastcall FeedControls();
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 };
 //----------------------------------------------------------------------------
 #endif

+ 1 - 1
source/forms/FullSynchronize.h

@@ -119,7 +119,7 @@ public:
 protected:
   void __fastcall UpdateControls();
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 };
 //---------------------------------------------------------------------------
 #endif

+ 1 - 1
source/forms/GenerateUrl.h

@@ -76,7 +76,7 @@ protected:
   UnicodeString __fastcall GenerateAssemblyCode(UnicodeString & AssemblyDescription);
   void __fastcall AddSampleDescription(UnicodeString & Description);
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 
 public:
   __fastcall TGenerateUrlDialog(

+ 1 - 1
source/forms/ImportSessions.h

@@ -55,7 +55,7 @@ private:
   virtual void __fastcall DestroyHandle();
   virtual void __fastcall Dispatch(void * Message);
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 
 public:
   virtual __fastcall TImportSessionsDialog(TComponent * AOwner);

+ 1 - 1
source/forms/License.cpp

@@ -13,7 +13,7 @@
 #pragma package(smart_init)
 #pragma resource "*.dfm"
 //---------------------------------------------------------------------------
-UnicodeString LicenseStr[2] =
+static UnicodeString LicenseStr[2] =
   { L"LICENSE", L"LICENSE_EXPAT" };
 //---------------------------------------------------------------------------
 void __fastcall DoLicenseDialog(TLicense License)

+ 1 - 1
source/forms/LocationProfiles.cpp

@@ -440,7 +440,7 @@ TTabSheet * TLocationProfilesDialog::GetProfilesSheet()
 }
 //---------------------------------------------------------------------------
 template<class T>
-typename T * GetProfilesObject(TObject * Sender, T * SessionObject, T * SharedObject)
+T * GetProfilesObject(TObject * Sender, T * SessionObject, T * SharedObject)
 {
   TControl * Control = dynamic_cast<TControl *>(Sender);
   DebugAssert(Control != NULL);

+ 1 - 1
source/forms/LocationProfiles.h

@@ -164,7 +164,7 @@ private:
   bool __fastcall ProfileMatch(TTreeNode * Node);
   UnicodeString __fastcall BookmarkText(TBookmark * Bookmark);
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 };
 //----------------------------------------------------------------------------
 #endif

+ 1 - 1
source/forms/Login.cpp

@@ -2658,7 +2658,7 @@ void __fastcall TLoginDialog::PortNumberEditChange(TObject * Sender)
   if (!NoUpdate)
   {
     bool WellKnownPort = false;
-    TFSProtocol FSProtocol;
+    TFSProtocol FSProtocol = TFSProtocol(); // shut up
     TFtps Ftps = ftpsNone;
 
     // For ambiguous port numbers, keep the current protocol, even if it is not the default protocol for the port

+ 1 - 1
source/forms/Login.h

@@ -447,7 +447,7 @@ protected:
   virtual void __fastcall CreateWnd();
   __property TSessionData * SelectedSession  = { read=GetSelectedSession };
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 
 public:
   virtual __fastcall TLoginDialog(TComponent* AOwner);

+ 6 - 5
source/forms/MessageDlg.cpp

@@ -460,9 +460,9 @@ void __fastcall TMessageForm::ButtonDropDownClick(TObject * /*Sender*/)
   }
 }
 //---------------------------------------------------------------------------
-const ResourceString * Captions[] = { &_SMsgDlgWarning, &_SMsgDlgError, &_SMsgDlgInformation,
+static const ResourceString * Captions[] = { &_SMsgDlgWarning, &_SMsgDlgError, &_SMsgDlgInformation,
   &_SMsgDlgConfirm, NULL };
-const wchar_t * ImageNames[] = { L"Warning", L"Error", L"Information",
+static const wchar_t * ImageNames[] = { L"Warning", L"Error", L"Information",
   L"Help Blue", NULL };
 const int mcHorzMargin = 8;
 const int mcVertMargin = 13;
@@ -998,10 +998,11 @@ TForm * __fastcall TMessageForm::Create(const UnicodeString & Msg,
   int IconHeight = 0;
 
   UnicodeString ImageName = AImageName;
+  int DlgTypeIndex = static_cast<int>(DlgType);
   if (ImageName.IsEmpty() &&
-      DebugAlwaysTrue(ImageNames[DlgType] != NULL))
+      DebugAlwaysTrue(ImageNames[DlgTypeIndex] != NULL))
   {
-    ImageName = ImageNames[DlgType];
+    ImageName = ImageNames[DlgTypeIndex];
   }
 
   if (DebugAlwaysTrue(!ImageName.IsEmpty()))
@@ -1207,7 +1208,7 @@ TForm * __fastcall TMessageForm::Create(const UnicodeString & Msg,
   }
   else if (DebugAlwaysTrue(DlgType != mtCustom))
   {
-    Result->Caption = LoadResourceString(Captions[DlgType]);
+    Result->Caption = LoadResourceString(Captions[DlgTypeIndex]);
   }
   else
   {

+ 6 - 5
source/forms/NonVisual.cpp

@@ -28,7 +28,6 @@
 #pragma resource "*.dfm"
 TNonVisualDataModule *NonVisualDataModule;
 //---------------------------------------------------------------------------
-#define SCPCOMMANDER ((TScpCommanderForm *)ScpExplorer)
 #define UPDEX(HandleAction, Condition, OtherEnabled, OtherDisabled) if (Action == HandleAction) { \
   ((TCustomAction *)Action)->Enabled = (Condition); \
   if (((TCustomAction *)Action)->Enabled) { OtherEnabled; } else { OtherDisabled; }; \
@@ -128,7 +127,7 @@ void __fastcall TNonVisualDataModule::ExplorerActionsUpdate(
     Handled = true;
     return;
   }
-  void * AuxVoidPtr;
+  unsigned long AuxULong;
   int AuxInt;
   #define HasManagedSession (ScpExplorer->ManagedSession != NULL)
   #define HasTerminal ScpExplorer->HasAvailableTerminal()
@@ -497,8 +496,8 @@ void __fastcall TNonVisualDataModule::ExplorerActionsUpdate(
   UPDQUEUE(DeleteAll)
   UPDQUEUE(DeleteAllDone)
   #undef UPDQUEUE
-  UPDEX(QueueItemSpeedAction, ScpExplorer->AllowQueueOperation(qoItemSpeed, &AuxVoidPtr),
-    QueueItemSpeedAction->Text = SetSpeedLimit(reinterpret_cast<unsigned long>(AuxVoidPtr)),
+  UPDEX(QueueItemSpeedAction, ScpExplorer->AllowQueueOperation(qoItemSpeed, &AuxULong),
+    QueueItemSpeedAction->Text = SetSpeedLimit(AuxULong),
     QueueItemSpeedAction->Text = L"")
   UPDEX1(QueueToggleShowAction, !ScpExplorer->IsLocalBrowserMode(), Action->Checked = ScpExplorer->ComponentVisible[fcQueueView])
   #define QUEUEACTION(SHOW) \
@@ -1793,7 +1792,7 @@ UnicodeString __fastcall TNonVisualDataModule::QueueItemSpeed(const UnicodeStrin
 {
   // Keep in sync with TProgressForm::ItemSpeed
   unsigned long Speed = GetSpeedLimit(Text);
-  ScpExplorer->ExecuteQueueOperation(qoItemSpeed, reinterpret_cast<void*>(Speed));
+  ScpExplorer->ExecuteQueueOperation(qoItemSpeed, Speed);
 
   UnicodeString Result = SetSpeedLimit(Speed);
   SaveToHistory(Item->Strings, Result);
@@ -1887,6 +1886,7 @@ TAction * __fastcall TNonVisualDataModule::CurrentQueueOnceEmptyAction()
   else
   {
     DebugFail();
+    Result = NULL; // shut up
   }
   return Result;
 }
@@ -1914,6 +1914,7 @@ TOnceDoneOperation __fastcall TNonVisualDataModule::CurrentQueueOnceEmptyOperati
   else
   {
     DebugFail();
+    Result = odoIdle; // shut up
   }
   return Result;
 }

+ 2 - 2
source/forms/OpenDirectory.cpp

@@ -277,8 +277,8 @@ bool __fastcall TOpenDirectoryDialog::Execute()
   return Result;
 }
 //---------------------------------------------------------------------------
-template<class T>
-typename T * GetBookmarkObject(TObject * Sender, T * SessionObject, T * SharedObject)
+template<typename T>
+T * GetBookmarkObject(TObject * Sender, T * SessionObject, T * SharedObject)
 {
   TControl * Control = dynamic_cast<TControl *>(Sender);
   DebugAssert(Control != NULL);

+ 1 - 1
source/forms/OpenDirectory.h

@@ -124,7 +124,7 @@ private:
   UnicodeString __fastcall BookmarkText(TBookmark * Bookmark);
   inline TBookmark * __fastcall GetBookmark(TListBox * BookmarksList, int Index);
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 };
 //----------------------------------------------------------------------------
 #endif

+ 7 - 6
source/forms/Preferences.cpp

@@ -859,10 +859,11 @@ void __fastcall TPreferencesDialog::SaveConfiguration()
     GUIConfiguration->QueueAutoPopup = QueueAutoPopupCheck->Checked;
     CopyParam.Queue = QueueCheck->Checked;
     CopyParam.QueueParallel = QueueParallelCheck->Checked;
-    __int64 ParallelTransferThreshold;
+    __int64 ParallelTransferThreshold = 0; // shut up
     if (ParallelTransferCheck->Checked && TryStrToSize(ParallelTransferThresholdCombo->Text, ParallelTransferThreshold))
     {
-      Configuration->ParallelTransferThreshold = std::min(ParallelTransferThreshold / 1024, static_cast<__int64>(std::numeric_limits<int>::max()));
+      Configuration->ParallelTransferThreshold =
+        static_cast<int>(std::min(ParallelTransferThreshold / 1024, static_cast<__int64>(std::numeric_limits<int>::max())));
     }
     else
     {
@@ -1038,7 +1039,7 @@ void __fastcall TPreferencesDialog::SaveConfiguration()
     Configuration->LogProtocol = LogProtocolCombo2->ItemIndex - BelowNormalLogLevels;
     Configuration->LogFileName = LogFileNameEdit3->Text;
     Configuration->LogFileAppend = LogFileAppendButton->Checked;
-    __int64 LogMaxSize;
+    __int64 LogMaxSize = 0; // shut up
     // TryStrToSize can fail, only if LogMaxSizeComboExit is bypassed due to IsCancelButtonBeingClicked
     if (LogMaxSizeCheck->Checked && TryStrToSize(LogMaxSizeCombo->Text, LogMaxSize))
     {
@@ -1080,7 +1081,7 @@ void __fastcall TPreferencesDialog::SaveConfiguration()
   }
 
   bool MoveStorage = true;
-  TStorage Storage;
+  TStorage Storage = TStorage(); // shut up
   if (RegistryStorageButton->Checked)
   {
     Storage = stRegistry;
@@ -1607,7 +1608,7 @@ void __fastcall TPreferencesDialog::FormCloseQuery(TObject * /*Sender*/,
 void __fastcall TPreferencesDialog::IconButtonClick(TObject *Sender)
 {
   UnicodeString IconName, Params;
-  int SpecialFolder;
+  int SpecialFolder = 0; // shut up
 
   if (Sender == DesktopIconButton)
   {
@@ -3335,7 +3336,7 @@ void __fastcall TPreferencesDialog::AddEditFileColor(bool Edit)
       }
       else
       {
-        FFileColors.insert(&FFileColors[Index], FileColorData);
+        FFileColors.insert(FFileColors.begin() + Index, FileColorData);
       }
     }
 

+ 1 - 1
source/forms/Preferences.h

@@ -584,7 +584,7 @@ protected:
   void UpdateSshHostCAsViewView();
   void SshHostCAsRefresh();
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 };
 //----------------------------------------------------------------------------
 #endif

+ 2 - 2
source/forms/Progress.cpp

@@ -28,7 +28,7 @@
 #pragma link "TBXExtItems"
 #pragma resource "*.dfm"
 //---------------------------------------------------------------------
-static IsIndeterminate(const TSynchronizeProgress * SynchronizeProgress, const TFileOperationProgressType * ProgressData)
+static bool IsIndeterminate(const TSynchronizeProgress * SynchronizeProgress, const TFileOperationProgressType * ProgressData)
 {
   bool Result;
   // TSynchronizeProgress has its own way how to take atomic operations into account
@@ -84,7 +84,7 @@ UnicodeString __fastcall TProgressForm::ProgressStr(
 //---------------------------------------------------------------------
 __fastcall TProgressForm::TProgressForm(
   TComponent * AOwner, bool AllowMoveToQueue, bool AllowSkip, TSynchronizeProgress * SynchronizeProgress)
-    : FData(), TForm(AOwner)
+    : TForm(AOwner), FData()
 {
   FLastOperation = foNone;
   FLastSide = (TOperationSide)-1;

+ 1 - 3
source/forms/Progress.h

@@ -97,8 +97,6 @@ private:
   bool FLastTotalSizeSet;
   bool FMinimizedByMe;
   int FUpdateCounter;
-  bool FAsciiTransferChanged;
-  bool FResumeStatusChanged;
   void * FShowAsModalStorage;
   bool FDeleteLocalToRecycleBin;
   bool FDeleteRemoteToRecycleBin;
@@ -138,7 +136,7 @@ protected:
   DYNAMIC void __fastcall MouseWheelHandler(TMessage & Message);
   virtual void __fastcall CreateWnd();
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 
 public:
   static UnicodeString __fastcall ProgressStr(

+ 1 - 1
source/forms/Properties.h

@@ -137,7 +137,7 @@ protected:
   void AutoSizeTagsView();
   void AddEditTag(bool Add);
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 
 public:
   virtual __fastcall TPropertiesDialog(TComponent * AOwner,

+ 1 - 1
source/forms/RemoteTransfer.h

@@ -57,7 +57,7 @@ private:
   bool FTargetConfirmed;
   UnicodeString FOriginalTarget;
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 };
 //---------------------------------------------------------------------------
 #endif

+ 1 - 1
source/forms/Rights.h

@@ -145,7 +145,7 @@ protected:
   void UpdateButton(TSpeedButton * Button, UnicodeString & Caption);
   bool IsButtonAccel(TCMDialogChar & Message, TSpeedButton * Button, TWinControl * FocusControl);
 
-  INTERFACE_HOOK_CUSTOM(TFrame);
+  INTERFACE_HOOK_CUSTOM(TFrame)
 
   __property TRights::TState States[TRights::TRight Right] = { read = GetStates, write = SetStates };
 };

+ 8 - 7
source/forms/ScpCommander.cpp

@@ -607,7 +607,7 @@ void __fastcall TScpCommanderForm::BatchEnd(void * Storage)
   OtherLocalDirView->WatchForChanges = LocalDirView->WatchForChanges;
   OtherLocalDriveView->WatchDirectory = LocalDirView->WatchForChanges;
 
-  delete Storage;
+  delete static_cast<bool *>(Storage);
 }
 //---------------------------------------------------------------------------
 void __fastcall TScpCommanderForm::StartingWithoutSession()
@@ -1075,7 +1075,7 @@ void __fastcall TScpCommanderForm::UpdateControls()
     P = SplitterLongHint.Pos(L"\n");
   }
   SplitterLongHint.Delete(1, P);
-  Splitter->Hint = FORMAT(L"%0.0f%%\n%s", (LeftPanelWidth*100, SplitterLongHint));
+  Splitter->Hint = FORMAT(L"%0.0f%%\n%s", (static_cast<long double>(LeftPanelWidth*100), SplitterLongHint));
   UnicodeString ACommandLinePromptLabel = LoadStr(COMMAND_LINE_LABEL) + " " +
     (!IsSideLocalBrowser(FCurrentSide) ? L"$" : L">");
   if (CommandLinePromptLabel->Caption != ACommandLinePromptLabel)
@@ -1590,7 +1590,7 @@ void __fastcall TScpCommanderForm::SynchronizeBrowsing(TCustomDirView * ADirView
       }
 
     }
-    catch(Exception & E)
+    catch(Exception &)
     {
       NonVisualDataModule->SynchronizeBrowsingAction2->Checked = false;
       // what does this say?
@@ -1817,8 +1817,8 @@ void __fastcall TScpCommanderForm::DDFakeFileInitDrag(TFileList * FileList,
 }
 //---------------------------------------------------------------------------
 void __fastcall TScpCommanderForm::LocalFileControlDDFileOperation(
-  TObject * Sender, int dwEffect, UnicodeString SourcePath,
-  UnicodeString TargetPath, bool Paste, bool & DoOperation)
+  TObject * Sender, int dwEffect, UnicodeString DebugUsedArg(SourcePath),
+  UnicodeString DebugUsedArg(TargetPath), bool Paste, bool & DoOperation)
 {
   if (IsFileControl(DropSourceControl, osRemote) && !IsLocalBrowserMode())
   {
@@ -2323,7 +2323,7 @@ void __fastcall TScpCommanderForm::LocalPathComboBoxCancel(TObject * /*Sender*/)
 }
 //---------------------------------------------------------------------------
 void TScpCommanderForm::DoLocalPathComboBoxAdjustImageIndex(
-  TTBXComboBoxItem * Sender, const UnicodeString AText, int AIndex, int & ImageIndex, TStrings * LocalPathComboBoxPaths)
+  TTBXComboBoxItem * Sender, const UnicodeString DebugUsedArg(AText), int AIndex, int & ImageIndex, TStrings * LocalPathComboBoxPaths)
 {
   // this may get called even before constructor starts
   // (e.g. from FixControlsPlacement)
@@ -2467,7 +2467,7 @@ void __fastcall TScpCommanderForm::CommandLineComboEditWndProc(TMessage & Messag
   }
 }
 //---------------------------------------------------------------------------
-void __fastcall TScpCommanderForm::DriveNotification(TDriveNotification Notification, UnicodeString Drive)
+void __fastcall TScpCommanderForm::DriveNotification(TDriveNotification Notification, UnicodeString DebugUsedArg(Drive))
 {
   if (Notification == dnRefresh)
   {
@@ -2790,6 +2790,7 @@ void TScpCommanderForm::LocalLocalCopy(
     default:
       DebugFail();
       Abort();
+      Move = false; // shut up
   }
 
   TOperationSide OtherSide = GetOtherSide(GetSide(Side));

+ 0 - 2
source/forms/ScpCommander.h

@@ -557,7 +557,6 @@ private:
   double FLastLeftPanelWidth;
   double FLeftPanelWidth;
   int FNormalPanelsWidth;
-  int FLastWidth;
   bool FSynchronisingBrowse;
   TStrings * FInternalDDDownloadList;
   UnicodeString FPrevPath[2];
@@ -567,7 +566,6 @@ private:
   TStrings * FLocalPathComboBoxPaths;
   TStrings * FOtherLocalPathComboBoxPaths;
   int FLocalSpecialPaths;
-  unsigned int FSpecialFolders;
   TEdit * FCommandLineComboEdit;
   TWndMethod FToolbarEditOldWndProc;
   bool FPanelsRestored;

+ 1 - 1
source/forms/SelectMask.h

@@ -46,7 +46,7 @@ private:
   void __fastcall ColorChange(TColor Color);
   void __fastcall UpdateControls();
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 
 public:
   enum TMode { smSelect, smDeselect, smFilter, smFileColor };

+ 3 - 3
source/forms/SiteAdvanced.cpp

@@ -468,14 +468,14 @@ void __fastcall TSiteAdvancedDialog::SaveSession(TSessionData * SessionData)
 
   for (int Index = 0; Index < CIPHER_COUNT; Index++)
   {
-    SessionData->Cipher[Index] = (TCipher)CipherListBox->Items->Objects[Index];
+    SessionData->Cipher[Index] = static_cast<TCipher>(reinterpret_cast<uintptr_t>(CipherListBox->Items->Objects[Index]));
   }
 
   // Kex page
 
   for (int Index = 0; Index < KEX_COUNT; Index++)
   {
-    SessionData->Kex[Index] = (TKex)KexListBox->Items->Objects[Index];
+    SessionData->Kex[Index] = static_cast<TKex>(reinterpret_cast<uintptr_t>(KexListBox->Items->Objects[Index]));
   }
 
   FSessionData->AuthGSSAPIKEX = AuthGSSAPIKEXCheck->Checked;
@@ -1406,7 +1406,7 @@ void __fastcall TSiteAdvancedDialog::PrivateKeyEdit3AfterDialog(TObject * Sender
           }
         }
       }
-      catch (Exception & E)
+      catch (Exception &)
       {
         // swallow
       }

+ 1 - 3
source/forms/SiteAdvanced.h

@@ -347,9 +347,7 @@ private:
   int NoUpdate;
   int FAlgDragSource;
   int FAlgDragDest;
-  int FOptions;
   UnicodeString FBeforeDialogPath;
-  TFSProtocol FFSProtocol;
   TSessionData * FSessionData;
   TColor FColor;
   UnicodeString FLastPrivateKey;
@@ -385,7 +383,7 @@ private:
   void SerializePuttyRegistry(const UnicodeString & Key, TStrings * Values);
   bool HasCertificate(const UnicodeString & FileName);
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 };
 //----------------------------------------------------------------------------
 #endif

+ 1 - 1
source/forms/Symlink.h

@@ -50,7 +50,7 @@ public:
 protected:
   void __fastcall UpdateControls();
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 };
 //---------------------------------------------------------------------------
 #endif

+ 2 - 2
source/forms/Synchronize.cpp

@@ -67,7 +67,7 @@ bool __fastcall DoSynchronizeDialog(TSynchronizeParamType & Params,
   return Result;
 }
 //---------------------------------------------------------------------------
-const TSynchronizeDialog::MaxLogItems = 1000;
+const int TSynchronizeDialog::MaxLogItems = 1000;
 //---------------------------------------------------------------------------
 struct TLogItemData
 {
@@ -452,7 +452,7 @@ void __fastcall TSynchronizeDialog::StartButtonClick(TObject * /*Sender*/)
 //---------------------------------------------------------------------------
 void __fastcall TSynchronizeDialog::Start()
 {
-  bool Synchronize;
+  bool Synchronize = false; // shut up
   bool Continue = true;
   if (SynchronizeSynchronizeCheck->State == cbGrayed)
   {

+ 2 - 2
source/forms/Synchronize.h

@@ -97,7 +97,7 @@ private:
   TSynchronizeOptions * FSynchronizeOptions;
   TFeedSynchronizeError * FOnFeedSynchronizeError;
   TSynchronizeInNewWindow FOnSynchronizeInNewWindow;
-  static const MaxLogItems;
+  static const int MaxLogItems;
 
   void __fastcall SetParams(const TSynchronizeParamType& value);
   TSynchronizeParamType __fastcall GetParams();
@@ -137,7 +137,7 @@ protected:
   bool __fastcall CanStartInNewWindow();
   void Abort(bool Close);
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 
 public:
   __fastcall TSynchronizeDialog(TComponent * Owner);

+ 2 - 2
source/forms/SynchronizeChecklist.cpp

@@ -1451,7 +1451,7 @@ void __fastcall TSynchronizeChecklistDialog::MoveActionExecute(TObject *)
   DebugAssert(IsTransferNewAction(TransferAction->Action));
   DebugAssert(GetOppositeMoveAction(DeleteAction->Action) == TransferAction->Action);
 
-  TOperationSide Side;
+  TOperationSide Side = TOperationSide(); // shut up
   UnicodeString NewFileName;
   DebugAssert(TransferAction->ChecklistItems.size() == 1);
   const TSynchronizeChecklist::TItem * TransferChecklistItem = TransferAction->ChecklistItems[0];
@@ -1469,7 +1469,7 @@ void __fastcall TSynchronizeChecklistDialog::MoveActionExecute(TObject *)
   if (DebugAlwaysTrue(!NewFileName.IsEmpty()))
   {
     bool Move = false;
-    bool TargetIsDirectory;
+    bool TargetIsDirectory = false; // shut up
     if ((TransferAction->AllItemsDirectories == DeleteAction->AllItemsDirectories) &&
         DebugAlwaysTrue(TransferAction->ItemsCount == 1) &&
         DebugAlwaysTrue(DeleteAction->ItemsCount == 1))

+ 1 - 1
source/forms/SynchronizeChecklist.h

@@ -223,7 +223,7 @@ protected:
   void DoSynchronize(bool Queue);
   void PathToClipboard(bool Local);
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 };
 //----------------------------------------------------------------------------
 #endif

+ 1 - 1
source/forms/SynchronizeProgress.h

@@ -75,7 +75,7 @@ private:
   void __fastcall CancelOperation();
   void __fastcall CMDialogKey(TCMDialogKey & Message);
 
-  INTERFACE_HOOK;
+  INTERFACE_HOOK
 };
 //---------------------------------------------------------------------------
 #endif

+ 8 - 3
source/packages/filemng/CustomDirView.pas

@@ -105,6 +105,11 @@ type
     function Execute(DataObject: TDataObject): TDragResult;
   end;
 
+  // TLVCompare uses LPARAM type, which in Pascal is defined as INT_PTR, while in C++ it's defined as incompatible LONG_PTR.
+  // So this is the same declaration (hence interchangable) as TLVCompare in Pascal, but explicitly with INT_PTR,
+  // so its generated C++ equivalent in hpp is compatible.
+  TListViewCompare = function(lParam1, lParam2, lParamSort: INT_PTR): Integer stdcall;
+
   TCustomDirView = class(TCustomIEListView)
   private
     FAddParentDir: Boolean;
@@ -272,7 +277,7 @@ type
       Stage: TCustomDrawStage): Boolean; override;
     function CustomDrawSubItem(Item: TListItem; SubItem: Integer;
       State: TCustomDrawState; Stage: TCustomDrawStage): Boolean; override;
-    procedure CustomSortItems(SortProc: Pointer);
+    procedure CustomSortItems(SortProc: TListViewCompare);
     procedure Delete(Item: TListItem); override;
     procedure DoHistoryChange; dynamic;
     function DragCompleteFileList: Boolean; virtual;
@@ -2145,7 +2150,7 @@ begin
     ItemFocused.MakeVisible(False);
 end;
 
-procedure TCustomDirView.CustomSortItems(SortProc: Pointer);
+procedure TCustomDirView.CustomSortItems(SortProc: TListViewCompare);
 var
   SavedCursor: TCursor;
   SavedNotifyEnabled: Boolean;
@@ -2158,7 +2163,7 @@ begin
     try
       Screen.Cursor := crHourglass;
       FNotifyEnabled := False;
-      CustomSort(TLVCompare(SortProc), Integer(Pointer(Self)));
+      CustomSort(SortProc, Integer(Pointer(Self)));
     finally
       Screen.Cursor := SavedCursor;
       FNotifyEnabled := SavedNotifyEnabled;

+ 6 - 7
source/windows/ConsoleRunner.cpp

@@ -383,7 +383,7 @@ bool __fastcall TOwnConsole::Input(UnicodeString & Str, bool Echo, unsigned int
 //---------------------------------------------------------------------------
 int __fastcall TOwnConsole::Choice(
   UnicodeString Options, int Cancel, int Break, int /*Continue*/, int Timeouted, bool /*Timeouting*/, unsigned int Timer,
-  UnicodeString Message)
+  UnicodeString DebugUsedArg(Message))
 {
   unsigned int ATimer = Timer;
   int Result = 0;
@@ -548,7 +548,6 @@ public:
   virtual UnicodeString __fastcall FinalLogMessage();
 
 private:
-  bool FPendingAbort;
   HANDLE FRequestEvent;
   HANDLE FResponseEvent;
   HANDLE FCancelEvent;
@@ -1374,7 +1373,7 @@ void __fastcall TConsoleRunner::ScriptPrintProgress(TScript * /*Script*/,
 }
 //---------------------------------------------------------------------------
 void __fastcall TConsoleRunner::ScriptTerminalPromptUser(TTerminal * /*Terminal*/,
-  TPromptKind /*Kind*/, UnicodeString Name, UnicodeString Instructions, TStrings * Prompts,
+  TPromptKind /*Kind*/, UnicodeString DebugUsedArg(Name), UnicodeString Instructions, TStrings * Prompts,
   TStrings * Results, bool & Result, void * /*Arg*/)
 {
   if (!Instructions.IsEmpty())
@@ -1552,12 +1551,12 @@ void __fastcall TConsoleRunner::ScriptTerminalQueryUser(TObject * /*Sender*/,
   DebugAssert(Accels.Length() == static_cast<int>(Buttons.size()));
   int NumberAccel = 0;
   unsigned int CancelA = CancelAnswer(Answers);
-  int CancelIndex;
+  int CancelIndex = -1;
   // AbortAnswer call duplicated in qpWaitInBatch branch above
   unsigned int AbortA = AbortAnswer(Answers & ~NoBatchA);
-  int AbortIndex;
+  int AbortIndex = -1;
   unsigned int ContinueA = ContinueAnswer(Answers & ~NoBatchA);
-  int ContinueIndex;
+  int ContinueIndex = -1;
   int TimeoutIndex = 0;
 
   for (unsigned int Index = 0; Index < Buttons.size(); Index++)
@@ -1902,7 +1901,7 @@ void __fastcall TConsoleRunner::SynchronizeControllerSynchronize(
       FScript->Synchronize(LocalDirectory, RemoteDirectory, CopyParam,
         Params.Params, Checklist);
     }
-    catch (Exception & E)
+    catch (Exception &)
     {
       if ((FScript->Batch == TScript::BatchContinue) &&
           FScript->Terminal->Active)

+ 3 - 3
source/windows/CustomWinConfiguration.cpp

@@ -22,7 +22,7 @@ public:
   __fastcall THistoryStrings() : TStringList()
   {
     FModified = false;
-  };
+  }
 
   __property bool Modified = { read = FModified, write = FModified };
 
@@ -150,7 +150,7 @@ void __fastcall TCustomWinConfiguration::Saved()
 #define KEY(TYPE, VAR) KEYEX(TYPE, VAR, PropertyToKey(TEXT(#VAR)))
 #define REGCONFIG(CANCREATE) \
   BLOCK(L"Interface", CANCREATE, \
-    KEY(Integer,  Interface); \
+    KEY(Enum,     Interface); \
     KEY(Bool,     ConfirmExitOnCompletion); \
     KEY(Bool,     SynchronizeSummary); \
     KEY(String,   SessionColors); \
@@ -173,7 +173,7 @@ void __fastcall TCustomWinConfiguration::Saved()
   ); \
   BLOCK(L"Interface\\LoginDialog", CANCREATE, \
     KEY(String,   LoginDialog.WindowSize); \
-    KEY(Integer,  LoginDialog.SiteSearch); \
+    KEY(Enum,     LoginDialog.SiteSearch); \
   ); \
 //---------------------------------------------------------------------------
 void __fastcall TCustomWinConfiguration::SaveData(

+ 3 - 3
source/windows/CustomWinConfiguration.h

@@ -28,7 +28,7 @@ struct TSynchronizeChecklistConfiguration
   UnicodeString WindowParams;
   UnicodeString ListParams;
   bool __fastcall operator !=(TSynchronizeChecklistConfiguration & rhc)
-    { return C(WindowParams) C(ListParams) 0; };
+    { return C(WindowParams) C(ListParams) 0; }
 };
 typedef TSynchronizeChecklistConfiguration TFindFileConfiguration;
 //---------------------------------------------------------------------------
@@ -36,7 +36,7 @@ struct TConsoleWinConfiguration
 {
   UnicodeString WindowSize;
   bool __fastcall operator !=(TConsoleWinConfiguration & rhc)
-    { return C(WindowSize) 0; };
+    { return C(WindowSize) 0; }
 };
 //---------------------------------------------------------------------------
 enum TIncrementalSearch { isOff = -1, isNameStartOnly, isName, isAll };
@@ -45,7 +45,7 @@ struct TLoginDialogConfiguration : public TConsoleWinConfiguration
 {
   TIncrementalSearch SiteSearch;
   bool __fastcall operator !=(TLoginDialogConfiguration & rhc)
-    { return (TConsoleWinConfiguration::operator !=(rhc)) || C(SiteSearch) 0; };
+    { return (TConsoleWinConfiguration::operator !=(rhc)) || C(SiteSearch) 0; }
 };
 //---------------------------------------------------------------------------
 class TCustomWinConfiguration : public TGUIConfiguration

+ 1 - 1
source/windows/GUIConfiguration.cpp

@@ -648,7 +648,7 @@ void __fastcall TGUIConfiguration::UpdateStaticUsage()
     KEYEX(Bool,   SessionRememberPassword, L"QueueRememberPassword"); \
     KEY(String,   PuttySession); \
     KEY(String,   PuttyPath); \
-    KEY(Integer,  UsePuttyPwFile); \
+    KEY(Enum,     UsePuttyPwFile); \
     KEY(Bool,     PuttyPassword); \
     KEY(Bool,     TelnetForFtpInPutty); \
     KEY(DateTime, IgnoreCancelBeforeFinish); \

+ 20 - 21
source/windows/GUITools.cpp

@@ -13,7 +13,7 @@
 #include <CoreMain.h>
 #include <SessionData.h>
 #include <WinInterface.h>
-#include <TbxUtils.hpp>
+#include <TBXUtils.hpp>
 #include <Math.hpp>
 #include <Tools.h>
 #include "PngImageList.hpp"
@@ -422,7 +422,7 @@ UnicodeString FindPuttyPath()
   return Program;
 }
 //---------------------------------------------------------------------------
-unsigned int PipeCounter = 0;
+static unsigned int PipeCounter = 0;
 //---------------------------------------------------------------------------
 void OpenSessionInPutty(TSessionData * SessionData)
 {
@@ -745,8 +745,8 @@ static bool __fastcall DoExecuteShell(const UnicodeString Path, const UnicodeStr
       SEE_MASK_FLAG_NO_UI |
       FLAGMASK((Handle != NULL), SEE_MASK_NOCLOSEPROCESS);
     ExecuteInfo.hwnd = Application->Handle;
-    ExecuteInfo.lpFile = (wchar_t*)Path.data();
-    ExecuteInfo.lpParameters = (wchar_t*)Params.data();
+    ExecuteInfo.lpFile = static_cast<const wchar_t *>(Path.data());
+    ExecuteInfo.lpParameters = static_cast<const wchar_t *>(Params.data());
     ExecuteInfo.lpDirectory = (ChangeWorkingDirectory ? Directory.c_str() : NULL);
     ExecuteInfo.nShow = SW_SHOW;
 
@@ -1356,7 +1356,7 @@ protected:
   }
 
   virtual HRESULT STDMETHODCALLTYPE ShowContextMenu(
-    DWORD dwID, POINT * ppt, IUnknown * pcmdtReserved, IDispatch * pdispReserved)
+    DWORD DebugUsedArg(dwID), POINT *, IUnknown *, IDispatch *)
   {
     // No context menu
     // (implementing IDocHostUIHandler reenabled context menu disabled by TBrowserViewer::DoContextPopup)
@@ -1372,8 +1372,7 @@ protected:
   }
 
   virtual HRESULT STDMETHODCALLTYPE ShowUI(
-    DWORD dwID, IOleInPlaceActiveObject * pActiveObject, IOleCommandTarget * pCommandTarget, IOleInPlaceFrame * pFrame,
-    IOleInPlaceUIWindow * pDoc)
+    DWORD DebugUsedArg(dwID), IOleInPlaceActiveObject *, IOleCommandTarget *, IOleInPlaceFrame *, IOleInPlaceUIWindow *)
   {
     return E_NOTIMPL;
   }
@@ -1388,52 +1387,52 @@ protected:
     return E_NOTIMPL;
   }
 
-  virtual HRESULT STDMETHODCALLTYPE EnableModeless(BOOL fEnable)
+  virtual HRESULT STDMETHODCALLTYPE EnableModeless(BOOL DebugUsedArg(fEnable))
   {
     return E_NOTIMPL;
   }
 
-  virtual HRESULT STDMETHODCALLTYPE OnDocWindowActivate(BOOL fActivate)
+  virtual HRESULT STDMETHODCALLTYPE OnDocWindowActivate(BOOL DebugUsedArg(fActivate))
   {
     return E_NOTIMPL;
   }
 
-  virtual HRESULT STDMETHODCALLTYPE OnFrameWindowActivate(BOOL fActivate)
+  virtual HRESULT STDMETHODCALLTYPE OnFrameWindowActivate(BOOL DebugUsedArg(fActivate))
   {
     return E_NOTIMPL;
   }
 
-  virtual HRESULT STDMETHODCALLTYPE ResizeBorder(LPCRECT prcBorder, IOleInPlaceUIWindow * pUIWindow, BOOL fRameWindow)
+  virtual HRESULT STDMETHODCALLTYPE ResizeBorder(LPCRECT, IOleInPlaceUIWindow *, BOOL DebugUsedArg(fRameWindow))
   {
     return E_NOTIMPL;
   }
 
-  virtual HRESULT STDMETHODCALLTYPE TranslateAccelerator(LPMSG lpMsg, const GUID * pguidCmdGroup, DWORD nCmdID)
+  virtual HRESULT STDMETHODCALLTYPE TranslateAccelerator(LPMSG, const GUID * DebugUsedArg(pguidCmdGroup), DWORD DebugUsedArg(nCmdID))
   {
     return E_NOTIMPL;
   }
 
-  virtual HRESULT STDMETHODCALLTYPE GetOptionKeyPath(LPOLESTR * pchKey, DWORD dw)
+  virtual HRESULT STDMETHODCALLTYPE GetOptionKeyPath(LPOLESTR * DebugUsedArg(pchKey), DWORD DebugUsedArg(dw))
   {
     return E_NOTIMPL;
   }
 
-  virtual HRESULT STDMETHODCALLTYPE GetDropTarget(IDropTarget * pDropTarget, IDropTarget ** ppDropTarget)
+  virtual HRESULT STDMETHODCALLTYPE GetDropTarget(IDropTarget *, IDropTarget **)
   {
     return E_NOTIMPL;
   }
 
-  virtual HRESULT STDMETHODCALLTYPE GetExternal(IDispatch ** ppDispatch)
+  virtual HRESULT STDMETHODCALLTYPE GetExternal(IDispatch **)
   {
     return E_NOTIMPL;
   }
 
-  virtual HRESULT STDMETHODCALLTYPE TranslateUrl(DWORD dwTranslate, OLECHAR * pchURLIn, OLECHAR ** ppchURLOut)
+  virtual HRESULT STDMETHODCALLTYPE TranslateUrl(DWORD DebugUsedArg(dwTranslate), OLECHAR * DebugUsedArg(pchURLIn), OLECHAR ** DebugUsedArg(ppchURLOut))
   {
     return E_NOTIMPL;
   }
 
-  virtual HRESULT STDMETHODCALLTYPE FilterDataObject(IDataObject * pDO, IDataObject ** ppDORet)
+  virtual HRESULT STDMETHODCALLTYPE FilterDataObject(IDataObject *, IDataObject **)
   {
     return E_NOTIMPL;
   }
@@ -2231,7 +2230,7 @@ TRect __fastcall TScreenTipHintWindow::CalcHintRect(int MaxWidth, const UnicodeS
   Canvas->Font->Assign(GetFont(HintControl, AHint));
 
   // from XE6 Vcl.ScreenTips.pas, but absent in 11
-  const cScreenTipTextOnlyWidth = 210;
+  const int cScreenTipTextOnlyWidth = 210;
   const int ScreenTipTextOnlyWidth = ScaleByTextHeight(HintControl, cScreenTipTextOnlyWidth);
 
   int LongHintMargin = 0; // shut up
@@ -2629,7 +2628,7 @@ bool __fastcall TDarkExplorerUxThemeStyle::DoDrawText(
   return TDarkUxThemeStyle::DoDrawText(DC, Details, S, R, Flags, Options, DPI);
 }
 //---------------------------------------------------------------------------
-std::unique_ptr<TDarkExplorerUxThemeStyle> DarkExplorerUxThemeStyle;
+static std::unique_ptr<TDarkExplorerUxThemeStyle> DarkExplorerUxThemeStyle;
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 // Based on:
@@ -2967,8 +2966,8 @@ private:
   TDateTime FLastRequired;
 };
 //---------------------------------------------------------------------------
-std::unique_ptr<TCriticalSection> SystemRequiredThreadSection(TraceInitPtr(new TCriticalSection()));
-TSystemRequiredThread * SystemRequiredThread = NULL;
+static std::unique_ptr<TCriticalSection> SystemRequiredThreadSection(TraceInitPtr(new TCriticalSection()));
+static TSystemRequiredThread * SystemRequiredThread = NULL;
 //---------------------------------------------------------------------------
 TSystemRequiredThread::TSystemRequiredThread() :
   TSignalThread(true), FRequired(false)

+ 2 - 2
source/windows/GUITools.h

@@ -2,8 +2,8 @@
 #ifndef GUIToolsH
 #define GUIToolsH
 //---------------------------------------------------------------------------
-#include <FileMasks.H>
-#include <Tbx.hpp>
+#include <FileMasks.h>
+#include <TBX.hpp>
 #include <DirectoryMonitor.hpp>
 //---------------------------------------------------------------------------
 class TSessionData;

+ 1 - 1
source/windows/ProgParams.cpp

@@ -7,7 +7,7 @@
 //---------------------------------------------------------------------------
 #pragma package(smart_init)
 //---------------------------------------------------------------------------
-std::unique_ptr<TProgramParams> ProgramParamsOwner;
+static std::unique_ptr<TProgramParams> ProgramParamsOwner;
 //---------------------------------------------------------------------------
 TProgramParams * __fastcall TProgramParams::Instance()
 {

+ 4 - 4
source/windows/QueueController.cpp

@@ -82,7 +82,7 @@ TQueueOperation __fastcall TQueueController::DefaultOperation()
 }
 //---------------------------------------------------------------------------
 bool __fastcall TQueueController::AllowOperation(
-  TQueueOperation Operation, void ** Param)
+  TQueueOperation Operation, unsigned long * Param)
 {
   TQueueItemProxy * QueueItem = NULL;
 
@@ -139,7 +139,7 @@ bool __fastcall TQueueController::AllowOperation(
           TFileOperationProgressType::IsTransferOperation(QueueItem->Info->Operation);
         if (Result && (Param != NULL))
         {
-          Result = QueueItem->GetCPSLimit(*reinterpret_cast<unsigned long *>(Param));
+          Result = QueueItem->GetCPSLimit(*Param);
         }
         return Result;
       }
@@ -175,7 +175,7 @@ bool __fastcall TQueueController::AllowOperation(
 }
 //---------------------------------------------------------------------------
 void __fastcall TQueueController::ExecuteOperation(TQueueOperation Operation,
-  void * Param)
+  unsigned long Param)
 {
   TQueueItemProxy * QueueItem = NULL;
 
@@ -235,7 +235,7 @@ void __fastcall TQueueController::ExecuteOperation(TQueueOperation Operation,
     case qoItemSpeed:
       if (QueueItem != NULL)
       {
-        QueueItem->SetCPSLimit(reinterpret_cast<unsigned long>(Param));
+        QueueItem->SetCPSLimit(Param);
       }
       break;
 

+ 2 - 2
source/windows/QueueController.h

@@ -18,8 +18,8 @@ public:
   virtual __fastcall ~TQueueController();
 
   TQueueOperation __fastcall DefaultOperation();
-  bool __fastcall AllowOperation(TQueueOperation Operation, void ** Param = NULL);
-  void __fastcall ExecuteOperation(TQueueOperation Operation, void * Param = NULL);
+  bool __fastcall AllowOperation(TQueueOperation Operation, unsigned long * Param = NULL);
+  void __fastcall ExecuteOperation(TQueueOperation Operation, unsigned long Param = 0);
 
   void __fastcall UpdateQueueStatus(TTerminalQueueStatus * QueueStatus);
   void __fastcall RefreshQueueItem(TQueueItemProxy * QueueItem);

+ 15 - 19
source/windows/Setup.cpp

@@ -44,12 +44,12 @@
 #define MAX_PATH_LEN 2000
 
 /* Command line options. */
-UnicodeString LastPathError;
+static UnicodeString LastPathError;
 //---------------------------------------------------------------------------
-UnicodeString NetVersionStr;
-UnicodeString NetCoreVersionStr;
-UnicodeString PowerShellVersionStr;
-UnicodeString PowerShellCoreVersionStr;
+static UnicodeString NetVersionStr;
+static UnicodeString NetCoreVersionStr;
+static UnicodeString PowerShellVersionStr;
+static UnicodeString PowerShellCoreVersionStr;
 //---------------------------------------------------------------------------
 // Display the error "err_msg".
 void err_out(LPCTSTR err_msg)
@@ -442,7 +442,7 @@ static void __fastcall RegisterAsUrlHandler(const UnicodeString & Protocol, Unic
       Registry->DeleteKey(SoftwareClassesBaseKey + Protocol);
     }
   }
-  catch (Exception & E)
+  catch (Exception &)
   {
     try
     {
@@ -659,7 +659,7 @@ static void __fastcall RegisterForDefaultPrograms()
     // this is needed for Windows Vista+7
     UnregisterProtocolsForDefaultPrograms(HKEY_CURRENT_USER, true);
   }
-  catch (Exception & E)
+  catch (Exception &)
   {
     try
     {
@@ -1336,7 +1336,7 @@ protected:
   void __fastcall HttpDownload(THttp * Sender, __int64 Size, bool & Cancel);
   void __fastcall UpdateProgress();
   void __fastcall ShowException();
-  void __fastcall DownloadNotVerified();
+  NORETURN void __fastcall DownloadNotVerified();
   void __fastcall CancelForm();
 
 private:
@@ -1506,7 +1506,7 @@ void __fastcall TUpdateDownloadThread::UpdateDownloaded()
   TerminateApplication();
 }
 //---------------------------------------------------------------------------
-void __fastcall TUpdateDownloadThread::DownloadNotVerified()
+NORETURN void __fastcall TUpdateDownloadThread::DownloadNotVerified()
 {
   throw Exception(MainInstructions(LoadStr(UPDATE_VERIFY_ERROR)));
 }
@@ -1645,11 +1645,6 @@ static void __fastcall DownloadUpdate(void * /*Data*/, TObject * Sender, unsigne
   Thread->Resume();
 }
 //---------------------------------------------------------------------------
-static void __fastcall UpdatesDonateClick(void * /*Data*/, TObject * /*Sender*/)
-{
-  EnableAutomaticUpdates();
-}
-//---------------------------------------------------------------------------
 static void __fastcall InsertDonateLink(void * /*Data*/, TObject * Sender)
 {
   const UnicodeString DonatePanelName = L"DonatePanel";
@@ -1669,7 +1664,7 @@ static void __fastcall InsertDonateLink(void * /*Data*/, TObject * Sender)
     UnicodeString StoreLink = FORMAT(L"<a href=\"%s\">%s</a>", (StoreUrl, StoreButton));
 
     UnicodeString PlainBody = TNetEncoding::HTML->Decode(DocumentBody);
-    int P1, P2;
+    int P1, P2 = 0; // shut up
     while (((P1 = PlainBody.Pos(L"<")) > 0) && ((P2 = PlainBody.Pos(L">")) > 0) && (P1 < P2))
     {
       PlainBody.Delete(P1, P2 - P1 + 1);
@@ -1851,7 +1846,7 @@ protected:
   TThreadMethod FOnUpdatesChecked;
 };
 //---------------------------------------------------------------------------
-TUpdateThread * UpdateThread = NULL;
+static TUpdateThread * UpdateThread = NULL;
 //---------------------------------------------------------------------------
 __fastcall TUpdateThread::TUpdateThread(TThreadMethod OnUpdatesChecked) :
   TCompThread(false),
@@ -1973,7 +1968,6 @@ static bool __fastcall AddJumpListCategory(TStrings * Names,
 void __fastcall UpdateJumpList(TStrings * SessionNames, TStrings * WorkspaceNames)
 {
   ICustomDestinationList * DestinationList = NULL;
-  IObjectArray * RemovedArray;
   TStringList * Removed = NULL;
   int OldErrMode = SetErrorMode(SEM_FAILCRITICALERRORS);
 
@@ -1984,9 +1978,11 @@ void __fastcall UpdateJumpList(TStrings * SessionNames, TStrings * WorkspaceName
     {
 
       unsigned int MinSlots;
-      HRESULT Result = DestinationListBeginList(DestinationList, MinSlots, IID_IObjectArray, reinterpret_cast<void *>(RemovedArray), 50000);
-      if (SUCCEEDED(Result) && DebugAlwaysTrue(RemovedArray != NULL))
+      void * ppv = NULL;
+      HRESULT Result = DestinationListBeginList(DestinationList, MinSlots, IID_IObjectArray, ppv, 50000);
+      if (SUCCEEDED(Result) && DebugAlwaysTrue(ppv != NULL))
       {
+        IObjectArray * RemovedArray = static_cast<IObjectArray*>(ppv);
         Removed = new TStringList();
 
         unsigned int RemovedCount;

+ 0 - 1
source/windows/SynchronizeController.h

@@ -63,7 +63,6 @@ private:
   TSynchronizeEvent FOnSynchronize;
   TSynchronizeParamType FSynchronizeParams;
   TSynchronizeOptions * FOptions;
-  TSynchronizeThreadsEvent FOnSynchronizeThreads;
   Discmon::TDiscMonitor * FSynchronizeMonitor;
   TSynchronizeAbortEvent FSynchronizeAbort;
   TSynchronizeInvalidEvent FOnSynchronizeInvalid;

+ 52 - 47
source/windows/TerminalManager.cpp

@@ -739,6 +739,53 @@ void __fastcall TTerminalManager::FreeAll()
   }
 }
 //---------------------------------------------------------------------------
+void TTerminalManager::FreeTerminalCleanup(TTerminal * ATerminal, bool IsActiveSession)
+{
+  int Index = IndexOf(ATerminal);
+  Extract(ATerminal);
+
+  TTerminalQueue * Queue;
+  Queue = reinterpret_cast<TTerminalQueue *>(FQueues->Items[Index]);
+  FQueues->Delete(Index);
+
+  if (IsActiveSession)
+  {
+    TManagedTerminal * NewActiveTerminal;
+    bool LastTerminalClosed = false;
+
+    if (FDestroying)
+    {
+      NewActiveTerminal = NULL;
+    }
+    else
+    {
+      if (Count > 0)
+      {
+        NewActiveTerminal = Sessions[Index < Count ? Index : Index - 1];
+        if (!NewActiveTerminal->Active && !NewActiveTerminal->Disconnected)
+        {
+          NewActiveTerminal->Disconnected = true;
+          NewActiveTerminal->DisconnectedTemporarily = true;
+        }
+      }
+      else
+      {
+        NewActiveTerminal = NULL;
+        LastTerminalClosed = true;
+        if (ScpExplorer != NULL)
+        {
+          TAutoNestingCounter UpdatingCounter(FUpdating); // prevent tab flicker
+          NewActiveTerminal = ScpExplorer->GetReplacementForLastSession();
+        }
+      }
+    }
+    DoSetActiveSession(NewActiveTerminal, false, LastTerminalClosed);
+  }
+
+  // only now all references to/from queue (particularly events to explorer) are cleared
+  delete Queue;
+}
+//---------------------------------------------------------------------------
 void __fastcall TTerminalManager::FreeTerminal(TTerminal * Terminal)
 {
   TTerminal * ATerminal = Terminal;
@@ -801,50 +848,8 @@ void __fastcall TTerminalManager::FreeTerminal(TTerminal * Terminal)
   }
   __finally
   {
-    int Index = IndexOf(ATerminal);
-    Extract(ATerminal);
-
-    TTerminalQueue * Queue;
-    Queue = reinterpret_cast<TTerminalQueue *>(FQueues->Items[Index]);
-    FQueues->Delete(Index);
-
-    if (IsActiveSession)
-    {
-      TManagedTerminal * NewActiveTerminal;
-      bool LastTerminalClosed = false;
-
-      if (FDestroying)
-      {
-        NewActiveTerminal = NULL;
-      }
-      else
-      {
-        if (Count > 0)
-        {
-          NewActiveTerminal = Sessions[Index < Count ? Index : Index - 1];
-          if (!NewActiveTerminal->Active && !NewActiveTerminal->Disconnected)
-          {
-            NewActiveTerminal->Disconnected = true;
-            NewActiveTerminal->DisconnectedTemporarily = true;
-          }
-        }
-        else
-        {
-          NewActiveTerminal = NULL;
-          LastTerminalClosed = true;
-          if (ScpExplorer != NULL)
-          {
-            TAutoNestingCounter UpdatingCounter(FUpdating); // prevent tab flicker
-            NewActiveTerminal = ScpExplorer->GetReplacementForLastSession();
-          }
-        }
-      }
-      DoSetActiveSession(NewActiveTerminal, false, LastTerminalClosed);
-    }
+    FreeTerminalCleanup(ATerminal, IsActiveSession);
 
-    // only now all references to/from queue (particularly events to explorer)
-    // are cleared
-    delete Queue;
     delete Terminal; // noop if abandoned
 
     DoSessionListChanged();
@@ -1412,7 +1417,7 @@ void __fastcall TTerminalManager::TerminalPromptUser(
 }
 //---------------------------------------------------------------------------
 void __fastcall TTerminalManager::TerminalDisplayBanner(
-  TTerminal * Terminal, UnicodeString SessionName,
+  TTerminal * Terminal, UnicodeString DebugUsedArg(SessionName),
   const UnicodeString & Banner, bool & NeverShowAgain, int Options, unsigned int & Params)
 {
   DebugAssert(FAuthenticateForm != NULL);
@@ -2036,11 +2041,11 @@ void __fastcall TTerminalManager::Idle(bool SkipCurrentTerminal)
   }
 
   TTerminalQueue * QueueWithEvent;
-  TQueueEvent QueueEvent;
 
   do
   {
     QueueWithEvent = NULL;
+    TQueueEvent QueueEvent = TQueueEvent(); // shut up
 
     {
       TGuard Guard(FQueueSection);
@@ -2210,7 +2215,7 @@ bool __fastcall TTerminalManager::UploadPublicKey(
         Terminal->OnFinished = NULL;
         DoConnectTerminal(Terminal, false, true);
       }
-      catch (Exception & E)
+      catch (Exception &)
       {
         CloseAutheticateForm();
         throw;
@@ -2374,7 +2379,7 @@ TThumbnailDownloadQueueItem::TThumbnailDownloadQueueItem(
     TCustomScpExplorerForm * ScpExplorer, TManagedTerminal * Terminal, const UnicodeString & SourceDir,
     const UnicodeString & TargetDir, const TCopyParamType * CopyParam) :
   TTransferQueueItem(Terminal, NULL, TargetDir, CopyParam, cpNoConfirmation | cpTemporary, osRemote, true, false),
-  FScpExplorer(ScpExplorer), FManagedTerminal(Terminal)
+  FManagedTerminal(Terminal), FScpExplorer(ScpExplorer)
 {
   FInfo->Source = SourceDir;
 }

+ 2 - 3
source/windows/TerminalManager.h

@@ -12,7 +12,7 @@
 class TCustomScpExplorerForm;
 class TTerminalQueue;
 class TAuthenticateForm;
-class ITaskbarList3;
+struct ITaskbarList3;
 class TThumbnailDownloadQueueItem;
 //---------------------------------------------------------------------------
 enum TTerminalPendingAction { tpNull, tpNone, tpReconnect, tpFree };
@@ -254,6 +254,7 @@ private:
   TTerminalThread * CreateTerminalThread(TTerminal * Terminal);
   void ReconnectingTerminal(TManagedTerminal * ManagedTerminal);
   void ReconnectedTerminal(TManagedTerminal * ManagedTerminal);
+  void FreeTerminalCleanup(TTerminal * ATerminal, bool IsActiveSession);
 };
 //---------------------------------------------------------------------------
 class TThumbnailDownloadQueueItem : public TTransferQueueItem
@@ -270,8 +271,6 @@ protected:
 private:
   TManagedTerminal * FManagedTerminal;
   TCustomScpExplorerForm * FScpExplorer;
-  int FIndex;
-  bool FVisible;
 
   bool Continue();
   bool CheckQueueFront(int Index, const UnicodeString & FileName, TSize ThumbnailSize);

+ 9 - 11
source/windows/Tools.cpp

@@ -39,11 +39,9 @@
 #undef SECURITY_FLAG_IGNORE_CERT_CN_INVALID
 
 #define URL_COMPONENTS URL_COMPONENTS_ANOTHER
-#define URL_COMPONENTSA URL_COMPONENTSA_ANOTHER
 #define URL_COMPONENTSW URL_COMPONENTSW_ANOTHER
 
 #define LPURL_COMPONENTS LPURL_COMPONENTS_ANOTHER
-#define LPURL_COMPONENTSA LPURL_COMPONENTS_ANOTHER
 #define LPURL_COMPONENTSW LPURL_COMPONENTS_ANOTHER
 
 #define INTERNET_SCHEME INTERNET_SCHEME_ANOTHER
@@ -196,7 +194,7 @@ void __fastcall LoadListViewStr(TCustomListView * ListView, UnicodeString ALayou
   }
 }
 //---------------------------------------------------------------------------
-wchar_t FormDataSep = L';';
+static wchar_t FormDataSep = L';';
 //---------------------------------------------------------------------------
 void LoadFormDimensions(
   const UnicodeString & AData, int PixelsPerInch, Forms::TMonitor * Monitor, TForm * Form, TRect & Bounds, bool & DefaultPos)
@@ -807,7 +805,7 @@ void __fastcall OpenBrowser(UnicodeString URL)
 void __fastcall OpenFolderInExplorer(const UnicodeString & Path)
 {
   if ((int)ShellExecute(Application->Handle, L"explore",
-      (wchar_t*)Path.data(), NULL, NULL, SW_SHOWNORMAL) <= 32)
+      static_cast<const wchar_t*>(Path.data()), NULL, NULL, SW_SHOWNORMAL) <= 32)
   {
     throw Exception(FMTLOAD(EXPLORE_LOCAL_DIR_ERROR, (Path)));
   }
@@ -1567,7 +1565,7 @@ bool __fastcall DetectSystemExternalEditor(
 //---------------------------------------------------------------------------
 // this was moved to global scope in past in some attempt to fix crashes,
 // not sure it really helped
-WINHTTP_CURRENT_USER_IE_PROXY_CONFIG IEProxyInfo;
+static WINHTTP_CURRENT_USER_IE_PROXY_CONFIG IEProxyInfo;
 //---------------------------------------------------------------------------
 static bool __fastcall GetProxyUrlFromIE(UnicodeString & Proxy)
 {
@@ -1720,21 +1718,21 @@ void __fastcall FinalizeCustomHelp()
 }
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
-bool __fastcall TWinHelpTester::CanShowALink(const UnicodeString ALink,
-  const UnicodeString FileName)
+bool __fastcall TWinHelpTester::CanShowALink(
+  const UnicodeString DebugUsedArg(ALink), const UnicodeString DebugUsedArg(FileName))
 {
   return !Application->HelpFile.IsEmpty();
 }
 //---------------------------------------------------------------------------
-bool __fastcall TWinHelpTester::CanShowTopic(const UnicodeString Topic,
-  const UnicodeString FileName)
+bool __fastcall TWinHelpTester::CanShowTopic(
+  const UnicodeString DebugUsedArg(Topic), const UnicodeString DebugUsedArg(FileName))
 {
   DebugFail();
   return !Application->HelpFile.IsEmpty();
 }
 //---------------------------------------------------------------------------
-bool __fastcall TWinHelpTester::CanShowContext(const int /*Context*/,
-  const UnicodeString FileName)
+bool __fastcall TWinHelpTester::CanShowContext(
+  const int DebugUsedArg(Context), const UnicodeString DebugUsedArg(FileName))
 {
   DebugFail();
   return !Application->HelpFile.IsEmpty();

+ 1 - 1
source/windows/Tools.h

@@ -2,7 +2,7 @@
 #ifndef ToolsH
 #define ToolsH
 
-#include <comctrls.hpp>
+#include <ComCtrls.hpp>
 #include <WinInterface.h>
 #include <HelpIntfs.hpp>
 #include <stdio.h>

+ 1 - 1
source/windows/UserInterface.cpp

@@ -206,7 +206,7 @@ void __fastcall ShowExtendedExceptionEx(TTerminal * Terminal,
       }
     }
   }
-  catch (Exception & E)
+  catch (Exception &)
   {
     // swallow
   }

+ 6 - 20
source/windows/VCLCommon.cpp

@@ -1073,10 +1073,7 @@ void __fastcall UseSystemSettingsPre(TForm * Control)
 {
   LocalSystemSettings(Control);
 
-  TWndMethod WindowProc;
-  ((TMethod*)&WindowProc)->Data = Control;
-  ((TMethod*)&WindowProc)->Code = FormWindowProc;
-  Control->WindowProc = WindowProc;
+  Control->WindowProc = MakeMethod<TWndMethod>(Control, FormWindowProc);
 
   if (Control->HelpKeyword.IsEmpty())
   {
@@ -2248,10 +2245,7 @@ void __fastcall HintLabel(TStaticText * StaticText, UnicodeString Hint)
   StaticText->ShowHint = true;
   StaticText->Cursor = crHandPoint;
 
-  TWndMethod WindowProc;
-  ((TMethod*)&WindowProc)->Data = StaticText;
-  ((TMethod*)&WindowProc)->Code = HintLabelWindowProc;
-  StaticText->WindowProc = WindowProc;
+  StaticText->WindowProc = MakeMethod<TWndMethod>(StaticText, HintLabelWindowProc);
 }
 //---------------------------------------------------------------------------
 static void __fastcall ComboBoxFixWindowProc(void * Data, TMessage & Message)
@@ -2286,10 +2280,7 @@ static void __fastcall ComboBoxFixWindowProc(void * Data, TMessage & Message)
 //---------------------------------------------------------------------------
 void __fastcall FixComboBoxResizeBug(TCustomComboBox * ComboBox)
 {
-  TWndMethod WindowProc;
-  ((TMethod*)&WindowProc)->Data = ComboBox;
-  ((TMethod*)&WindowProc)->Code = ComboBoxFixWindowProc;
-  ComboBox->WindowProc = WindowProc;
+  ComboBox->WindowProc = MakeMethod<TWndMethod>(ComboBox, ComboBoxFixWindowProc);
 }
 //---------------------------------------------------------------------------
 static void __fastcall LinkLabelClick(TStaticText * StaticText)
@@ -2374,10 +2365,7 @@ static void __fastcall DoLinkLabel(TStaticText * StaticText)
   StaticText->ParentFont = true;
   StaticText->Cursor = crHandPoint;
 
-  TWndMethod WindowProc;
-  ((TMethod*)&WindowProc)->Data = StaticText;
-  ((TMethod*)&WindowProc)->Code = LinkLabelWindowProc;
-  StaticText->WindowProc = WindowProc;
+  StaticText->WindowProc = MakeMethod<TWndMethod>(StaticText, LinkLabelWindowProc);
 }
 //---------------------------------------------------------------------------
 void __fastcall LinkLabel(TStaticText * StaticText, UnicodeString Url,
@@ -2401,9 +2389,7 @@ void __fastcall LinkLabel(TStaticText * StaticText, UnicodeString Url,
     StaticText->PopupMenu = new TPopupMenu(StaticText);
     try
     {
-      TNotifyEvent ContextMenuOnClick;
-      ((TMethod*)&ContextMenuOnClick)->Data = StaticText;
-      ((TMethod*)&ContextMenuOnClick)->Code = LinkLabelContextMenuClick;
+      TNotifyEvent ContextMenuOnClick = MakeMethod<TNotifyEvent>(StaticText, LinkLabelContextMenuClick);
 
       TMenuItem * Item;
 
@@ -2807,7 +2793,7 @@ void __fastcall TDesktopFontManager::WndProc(TMessage & Message)
   Message.Result = DefWindowProc(FWindowHandle, Message.Msg, Message.WParam, Message.LParam);
 }
 //---------------------------------------------------------------------------
-std::unique_ptr<TDesktopFontManager> DesktopFontManager(new TDesktopFontManager());
+static std::unique_ptr<TDesktopFontManager> DesktopFontManager(new TDesktopFontManager());
 //---------------------------------------------------------------------------
 // This might be somewhat redundant now that at least the default Desktop font is actually the default VCL font
 void __fastcall UseDesktopFont(TControl * Control)

+ 30 - 45
source/windows/WinConfiguration.cpp

@@ -15,7 +15,7 @@
 #include "TerminalManager.h"
 #include "Cryptography.h"
 #include <VCLCommon.h>
-#include <InitGUID.h>
+#include <initguid.h>
 #include <DragExt.h>
 #include <Math.hpp>
 #include <StrUtils.hpp>
@@ -701,7 +701,7 @@ void __fastcall TWinConfiguration::Default()
   FUpdates.AuthenticationEmail = L"";
   FUpdates.Mode = EmptyStr;
   // for backward compatibility the default is decided based on value of ProxyHost
-  FUpdates.ConnectionType = (TConnectionType)-1;
+  FUpdates.ConnectionType = ctUndefined;
   FUpdates.ProxyHost = L""; // keep empty (see above)
   FUpdates.ProxyPort = 8080;
   FUpdates.Results.Reset();
@@ -1041,11 +1041,11 @@ THierarchicalStorage * TWinConfiguration::CreateScpStorage(bool & SessionList)
 #define KEY(TYPE, VAR) KEYEX(TYPE, VAR, PropertyToKey(TEXT(#VAR)))
 #define REGCONFIG(CANCREATE) \
   BLOCK(L"Interface", CANCREATE, \
-    KEYEX(Integer,DoubleClickAction, L"CopyOnDoubleClick"); \
+    KEYEX(Enum,   DoubleClickAction, L"CopyOnDoubleClick"); \
     KEY(Bool,     CopyOnDoubleClickConfirmation); \
     KEY(Bool,     AlwaysRespectDoubleClickAction); \
     KEY(Bool,     DDDisableMove); \
-    KEYEX(Integer, DDTransferConfirmation, L"DDTransferConfirmation2"); \
+    KEYEX(Enum,   DDTransferConfirmation, L"DDTransferConfirmation2"); \
     KEY(String,   DDTemporaryDirectory); \
     KEY(String,   DDDrives); \
     KEY(Bool,     DDWarnLackOfTempSpace); \
@@ -1056,8 +1056,8 @@ THierarchicalStorage * TWinConfiguration::CreateScpStorage(bool & SessionList)
     KEY(Bool,     SelectDirectories); \
     KEY(String,   SelectMask); \
     KEY(Bool,     ShowHiddenFiles); \
-    KEY(Integer,  FormatSizeBytes); \
-    KEY(Integer,  PanelSearch); \
+    KEY(Enum,     FormatSizeBytes); \
+    KEY(Enum,     PanelSearch); \
     KEY(Bool,     ShowInaccesibleDirectories); \
     KEY(Bool,     ConfirmTransferring); \
     KEY(Bool,     ConfirmDeleting); \
@@ -1076,13 +1076,13 @@ THierarchicalStorage * TWinConfiguration::CreateScpStorage(bool & SessionList)
     KEY(Bool,     TemporaryDirectoryCleanup); \
     KEY(Bool,     ConfirmTemporaryDirectoryCleanup); \
     KEY(Bool,     PreservePanelState); \
-    KEY(Integer,  DarkTheme); \
+    KEY(Enum,     DarkTheme); \
     KEY(String,   LastStoredSession); \
     KEY(Bool,     AutoSaveWorkspace); \
     KEY(Bool,     AutoSaveWorkspacePasswords); \
     KEY(String,   AutoWorkspace); \
-    KEY(Integer,  PathInCaption); \
-    KEY(Integer,  SessionTabNameFormat); \
+    KEY(Enum,     PathInCaption); \
+    KEY(Enum,     SessionTabNameFormat); \
     KEY(Bool,     MinimizeToTray); \
     KEY(Bool,     BalloonNotifications); \
     KEY(Integer,  NotificationsTimeout); \
@@ -1108,9 +1108,9 @@ THierarchicalStorage * TWinConfiguration::CreateScpStorage(bool & SessionList)
     KEY(String,   OpenedStoredSessionFolders); \
     KEY(Bool,     AutoImportedFromPuttyOrFilezilla); \
     KEY(Integer,  GenerateUrlComponents); \
-    KEY(Integer,  GenerateUrlCodeTarget); \
-    KEY(Integer,  GenerateUrlScriptFormat); \
-    KEY(Integer,  GenerateUrlAssemblyLanguage); \
+    KEY(Enum,     GenerateUrlCodeTarget); \
+    KEY(Enum,     GenerateUrlScriptFormat); \
+    KEY(Enum,     GenerateUrlAssemblyLanguage); \
     KEY(Bool,     ExternalSessionInExistingInstance); \
     KEY(Bool,     ShowLoginWhenNoSession); \
     KEY(Bool,     KeepOpenWhenNoSession); \
@@ -1118,8 +1118,8 @@ THierarchicalStorage * TWinConfiguration::CreateScpStorage(bool & SessionList)
     KEY(Bool,     LocalIconsByExt); \
     KEY(Bool,     FlashTaskbar); \
     KEY(Integer,  MaxSessions); \
-    KEY(Integer,  BidiModeOverride); \
-    KEY(Integer,  FlipChildrenOverride); \
+    KEY(Enum,     BidiModeOverride); \
+    KEY(Enum,     FlipChildrenOverride); \
     KEY(Bool,     ShowTips); \
     KEY(String,   TipsSeen); \
     KEY(DateTime, TipsShown); \
@@ -1135,7 +1135,7 @@ THierarchicalStorage * TWinConfiguration::CreateScpStorage(bool & SessionList)
     KEY(Bool,     TimeoutShellIconRetrieval); \
     KEY(Bool,     UseIconUpdateThread); \
     KEY(Bool,     AllowWindowPrint); \
-    KEY(Integer,  StoreTransition); \
+    KEY(Enum,     StoreTransition); \
     KEY(Integer,  QueueTransferLimitMax); \
     KEY(Bool,     HiContrast); \
     KEY(Bool,     EditorCheckNotModified); \
@@ -1150,8 +1150,8 @@ THierarchicalStorage * TWinConfiguration::CreateScpStorage(bool & SessionList)
     KEY(Integer,  Editor.Font.FontSize); \
     KEY(Integer,  Editor.Font.FontStyle); \
     KEY(Integer,  Editor.Font.FontCharset); \
-    KEY(Integer,  Editor.FontColor); \
-    KEY(Integer,  Editor.BackgroundColor); \
+    KEY(Enum,     Editor.FontColor); \
+    KEY(Enum,     Editor.BackgroundColor); \
     KEY(Bool,     Editor.WordWrap); \
     KEY(String,   Editor.FindText); \
     KEY(String,   Editor.ReplaceText); \
@@ -1173,8 +1173,8 @@ THierarchicalStorage * TWinConfiguration::CreateScpStorage(bool & SessionList)
     KEY(Integer,  QueueView.Height); \
     KEY(Integer,  QueueView.HeightPixelsPerInch); \
     KEY(String,   QueueView.Layout); \
-    KEY(Integer,  QueueView.Show); \
-    KEY(Integer,  QueueView.LastHideShow); \
+    KEY(Enum,     QueueView.Show); \
+    KEY(Enum,     QueueView.LastHideShow); \
     KEY(Bool,     QueueView.ToolBar); \
     KEY(Bool,     QueueView.Label); \
     KEY(Bool,     QueueView.FileList); \
@@ -1186,11 +1186,11 @@ THierarchicalStorage * TWinConfiguration::CreateScpStorage(bool & SessionList)
     KEY(DateTime, FUpdates.LastCheck); \
     KEY(Integer,  FUpdates.HaveResults); \
     KEY(Integer,  FUpdates.ShownResults); \
-    KEY(Integer,  FUpdates.BetaVersions); \
+    KEY(Enum,     FUpdates.BetaVersions); \
     KEY(Bool,     FUpdates.ShowOnStartup); \
     KEY(String,   FUpdates.AuthenticationEmail); \
     KEY(String,   FUpdates.Mode); \
-    KEY(Integer,  FUpdates.ConnectionType); \
+    KEY(Enum,     FUpdates.ConnectionType); \
     KEY(String,   FUpdates.ProxyHost); \
     KEY(Integer,  FUpdates.ProxyPort); \
     KEY(Integer,  FUpdates.Results.ForVersion); \
@@ -1236,13 +1236,13 @@ THierarchicalStorage * TWinConfiguration::CreateScpStorage(bool & SessionList)
   BLOCK(L"Interface\\Commander", CANCREATE, \
     KEYEX(String,  ScpCommander.ToolbarsLayout, ToolbarsLayoutKey); \
     KEY(String,  ScpCommander.ToolbarsButtons); \
-    KEY(Integer, ScpCommander.CurrentPanel); \
+    KEY(Enum,    ScpCommander.CurrentPanel); \
     KEY(Float,   ScpCommander.LocalPanelWidth); \
     KEY(Bool,    ScpCommander.SwappedPanels); \
     KEY(Bool,    ScpCommander.SessionsTabs); \
     KEY(Bool,    ScpCommander.StatusBar); \
     KEY(String,  ScpCommander.WindowParams); \
-    KEYEX(Integer, ScpCommander.NortonLikeMode, L"ExplorerStyleSelection"); \
+    KEYEX(Enum,  ScpCommander.NortonLikeMode, L"ExplorerStyleSelection"); \
     KEY(Bool,    ScpCommander.PreserveLocalDirectory); \
     KEY(Bool,    ScpCommander.CompareByTime); \
     KEY(Bool,    ScpCommander.CompareBySize); \
@@ -1397,7 +1397,7 @@ void __fastcall TWinConfiguration::LoadFrom(THierarchicalStorage * Storage)
     FLegacyEditor = NULL;
   }
 
-  if (FUpdates.ConnectionType == -1)
+  if (FUpdates.ConnectionType == ctUndefined)
   {
     FUpdates.ConnectionType = (FUpdates.ProxyHost.IsEmpty() ? ctAuto : ctProxy);
   }
@@ -2248,21 +2248,6 @@ void __fastcall TWinConfiguration::SetDarkTheme(TAutoSwitch value)
   SET_CONFIG_PROPERTY_EX(DarkTheme, ConfigureInterface());
 }
 //---------------------------------------------------------------------------
-static int __fastcall SysDarkTheme(HKEY RootKey)
-{
-  std::unique_ptr<TRegistry> Registry(new TRegistry());
-  Registry->RootKey = RootKey;
-  UnicodeString ThemesPersonalizeKey = L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
-  UnicodeString AppsUseLightThemeValue = L"AppsUseLightTheme";
-  int Result = -1;
-  if (Registry->OpenKeyReadOnly(ThemesPersonalizeKey) &&
-      Registry->ValueExists(AppsUseLightThemeValue))
-  {
-    Result = Registry->ReadBool(AppsUseLightThemeValue) ? 0 : 1;
-  }
-  return Result;
-}
-//---------------------------------------------------------------------------
 bool __fastcall TWinConfiguration::UseDarkTheme()
 {
   switch (WinConfiguration->DarkTheme)
@@ -2529,8 +2514,8 @@ void __fastcall TWinConfiguration::SetExtensionList(TCustomCommandList * value)
     for (int Index = 0; Index < ExtensionList->Count; Index++)
     {
       const TCustomCommandType * CustomCommand = ExtensionList->Commands[Index];
-      int Index = value->FindIndexByFileName(CustomCommand->FileName);
-      if (Index < 0)
+      int Index2 = value->FindIndexByFileName(CustomCommand->FileName);
+      if (Index2 < 0)
       {
         if (FileExists(CustomCommand->FileName) &&
             !DeleteFile(CustomCommand->FileName))
@@ -3071,7 +3056,7 @@ void __fastcall TWinConfiguration::RestoreFont(
 {
   Font->Name = Configuration.FontName;
   Font->Size = Configuration.FontSize;
-  Font->Charset = Configuration.FontCharset;
+  Font->Charset = static_cast<TFontCharset>(Configuration.FontCharset);
   Font->Style = IntToFontStyles(Configuration.FontStyle);
 }
 //---------------------------------------------------------------------------
@@ -3269,7 +3254,7 @@ void __fastcall TCustomCommandType::LoadExtension(TStrings * Lines, const Unicod
 
     if (!Continuation)
     {
-      int P;
+      int P = 0; // shut up
       if (!ExtensionLine.IsEmpty() && (ExtensionLine[1] == ExtensionMark) && ((P = Pos(L" ", ExtensionLine)) >= 2))
       {
         UnicodeString Key = ExtensionLine.SubString(2, P - 2).LowerCase();
@@ -3956,11 +3941,11 @@ public:
     // fallback to comparing by name
     else if ((Index1 < 0) && (Index2 < 0))
     {
-      Result = TComparer__1<UnicodeString>::Default()->Compare(CustomCommand1->Name, CustomCommand2->Name);
+      Result = AnsiCompareStr(CustomCommand1->Name, CustomCommand2->Name);
     }
     else
     {
-      Result = TComparer__1<int>::Default()->Compare(Index1, Index2);
+      Result = ((Index1 < Index2) ? -1 : ((Index1 > Index2) ? 1 : 0));
     }
     return Result;
   }

+ 10 - 10
source/windows/WinConfiguration.h

@@ -29,7 +29,7 @@ struct TScpExplorerConfiguration {
     { return C(WindowParams) C(DirViewParams) C(ToolbarsLayout) C(ToolbarsButtons)
         C(SessionsTabs) C(StatusBar)
         C(LastLocalTargetDirectory) C(ViewStyle) C(ShowFullAddress)
-        C(DriveView) C(DriveViewWidth) C(DriveViewWidthPixelsPerInch) 0; };
+        C(DriveView) C(DriveViewWidth) C(DriveViewWidthPixelsPerInch) 0; }
 };
 //---------------------------------------------------------------------------
 struct TScpCommanderPanelConfiguration {
@@ -45,7 +45,7 @@ struct TScpCommanderPanelConfiguration {
   bool __fastcall operator !=(TScpCommanderPanelConfiguration & rhc)
     { return C(DirViewParams) C(ViewStyle) C(StatusBar)
         C(DriveView) C(DriveViewHeight) C(DriveViewHeightPixelsPerInch)
-        C(DriveViewWidth) C(DriveViewWidthPixelsPerInch) C(LastPath) 0; };
+        C(DriveViewWidth) C(DriveViewWidthPixelsPerInch) C(LastPath) 0; }
 };
 //---------------------------------------------------------------------------
 struct TScpCommanderConfiguration {
@@ -76,7 +76,7 @@ struct TScpCommanderConfiguration {
       C(NortonLikeMode) C(PreserveLocalDirectory)
       C(CompareBySize) C(CompareByTime) C(SwappedPanels)
       C(TreeOnLeft) C(ExplorerKeyboardShortcuts) C(SystemContextMenu)
-      C(OtherLocalPanelDirViewParams) C(OtherLocalPanelViewStyle) C(OtherLocalPanelLastPath) 0; };
+      C(OtherLocalPanelDirViewParams) C(OtherLocalPanelViewStyle) C(OtherLocalPanelLastPath) 0; }
 
   TCompareCriterias __fastcall CompareCriterias()
   {
@@ -110,7 +110,7 @@ struct TFontConfiguration
   // keep in sync with SameFont
   bool __fastcall operator !=(const TFontConfiguration & rhc)
     { return !SameText(FontName, rhc.FontName) || C(FontSize)
-      C(FontCharset) C(FontStyle) 0; };
+      C(FontCharset) C(FontStyle) 0; }
 };
 //---------------------------------------------------------------------------
 struct TEditorConfiguration {
@@ -137,7 +137,7 @@ struct TEditorConfiguration {
     { return C(Font) C(FontColor) C(BackgroundColor) C(WordWrap) C(FindText) C(ReplaceText)
       C(FindMatchCase) C(FindWholeWord) C(FindDown) C(TabSize)
       C(MaxEditors) C(EarlyClose) C(SDIShellEditor) C(WindowParams)
-      C(Encoding) C(WarnOnEncodingFallback) C(WarnOrLargeFileSize) C(AutoFont) C(DisableSmoothScroll) 0; };
+      C(Encoding) C(WarnOnEncodingFallback) C(WarnOrLargeFileSize) C(AutoFont) C(DisableSmoothScroll) 0; }
 };
 //---------------------------------------------------------------------------
 enum TQueueViewShow { qvShow, qvHideWhenEmpty, qvHide };
@@ -154,7 +154,7 @@ struct TQueueViewConfiguration {
   int FileListHeightPixelsPerInch;
   bool __fastcall operator !=(TQueueViewConfiguration & rhc)
     { return C(Height) C(HeightPixelsPerInch) C(Layout) C(Show) C(LastHideShow) C(ToolBar) C(Label)
-        C(FileList) C(FileListHeight) C(FileListHeightPixelsPerInch) 0; };
+        C(FileList) C(FileListHeight) C(FileListHeightPixelsPerInch) 0; }
 };
 //---------------------------------------------------------------------------
 struct TUpdatesData
@@ -185,7 +185,7 @@ struct TUpdatesData
              C(Disabled) C(Url) C(UrlButton) C(NewsUrl) C(NewsSize)
              C(DownloadUrl) C(DownloadSize) C(DownloadSha256) C(AuthenticationError)
              C(OpenGettingStarted) C(DownloadingUrl)
-             C(TipsSize) C(TipsUrl) C(Tips) C(TipsIntervalDays) C(TipsIntervalRuns) 0; };
+             C(TipsSize) C(TipsUrl) C(Tips) C(TipsIntervalDays) C(TipsIntervalRuns) 0; }
   void Reset()
   {
     ForVersion = 0;
@@ -212,7 +212,7 @@ struct TUpdatesData
   }
 };
 //---------------------------------------------------------------------------
-enum TConnectionType { ctDirect, ctAuto, ctProxy };
+enum TConnectionType { ctUndefined = -1, ctDirect, ctAuto, ctProxy };
 extern TDateTime DefaultUpdatesPeriod;
 extern const UnicodeString ScpExplorerDirViewParamsDefault;
 extern const UnicodeString ScpCommanderRemotePanelDirViewParamsDefault;
@@ -242,7 +242,7 @@ struct TUpdatesConfiguration
     { return C(Period) C(LastCheck) C(ConnectionType) C(ProxyHost) C(ProxyPort)
         C(BetaVersions) C(ShowOnStartup) C(AuthenticationEmail) C(Mode)
         C(HaveResults) C(ShownResults) C(DotNetVersion)
-        C(ConsoleVersion) C(Results)  0; };
+        C(ConsoleVersion) C(Results)  0; }
 
   bool __fastcall HaveValidResultsForVersion(int CompoundVersion)
   {
@@ -311,7 +311,7 @@ private:
   mutable UnicodeString FName;
 
   UnicodeString __fastcall GetName() const;
-  const TEditorData * __fastcall GetConstData() const { return &FData; };
+  const TEditorData * __fastcall GetConstData() const { return &FData; }
 };
 //---------------------------------------------------------------------------
 class TEditorList

+ 1 - 1
source/windows/WinHelp.cpp

@@ -57,7 +57,7 @@ __fastcall TWebHelpSystem::TWebHelpSystem(
 {
 }
 //---------------------------------------------------------------------------
-int __fastcall TWebHelpSystem::UnderstandsKeyword(const UnicodeString HelpString)
+int __fastcall TWebHelpSystem::UnderstandsKeyword(const UnicodeString DebugUsedArg(HelpString))
 {
   // pretend that we know everything
   return 1;

+ 7 - 9
source/windows/WinInterface.cpp

@@ -34,7 +34,7 @@
 //---------------------------------------------------------------------------
 #define WM_TRAY_ICON (WM_WINSCP_USER + 5)
 //---------------------------------------------------------------------
-TNotifyEvent GlobalOnMinimize = NULL;
+static TNotifyEvent GlobalOnMinimize = NULL;
 //---------------------------------------------------------------------
 const IID IID_IListView_Win7 = {0xE5B16AF2, 0x3990, 0x4681, {0xA6, 0x09, 0x1F, 0x06, 0x0C, 0xD1, 0x42, 0x69}};
 //---------------------------------------------------------------------
@@ -238,9 +238,7 @@ TForm * __fastcall CreateMessageDialogEx(const UnicodeString Msg,
       {
         NeverAskAgainCheck->Tag = Params->NeverAskAgainAnswer;
       }
-      TNotifyEvent OnClick;
-      ((TMethod*)&OnClick)->Code = NeverAskAgainCheckClick;
-      NeverAskAgainCheck->OnClick = OnClick;
+      NeverAskAgainCheck->OnClick = MakeMethod<TNotifyEvent>(NULL, NeverAskAgainCheckClick);
     }
 
     Dialog->HelpKeyword = HelpKeyword;
@@ -729,7 +727,7 @@ void * __fastcall BusyStart()
 //---------------------------------------------------------------------------
 void __fastcall BusyEnd(void * Token)
 {
-  Screen->Cursor = reinterpret_cast<TCursor>(Token);
+  Screen->Cursor = static_cast<TCursor>(reinterpret_cast<uintptr_t>(Token));
 }
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
@@ -1262,7 +1260,7 @@ void __fastcall CallGlobalMinimizeHandler(TObject * Sender)
   }
 }
 //---------------------------------------------------------------------------
-bool MinimizedToTray = false;
+static bool MinimizedToTray = false;
 //---------------------------------------------------------------------------
 static void __fastcall DoApplicationMinimizeRestore(bool Minimize)
 {
@@ -1446,7 +1444,7 @@ void __fastcall TCallstackThread::ProcessEvent()
     UnicodeString Path = DumpCallstackFileName(GetCurrentProcessId());
     std::unique_ptr<TStrings> StackStrings;
     HANDLE MainThreadHandle = reinterpret_cast<HANDLE>(MainThreadID);
-    if (SuspendThread(MainThreadHandle) < 0)
+    if (SuspendThread(MainThreadHandle) == static_cast<DWORD>(-1))
     {
       RaiseLastOSError();
     }
@@ -1461,7 +1459,7 @@ void __fastcall TCallstackThread::ProcessEvent()
     }
     __finally
     {
-      if (ResumeThread(MainThreadHandle) < 0)
+      if (ResumeThread(MainThreadHandle) == static_cast<DWORD>(-1))
       {
         RaiseLastOSError();
       }
@@ -1480,7 +1478,7 @@ HANDLE TCallstackThread::DoCreateEvent()
 }
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
-std::unique_ptr<TCallstackThread> CallstackThread;
+static std::unique_ptr<TCallstackThread> CallstackThread;
 //---------------------------------------------------------------------------
 static void __fastcall AppGetMainFormHandle(void * /*Data*/, HWND & Handle)
 {

+ 33 - 33
source/windows/WinInterface.h

@@ -216,17 +216,17 @@ void __fastcall DoConsoleDialog(TTerminal * Terminal,
     const UnicodeString Command = L"", const TStrings * Log = NULL);
 
 // forms\Copy.cpp
-const coTemp                = 0x001;
-const coDisableQueue        = 0x002;
-const coDoNotShowAgain      = 0x020;
-const coAllowRemoteTransfer = 0x100;
-const coShortCutHint        = 0x800;
-const coAllFiles            = 0x1000;
-const coExplore             = 0x2000;
-const cooDoNotShowAgain     = 0x01;
-const cooRemoteTransfer     = 0x02;
-const cooSaveSettings       = 0x04;
-const cooExplore            = 0x08;
+const int coTemp                = 0x001;
+const int coDisableQueue        = 0x002;
+const int coDoNotShowAgain      = 0x020;
+const int coAllowRemoteTransfer = 0x100;
+const int coShortCutHint        = 0x800;
+const int coAllFiles            = 0x1000;
+const int coExplore             = 0x2000;
+const int cooDoNotShowAgain     = 0x01;
+const int cooRemoteTransfer     = 0x02;
+const int cooSaveSettings       = 0x04;
+const int cooExplore            = 0x08;
 bool __fastcall DoCopyDialog(
   bool ToRemote, bool Move, TStrings * FileList, UnicodeString & TargetDirectory,
   TGUICopyParamType * Params, int Options, int CopyParamAttrs,
@@ -236,9 +236,9 @@ bool CopyDialogValidateFileMask(
   const UnicodeString & FileMask, THistoryComboBox * DirectoryEdit, bool MultipleFiles, bool RemotePaths);
 
 // forms\CopyLocal.cpp
-const cloShortCutHint = 0x01;
-const cloMultipleFiles = 0x02;
-const clooDoNotShowAgain = 0x01;
+const int cloShortCutHint = 0x01;
+const int cloMultipleFiles = 0x02;
+const int clooDoNotShowAgain = 0x01;
 bool DoCopyLocalDialog(bool Move, int Options, UnicodeString & TargetDirectory, UnicodeString & FileMask, int & OutputOptions);
 
 // forms\CreateDirectory.cpp
@@ -272,7 +272,7 @@ bool __fastcall LocationProfilesDialog(TOpenDirectoryMode Mode,
 enum TPreferencesMode { pmDefault, pmEditor, pmCustomCommands,
     pmQueue, pmLogging, pmUpdates, pmPresets, pmEditors, pmCommander,
     pmEditorInternal, pmFileColors };
-class TCopyParamRuleData;
+struct TCopyParamRuleData;
 struct TPreferencesDialogData
 {
   TCopyParamRuleData * CopyParamRuleData;
@@ -285,8 +285,8 @@ class TCustomCommandList;
 class TCustomCommandType;
 class TShortCuts;
 enum TCustomCommandsMode { ccmAdd, ccmEdit, ccmAdHoc };
-const ccoDisableRemote = 0x01;
-const ccoDisableRemoteFiles = 0x02;
+const int ccoDisableRemote = 0x01;
+const int ccoDisableRemoteFiles = 0x02;
 typedef void __fastcall (__closure *TCustomCommandValidate)
   (const TCustomCommandType & Command);
 bool __fastcall DoCustomCommandDialog(TCustomCommandType & Command,
@@ -309,12 +309,12 @@ bool __fastcall DoCopyParamCustomDialog(TCopyParamType & CopyParam,
 class TRemoteProperties;
 class TRemoteTokenList;
 struct TCalculateSizeStats;
-const cpMode =  0x01;
-const cpOwner = 0x02;
-const cpGroup = 0x04;
-const cpAcl =   0x08;
-const poUserGroupByID = 0x01;
-const poTags =          0x02;
+const int cpMode =  0x01;
+const int cpOwner = 0x02;
+const int cpGroup = 0x04;
+const int cpAcl =   0x08;
+const int poUserGroupByID = 0x01;
+const int poTags =          0x02;
 typedef void __fastcall (__closure *TCalculateSizeEvent)
   (TStrings * FileList, __int64 & Size, TCalculateSizeStats & Stats,
    bool & Close);
@@ -349,9 +349,9 @@ bool __fastcall DoFileColorDialog(TFileColorData & FileColorData);
 bool __fastcall DoEditMaskDialog(TFileMasks & Mask);
 
 // forms\Synchronize.cpp
-const soDoNotUsePresets =  0x01;
-const soNoMinimize =       0x02;
-const soAllowSelectedOnly = 0x04;
+const int soDoNotUsePresets =  0x01;
+const int soNoMinimize =       0x02;
+const int soAllowSelectedOnly = 0x04;
 typedef void __fastcall (__closure *TGetSynchronizeOptionsEvent)
   (int Params, TSynchronizeOptions & Options);
 typedef void __fastcall (__closure *TSynchronizeSessionLog)
@@ -374,10 +374,10 @@ bool __fastcall DoSynchronizeDialog(TSynchronizeParamType & Params,
 // forms\FullSynchronize.cpp
 struct TUsableCopyParamAttrs;
 enum TSynchronizeMode { smRemote, smLocal, smBoth };
-const fsoDisableTimestamp = 0x01;
-const fsoDoNotUsePresets =  0x02;
-const fsoAllowSelectedOnly = 0x04;
-const fsoDisableByChecksum = 0x08;
+const int fsoDisableTimestamp = 0x01;
+const int fsoDoNotUsePresets =  0x02;
+const int fsoAllowSelectedOnly = 0x04;
+const int fsoDisableByChecksum = 0x08;
 typedef void __fastcall (__closure *TFullSynchronizeInNewWindow)
   (TSynchronizeMode Mode, int Params, const UnicodeString & LocalDirectory, const UnicodeString & RemoteDirectory,
    const TCopyParamType * CopyParams);
@@ -467,7 +467,7 @@ int __fastcall Console(TConsoleMode Mode);
 
 // forms\EditorPreferences.cpp
 enum TEditorPreferencesMode { epmAdd, epmEdit, epmAdHoc };
-class TEditorData;
+struct TEditorData;
 bool __fastcall DoEditorPreferencesDialog(TEditorData * Editor,
   bool & Remember, TEditorPreferencesMode Mode, bool MayRemote);
 
@@ -579,7 +579,7 @@ struct TCopyDataMessage
       wchar_t Session[1024];
       wchar_t Path[1024];
     } Refresh;
-  };
+  } Data;
 
   TCopyDataMessage()
   {
@@ -659,7 +659,7 @@ enum TConsoleFlag
 class TConsole
 {
 public:
-  virtual __fastcall ~TConsole() {};
+  virtual __fastcall ~TConsole() {}
   virtual void __fastcall Print(UnicodeString Str, bool FromBeginning = false, bool Error = false) = 0;
   void __fastcall PrintLine(const UnicodeString & Str = UnicodeString(), bool Error = false);
   virtual bool __fastcall Input(UnicodeString & Str, bool Echo, unsigned int Timer) = 0;

+ 21 - 22
source/windows/WinMain.cpp

@@ -485,11 +485,11 @@ void __fastcall TStartupThread::Execute()
   }
 }
 //---------------------------------------------------------------------------
-TStartupThread * StartupThread(new TStartupThread());
-TDateTime Started(Now());
-TDateTime LastStartupStartupSequence(Now());
-UnicodeString StartupSequence;
-int LifetimeRuns = -1;
+static TStartupThread * StartupThread(new TStartupThread());
+static TDateTime Started(Now());
+static TDateTime LastStartupStartupSequence(Now());
+static UnicodeString StartupSequence;
+static int LifetimeRuns = -1;
 //---------------------------------------------------------------------------
 void InterfaceStartDontMeasure()
 {
@@ -738,8 +738,8 @@ bool __fastcall SendToAnotherInstance()
       SetForegroundWindow(Handle);
 
       Message.Command = TCopyDataMessage::CommandCommandLine;
-      wcsncpy(Message.CommandLine, CmdLine, LENOF(Message.CommandLine));
-      NULL_TERMINATE(Message.CommandLine);
+      wcsncpy(Message.Data.CommandLine, CmdLine, LENOF(Message.Data.CommandLine));
+      NULL_TERMINATE(Message.Data.CommandLine);
 
       Result = SendCopyDataMessage(Handle, Message);
     }
@@ -762,10 +762,10 @@ void __fastcall Refresh(const UnicodeString & Session, const UnicodeString & Pat
 
     TCopyDataMessage Message;
     Message.Command = TCopyDataMessage::RefreshPanel;
-    wcsncpy(Message.Refresh.Session, Session.c_str(), LENOF(Message.Refresh.Session));
-    NULL_TERMINATE(Message.Refresh.Session);
-    wcsncpy(Message.Refresh.Path, Path.c_str(), LENOF(Message.Refresh.Path));
-    NULL_TERMINATE(Message.Refresh.Path);
+    wcsncpy(Message.Data.Refresh.Session, Session.c_str(), LENOF(Message.Data.Refresh.Session));
+    NULL_TERMINATE(Message.Data.Refresh.Session);
+    wcsncpy(Message.Data.Refresh.Path, Path.c_str(), LENOF(Message.Data.Refresh.Path));
+    NULL_TERMINATE(Message.Data.Refresh.Path);
 
     SendCopyDataMessage(Handle, Message);
 
@@ -877,7 +877,7 @@ int __fastcall Execute()
 
       Configuration->TemporaryLogSensitive(LogSensitive);
     }
-    int LogProtocol;
+    int LogProtocol = 0; // shut up
     if (!SwitchValue.IsEmpty() && TryStrToInt(SwitchValue, LogProtocol) && (LogProtocol >= -1))
     {
       Configuration->TemporaryLogProtocol(LogProtocol);
@@ -898,7 +898,7 @@ int __fastcall Execute()
       SwitchValue = SwitchValue.Trim();
     }
 
-    __int64 LogMaxSize;
+    __int64 LogMaxSize = 0; // shut up
     if ((LogMaxCount >= 0) &&
         !SwitchValue.IsEmpty() &&
         TryStrToSize(SwitchValue, LogMaxSize))
@@ -1318,13 +1318,13 @@ int __fastcall Execute()
                 // Start loading drives on the background asap,
                 // to prevent unnecessary refreshes after the explorer opens
                 DriveInfo->NeedData();
-                TCustomScpExplorerForm * ScpExplorer = CreateScpExplorer();
+                std::unique_ptr<TCustomScpExplorerForm> ScpExplorer(CreateScpExplorer());
                 AddStartupSequence(L"E");
                 CustomWinConfiguration->AppliedInterface = CustomWinConfiguration->Interface;
                 try
                 {
                   // moved inside try .. __finally, because it can fail as well
-                  TerminalManager->ScpExplorer = ScpExplorer;
+                  TerminalManager->ScpExplorer = ScpExplorer.get();
 
                   if ((ParamCommand != pcNone) || !DownloadFile.IsEmpty())
                   {
@@ -1339,17 +1339,17 @@ int __fastcall Execute()
                   }
                   else if (ParamCommand == pcFullSynchronize)
                   {
-                    FullSynchronize(TerminalManager->ActiveSession, ScpExplorer,
-                      CommandParams, UseDefaults);
+                    FullSynchronize(
+                      TerminalManager->ActiveSession, ScpExplorer.get(), CommandParams, UseDefaults);
                   }
                   else if (ParamCommand == pcSynchronize)
                   {
-                    Synchronize(TerminalManager->ActiveSession, ScpExplorer,
-                      CommandParams, UseDefaults);
+                    Synchronize(
+                      TerminalManager->ActiveSession, ScpExplorer.get(), CommandParams, UseDefaults);
                   }
                   else if (ParamCommand == pcEdit)
                   {
-                    Edit(ScpExplorer, CommandParams);
+                    Edit(ScpExplorer.get(), CommandParams);
                   }
                   else if (!DownloadFile.IsEmpty())
                   {
@@ -1379,7 +1379,6 @@ int __fastcall Execute()
                 __finally
                 {
                   TerminalManager->ScpExplorer = NULL;
-                  SAFE_DESTROY(ScpExplorer);
                 }
               }
             }
@@ -1390,7 +1389,7 @@ int __fastcall Execute()
           }
         }
         // Catch EAbort from Synchronize() and similar functions, so that CheckConfigurationForceSave is processed
-        catch (EAbort & E)
+        catch (EAbort &)
         {
           Retry = false; // unlikely to be true, but just in case
         }