Ver código fonte

Clang imposed changes that should be noop and have no effect on classic compiler

Mostly:
– incorrectly identified uninitialized variables
– explicit static global variables
– const, sign and down casts and safety
– typename use
– semicolon after function implementation
– unused variables, fields, arguments and macros
– field initialization order
– exact include filename case
– redundant in code macros already defined at project level

(cherry picked from commit f7f00c631e6b145cad653b8d6186c8a6f3b6ba6a)

Source commit: 90ad9390853aba308abe73cf02e0281238c53c87
Martin Prikryl 7 meses atrás
pai
commit
3f4e41fee0
59 arquivos alterados com 299 adições e 263 exclusões
  1. 1 1
      source/core/Bookmarks.cpp
  2. 2 0
      source/core/Bookmarks.h
  3. 7 6
      source/core/Common.cpp
  4. 7 7
      source/core/Common.h
  5. 0 1
      source/core/Configuration.h
  6. 1 1
      source/core/CopyParam.cpp
  7. 7 9
      source/core/Cryptography.cpp
  8. 1 1
      source/core/Exceptions.cpp
  9. 4 4
      source/core/Exceptions.h
  10. 4 4
      source/core/FileBuffer.cpp
  11. 5 6
      source/core/FileBuffer.h
  12. 2 2
      source/core/FileInfo.cpp
  13. 2 2
      source/core/FileOperationProgress.h
  14. 12 0
      source/core/FileSystems.cpp
  15. 2 2
      source/core/FileSystems.h
  16. 13 15
      source/core/FtpFileSystem.cpp
  17. 2 2
      source/core/Global.h
  18. 8 6
      source/core/HierarchicalStorage.cpp
  19. 2 2
      source/core/HierarchicalStorage.h
  20. 2 2
      source/core/NamedObjs.cpp
  21. 3 3
      source/core/NamedObjs.h
  22. 0 1
      source/core/NeonIntf.cpp
  23. 0 1
      source/core/NeonIntf.h
  24. 10 9
      source/core/PuttyIntf.cpp
  25. 16 19
      source/core/Queue.cpp
  26. 3 2
      source/core/Queue.h
  27. 4 6
      source/core/RemoteFiles.cpp
  28. 18 15
      source/core/S3FileSystem.cpp
  29. 13 10
      source/core/ScpFileSystem.cpp
  30. 3 3
      source/core/Script.cpp
  31. 2 2
      source/core/SecureShell.cpp
  32. 1 1
      source/core/Security.cpp
  33. 9 8
      source/core/SessionData.cpp
  34. 1 1
      source/core/SessionInfo.cpp
  35. 33 32
      source/core/SftpFileSystem.cpp
  36. 2 2
      source/core/SftpFileSystem.h
  37. 11 6
      source/core/Terminal.cpp
  38. 1 1
      source/core/Terminal.h
  39. 1 1
      source/core/Usage.cpp
  40. 11 7
      source/core/WebDAVFileSystem.cpp
  41. 11 12
      source/core/WebDAVFileSystem.h
  42. 1 1
      source/filezilla/AsyncProxySocketLayer.cpp
  43. 2 2
      source/filezilla/AsyncSocketEx.cpp
  44. 1 1
      source/filezilla/AsyncSocketExLayer.cpp
  45. 2 2
      source/filezilla/AsyncSslSocketLayer.cpp
  46. 1 1
      source/filezilla/FileZillaApi.cpp
  47. 18 18
      source/filezilla/FtpControlSocket.cpp
  48. 2 2
      source/filezilla/FtpListResult.cpp
  49. 0 1
      source/filezilla/ServerPath.h
  50. 4 4
      source/filezilla/TransferSocket.cpp
  51. 8 5
      source/putty/defs.h
  52. 6 3
      source/putty/network.h
  53. 5 0
      source/putty/putty.h
  54. 1 1
      source/putty/puttyexp.h
  55. 1 0
      source/putty/ssh.h
  56. 2 2
      source/putty/ssh/transport2.c
  57. 1 1
      source/putty/ssh/userauth2-client.c
  58. 2 0
      source/putty/windows/gss.c
  59. 5 4
      source/putty/windows/handle-io.c

+ 1 - 1
source/core/Bookmarks.cpp

@@ -86,7 +86,7 @@ void __fastcall TBookmarks::LoadLevel(THierarchicalStorage * Storage, const Unic
     Storage->GetValueNames(Names);
     UnicodeString Name;
     UnicodeString Directory;
-    TShortCut ShortCut;
+    TShortCut ShortCut = TShortCut();
     for (int i = 0; i < Names->Count; i++)
     {
       Name = Names->Strings[i];

+ 2 - 0
source/core/Bookmarks.h

@@ -35,6 +35,8 @@ private:
     int Index, TBookmarkList * BookmarkList);
 };
 //---------------------------------------------------------------------------
+class TBookmark;
+//---------------------------------------------------------------------------
 class TBookmarkList : public TPersistent
 {
 friend class TBookmarks;

+ 7 - 6
source/core/Common.cpp

@@ -14,6 +14,7 @@
 #include <shlobj.h>
 #include <limits>
 #include <algorithm>
+#include <memory>
 #include <shlwapi.h>
 #include <tlhelp32.h>
 #include <psapi.h>
@@ -2185,7 +2186,7 @@ TDateTime __fastcall FileTimeToDateTime(const FILETIME & FileTime)
 __int64 __fastcall ConvertTimestampToUnix(const FILETIME & FileTime,
   TDSTMode DSTMode)
 {
-  __int64 Result = ((*(__int64*)&(FileTime)) / 10000000LL - 11644473600LL);
+  __int64 Result = ((*(const __int64*)&(FileTime)) / 10000000LL - 11644473600LL);
 
   if (UsesDaylightHack())
   {
@@ -3070,8 +3071,8 @@ bool __fastcall IsWine()
     (GetProcAddress(NtDll, "wine_get_version") != NULL);
 }
 //---------------------------------------------------------------------------
-int GIsUWP = -1;
-UnicodeString GPackageName;
+static int GIsUWP = -1;
+static UnicodeString GPackageName;
 //---------------------------------------------------------------------------
 void EnableUWPTestMode()
 {
@@ -3919,7 +3920,7 @@ UnicodeString __fastcall RtfEscapeParam(UnicodeString Param, bool PowerShellEsca
     else
     {
       int P2 = PosEx(RtfHyperlinkFieldPrefix, Param, Index);
-      int P3;
+      int P3 = 0; // shut up
       if ((P2 > 0) && (P2 < P1) && ((P3 = PosEx(RtfHyperlinkFieldSuffix, Param, P2)) > 0))
       {
         // skip HYPERLINK
@@ -4428,7 +4429,7 @@ static UnicodeString GetProcessName(DWORD ProcessId)
   return Result;
 }
 //---------------------------------------------------------------------------
-UnicodeString ParentProcessName;
+static UnicodeString ParentProcessName;
 //---------------------------------------------------------------------------
 UnicodeString __fastcall GetAncestorProcessName(int Levels)
 {
@@ -4512,7 +4513,7 @@ UnicodeString __fastcall GetAncestorProcessName(int Levels)
   return Result;
 }
 //---------------------------------------------------------------------------
-UnicodeString AncestorProcessNames;
+static UnicodeString AncestorProcessNames;
 //---------------------------------------------------------------------------
 UnicodeString GetAncestorProcessNames()
 {

+ 7 - 7
source/core/Common.h

@@ -112,7 +112,7 @@ int __fastcall CompareNumber(__int64 Value1, __int64 Value2);
 bool ContainsTextSemiCaseSensitive(const UnicodeString & Text, const UnicodeString & SubText);
 bool __fastcall IsReservedName(UnicodeString FileName);
 UnicodeString __fastcall ApiPath(UnicodeString Path);
-bool IsWideChar(wchar_t Ch) { return (Ch >= L'\x80'); };
+bool IsWideChar(wchar_t Ch) { return (Ch >= L'\x80'); }
 UnicodeString __fastcall DisplayableStr(const RawByteString & Str);
 UnicodeString __fastcall ByteToHex(unsigned char B, bool UpperCase = true);
 UnicodeString __fastcall BytesToHex(const unsigned char * B, size_t Length, bool UpperCase = true, wchar_t Separator = L'\0');
@@ -183,7 +183,7 @@ UnicodeString __fastcall FormatVersion(int MajovVersion, int MinorVersion, int R
 TFormatSettings __fastcall GetEngFormatSettings();
 int __fastcall ParseShortEngMonthName(const UnicodeString & MonthStr);
 // The defaults are equal to defaults of TStringList class (except for Sorted)
-TStringList * __fastcall CreateSortedStringList(bool CaseSensitive = false, System::Types::TDuplicates Duplicates = dupIgnore);
+TStringList * __fastcall CreateSortedStringList(bool CaseSensitive = false, System::Types::TDuplicates Duplicates = System::Types::dupIgnore);
 bool SameIdent(const UnicodeString & Ident1, const UnicodeString & Ident2);
 UnicodeString __fastcall FindIdent(const UnicodeString & Ident, TStrings * Idents);
 UnicodeString GetTlsErrorStr(unsigned long Err);
@@ -431,7 +431,7 @@ class BiDiMap
 {
 public:
   typedef std::map<T1, T2> TFirstToSecond;
-  typedef TFirstToSecond::const_iterator const_iterator;
+  typedef typename TFirstToSecond::const_iterator const_iterator;
 
   void Add(const T1 & Value1, const T2 & Value2)
   {
@@ -441,7 +441,7 @@ public:
 
   T1 LookupFirst(const T2 & Value2) const
   {
-    TSecondToFirst::const_iterator Iterator = FSecondToFirst.find(Value2);
+    typename TSecondToFirst::const_iterator Iterator = FSecondToFirst.find(Value2);
     DebugAssert(Iterator != FSecondToFirst.end());
     return Iterator->second;
   }
@@ -497,7 +497,7 @@ public:
 
   void Remove(T EventHandler)
   {
-    TEventHandlers::iterator I = Find(EventHandler);
+    typename TEventHandlers::iterator I = Find(EventHandler);
     if (DebugAlwaysTrue(I != FEventHandlers.end()))
     {
       FEventHandlers.erase(I);
@@ -508,7 +508,7 @@ public:
   template<typename P>
   void Invoke(const P & p)
   {
-    TEventHandlers::iterator I = FEventHandlers.begin();
+    typename TEventHandlers::iterator I = FEventHandlers.begin();
     while (I != FEventHandlers.end())
     {
       (*I)(p);
@@ -541,7 +541,7 @@ private:
   typedef std::vector<T> TEventHandlers;
   TEventHandlers FEventHandlers;
 
-  TEventHandlers::iterator Find(T EventHandler)
+  typename TEventHandlers::iterator Find(T EventHandler)
   {
     return std::find(FEventHandlers.begin(), FEventHandlers.end(), EventHandler);
   }

+ 0 - 1
source/core/Configuration.h

@@ -72,7 +72,6 @@ private:
   bool FPermanentLogging;
   UnicodeString FLogFileName;
   UnicodeString FPermanentLogFileName;
-  int FLogWindowLines;
   bool FLogFileAppend;
   bool FLogSensitive;
   bool FPermanentLogSensitive;

+ 1 - 1
source/core/CopyParam.cpp

@@ -450,7 +450,7 @@ void __fastcall TCopyParamType::DoGetInfoStr(
   {
     UnicodeString Value;
     UnicodeString CodeState;
-    int ResumeThresholdKB = (ResumeThreshold / 1024);
+    int ResumeThresholdKB = static_cast<int>(ResumeThreshold / 1024);
     switch (ResumeSupport)
     {
       case rsOff:

+ 7 - 9
source/core/Cryptography.cpp

@@ -503,7 +503,7 @@ bool __fastcall AES256Verify(UnicodeString Input, RawByteString Verifier)
   return (Mac == Mac2);
 }
 //---------------------------------------------------------------------------
-unsigned char SScrambleTable[256] =
+static unsigned char SScrambleTable[256] =
 {
     0, 223, 235, 233, 240, 185,  88, 102,  22, 130,  27,  53,  79, 125,  66, 201,
    90,  71,  51,  60, 134, 104, 172, 244, 139,  84,  91,  12, 123, 155, 237, 151,
@@ -523,8 +523,8 @@ unsigned char SScrambleTable[256] =
   206, 222, 188, 152, 210, 243,  96,  41,  86, 180, 101, 177, 166, 141, 212, 116
 };
 //---------------------------------------------------------------------------
-unsigned char * ScrambleTable;
-unsigned char * UnscrambleTable;
+static unsigned char * ScrambleTable;
+static unsigned char * UnscrambleTable;
 //---------------------------------------------------------------------------
 RawByteString __fastcall ScramblePassword(UnicodeString Password)
 {
@@ -604,7 +604,7 @@ bool __fastcall UnscramblePassword(RawByteString Scrambled, UnicodeString & Pass
   return Result;
 }
 //---------------------------------------------------------------------------
-UnicodeString OpensslInitializationErrors;
+static UnicodeString OpensslInitializationErrors;
 //---------------------------------------------------------------------------
 static bool InitOpenssl()
 {
@@ -762,10 +762,8 @@ void TEncryption::NeedSalt()
   }
 }
 //---------------------------------------------------------------------------
-const int AesBlock = 16;
-const int AesBlockMask = 0x0F;
-UnicodeString AesCtrExt(L".aesctr.enc");
-RawByteString AesCtrMagic("aesctr.........."); // 16 bytes fixed [to match AES block size], even for future algos
+static UnicodeString AesCtrExt(L".aesctr.enc");
+static RawByteString AesCtrMagic("aesctr.........."); // 16 bytes fixed [to match AES block size], even for future algos
 //---------------------------------------------------------------------------
 int TEncryption::RoundToBlock(int Size)
 {
@@ -796,7 +794,7 @@ void TEncryption::Aes(TFileBuffer & Buffer, bool Last)
     FOverflowBuffer.SetLength(0);
   }
 
-  int Size;
+  int Size = 0; // shut up
   if (Last)
   {
     Size = Buffer.Size;

+ 1 - 1
source/core/Exceptions.cpp

@@ -34,7 +34,7 @@ static bool __fastcall WellKnownException(
   Exception * E, UnicodeString * AMessage, const wchar_t ** ACounterName, Exception ** AClone, bool Rethrow)
 {
   UnicodeString Message;
-  const wchar_t * CounterName;
+  const wchar_t * CounterName = NULL; // shut up
   std::unique_ptr<Exception> Clone;
 
 

+ 4 - 4
source/core/Exceptions.h

@@ -35,7 +35,7 @@ public:
     Sysutils::Exception(Msg, Args, Args_Size)
   {
   }
-  inline __fastcall ExtException(int Ident, const TVarRec * Args, const int Args_Size)/* overload */ :
+  inline __fastcall ExtException(NativeUInt Ident, const TVarRec * Args, const int Args_Size)/* overload */ :
     Sysutils::Exception(Ident, Args, Args_Size)
   {
   }
@@ -47,7 +47,7 @@ public:
     Sysutils::Exception(Msg, Args, Args_Size, AHelpContext)
   {
   }
-  inline __fastcall ExtException(int Ident, int AHelpContext)/* overload */ :
+  inline __fastcall ExtException(NativeUInt Ident, int AHelpContext)/* overload */ :
     Exception(Ident, AHelpContext)
   {
   }
@@ -90,7 +90,7 @@ private:
       BASE(Msg, Args, Args_Size) \
     { \
     } \
-    inline __fastcall NAME(int Ident, const TVarRec * Args, const int Args_Size) : \
+    inline __fastcall NAME(NativeUInt Ident, const TVarRec * Args, const int Args_Size) : \
       BASE(Ident, Args, Args_Size) \
     { \
     } \
@@ -102,7 +102,7 @@ private:
       BASE(Msg, Args, Args_Size, AHelpContext) \
     { \
     } \
-    inline __fastcall NAME(int Ident, int AHelpContext) : \
+    inline __fastcall NAME(NativeUInt Ident, int AHelpContext) : \
       BASE(Ident, AHelpContext) \
     { \
     } \

+ 4 - 4
source/core/FileBuffer.cpp

@@ -9,7 +9,7 @@
 //---------------------------------------------------------------------------
 const wchar_t * EOLTypeNames = L"LF;CRLF;CR";
 //---------------------------------------------------------------------------
-char * __fastcall EOLToStr(TEOLType EOLType)
+const char * __fastcall EOLToStr(TEOLType EOLType)
 {
   switch (EOLType) {
     case eolLF: return "\n";
@@ -98,7 +98,7 @@ DWORD __fastcall TFileBuffer::LoadFromIn(TTransferInEvent OnTransferIn, TObject
   return Result;
 }
 //---------------------------------------------------------------------------
-void __fastcall TFileBuffer::Convert(char * Source, char * Dest, int Params,
+void __fastcall TFileBuffer::Convert(const char * Source, const char * Dest, int Params,
   bool & Token)
 {
   DebugAssert(strlen(Source) <= 2);
@@ -202,13 +202,13 @@ void __fastcall TFileBuffer::Convert(TEOLType Source, TEOLType Dest, int Params,
   Convert(EOLToStr(Source), EOLToStr(Dest), Params, Token);
 }
 //---------------------------------------------------------------------------
-void __fastcall TFileBuffer::Convert(char * Source, TEOLType Dest, int Params,
+void __fastcall TFileBuffer::Convert(const char * Source, TEOLType Dest, int Params,
   bool & Token)
 {
   Convert(Source, EOLToStr(Dest), Params, Token);
 }
 //---------------------------------------------------------------------------
-void __fastcall TFileBuffer::Convert(TEOLType Source, char * Dest, int Params,
+void __fastcall TFileBuffer::Convert(TEOLType Source, const char * Dest, int Params,
   bool & Token)
 {
   Convert(EOLToStr(Source), Dest, Params, Token);

+ 5 - 6
source/core/FileBuffer.h

@@ -2,7 +2,7 @@
 #ifndef FileBufferH
 #define FileBufferH
 
-#include <classes.hpp>
+#include <Classes.hpp>
 //---------------------------------------------------------------------------
 extern const wchar_t * EOLTypeNames;
 enum TEOLType { eolLF /* \n */, eolCRLF /* \r\n */, eolCR /* \r */ };
@@ -17,10 +17,10 @@ class TFileBuffer
 public:
   __fastcall TFileBuffer();
   virtual __fastcall ~TFileBuffer();
-  void __fastcall Convert(char * Source, char * Dest, int Params, bool & Token);
+  void __fastcall Convert(const char * Source, const char * Dest, int Params, bool & Token);
   void __fastcall Convert(TEOLType Source, TEOLType Dest, int Params, bool & Token);
-  void __fastcall Convert(char * Source, TEOLType Dest, int Params, bool & Token);
-  void __fastcall Convert(TEOLType Source, char * Dest, int Params, bool & Token);
+  void __fastcall Convert(const char * Source, TEOLType Dest, int Params, bool & Token);
+  void __fastcall Convert(TEOLType Source, const char * Dest, int Params, bool & Token);
   void __fastcall Insert(int Index, const char * Buf, int Len);
   void __fastcall Delete(int Index, int Len);
   DWORD __fastcall LoadStream(TStream * Stream, const DWORD Len, bool ForceLen);
@@ -58,9 +58,8 @@ public:
   virtual int __fastcall Write(const System::DynamicArray<System::Byte> Buffer, int Offset, int Count);
 private:
   THandleStream * FSource;
-  bool FOwned;
 };
 //---------------------------------------------------------------------------
-char * __fastcall EOLToStr(TEOLType EOLType);
+const char * __fastcall EOLToStr(TEOLType EOLType);
 //---------------------------------------------------------------------------
 #endif

+ 2 - 2
source/core/FileInfo.cpp

@@ -16,7 +16,7 @@ void * __fastcall CreateFileInfo(UnicodeString FileName)
 {
   unsigned long Handle;
   unsigned int Size;
-  void * Result = NULL;
+  char * Result = NULL;
 
   // Get file version info block size
   Size = GetFileVersionInfoSize(FileName.c_str(), &Handle);
@@ -37,7 +37,7 @@ void * __fastcall CreateFileInfo(UnicodeString FileName)
 // Free file version info block memory
 void __fastcall FreeFileInfo(void * FileInfo)
 {
-  delete[] FileInfo;
+  delete[] static_cast<char *>(FileInfo);
 }
 //---------------------------------------------------------------------------
 typedef TTranslation TTranslations[65536];

+ 2 - 2
source/core/FileOperationProgress.h

@@ -106,8 +106,8 @@ private:
   unsigned long __fastcall GetCPSLimit();
   TBatchOverwrite __fastcall GetBatchOverwrite();
   bool __fastcall GetSkipToAll();
-  TDateTime __fastcall GetStartTime() const { return FPersistence.StartTime; };
-  TOperationSide __fastcall GetSide() const { return FPersistence.Side; };
+  TDateTime __fastcall GetStartTime() const { return FPersistence.StartTime; }
+  TOperationSide __fastcall GetSide() const { return FPersistence.Side; }
 
 protected:
   void __fastcall ClearTransfer();

+ 12 - 0
source/core/FileSystems.cpp

@@ -29,3 +29,15 @@ UnicodeString TCustomFileSystem::CalculateFilesChecksumInitialize(const UnicodeS
   NotImplemented();
   return EmptyStr;
 }
+//---------------------------------------------------------------------------
+void __fastcall TCustomFileSystem::TransferOnDirectory(
+  const UnicodeString & Directory, const TCopyParamType *, int Params)
+{
+  DebugUsedParam2(Directory, Params);
+}
+//---------------------------------------------------------------------------
+void __fastcall TCustomFileSystem::DirectorySunk(
+  const UnicodeString & DestFullName, const TRemoteFile *, const TCopyParamType *)
+{
+  DebugUsedParam(DestFullName);
+}

+ 2 - 2
source/core/FileSystems.h

@@ -60,14 +60,14 @@ public:
     int Params, TFileOperationProgressType * OperationProgress,
     TOnceDoneOperation & OnceDoneOperation) = 0;
   virtual void __fastcall TransferOnDirectory(
-    const UnicodeString & Directory, const TCopyParamType * CopyParam, int Params) {};
+    const UnicodeString & Directory, const TCopyParamType * CopyParam, int Params);
   virtual void __fastcall Source(
     TLocalFileHandle & Handle, const UnicodeString & TargetDir, UnicodeString & DestFileName,
     const TCopyParamType * CopyParam, int Params,
     TFileOperationProgressType * OperationProgress, unsigned int Flags,
     TUploadSessionAction & Action, bool & ChildError) = 0;
   virtual void __fastcall DirectorySunk(
-    const UnicodeString & DestFullName, const TRemoteFile * File, const TCopyParamType * CopyParam) {};
+    const UnicodeString & DestFullName, const TRemoteFile * File, const TCopyParamType * CopyParam);
   virtual void __fastcall Sink(
     const UnicodeString & FileName, const TRemoteFile * File,
     const UnicodeString & TargetDir, UnicodeString & DestFileName, int Attrs,

+ 13 - 15
source/core/FtpFileSystem.cpp

@@ -4,7 +4,6 @@
 
 //---------------------------------------------------------------------------
 #include <list>
-#define MPEXT
 #include "FtpFileSystem.h"
 #include "FileZillaIntf.h"
 
@@ -30,7 +29,6 @@
 //---------------------------------------------------------------------------
 const int DummyCodeClass = 8;
 const int DummyTimeoutCode = 801;
-const int DummyCancelCode = 802;
 const int DummyDisconnectCode = 803;
 //---------------------------------------------------------------------------
 class TFileZillaImpl : public TFileZillaIntf
@@ -261,8 +259,9 @@ __fastcall TFTPFileSystem::TFTPFileSystem(TTerminal * ATerminal):
   FFileZillaIntf(NULL),
   FQueueCriticalSection(new TCriticalSection),
   FTransferStatusCriticalSection(new TCriticalSection),
-  FQueueEvent(CreateEvent(NULL, true, false, NULL)),
   FQueue(new TMessageQueue),
+  FQueueEvent(CreateEvent(NULL, true, false, NULL)),
+  FFileSystemInfoValid(false),
   FReply(0),
   FCommandReply(0),
   FLastCommand(CMD_UNKNOWN),
@@ -270,16 +269,15 @@ __fastcall TFTPFileSystem::TFTPFileSystem(TTerminal * ATerminal):
   FLastErrorResponse(new TStringList()),
   FLastError(new TStringList()),
   FFeatures(new TStringList()),
+  FReadCurrentDirectory(false),
   FFileList(NULL),
   FFileListCache(NULL),
   FActive(false),
   FWaitingForReply(false),
   FIgnoreFileList(false),
   FOnCaptureOutput(NULL),
-  FFileSystemInfoValid(false),
   FDoListAll(false),
-  FServerCapabilities(NULL),
-  FReadCurrentDirectory(false)
+  FServerCapabilities(NULL)
 {
   ResetReply();
 
@@ -440,6 +438,7 @@ void __fastcall TFTPFileSystem::Open()
         break;
 
       default:
+        ServerType = int(); // shutup
         DebugFail();
         break;
     }
@@ -2236,7 +2235,7 @@ void __fastcall TFTPFileSystem::AutoDetectTimeDifference(TRemoteFileList * FileL
         {
           ReadFile(File->FullFileName, UtcFile);
         }
-        catch (Exception & E)
+        catch (Exception &)
         {
           FDetectTimeDifference = false;
           if (!FTerminal->Active)
@@ -2273,7 +2272,7 @@ void __fastcall TFTPFileSystem::AutoDetectTimeDifference(TRemoteFileList * FileL
           // Time difference between timestamp retrieved using MDTM (UTC converted to local timezone)
           // and using LIST (no conversion, expecting the server uses the same timezone as the client).
           // Note that FormatTimeZone reverses the value.
-          FTimeDifference = static_cast<__int64>(SecsPerDay * (UtcModification - File->Modification));
+          FTimeDifference = static_cast<__int64>(SecsPerDay * static_cast<Variant>(UtcModification - File->Modification));
           double Hours = TTimeSpan::FromSeconds(FTimeDifference).TotalHours;
 
           UnicodeString FileLog =
@@ -2291,7 +2290,7 @@ void __fastcall TFTPFileSystem::AutoDetectTimeDifference(TRemoteFileList * FileL
           }
           else
           {
-            LogMessage = FORMAT(L"Timezone difference of %s detected using file %s", (FormatTimeZone(FTimeDifference), FileLog));
+            LogMessage = FORMAT(L"Timezone difference of %s detected using file %s", (FormatTimeZone(static_cast<long>(FTimeDifference)), FileLog));
           }
           FTerminal->LogEvent(LogMessage);
 
@@ -2371,7 +2370,7 @@ void __fastcall TFTPFileSystem::ReadDirectory(TRemoteFileList * FileList)
         // Note that FZAPI ignores this for VMS/MVS.
         FDoListAll = (FListAll == asOn);
       }
-      catch(Exception & E)
+      catch(Exception &)
       {
         FDoListAll = false;
         // reading the first directory has failed,
@@ -2465,7 +2464,7 @@ void __fastcall TFTPFileSystem::ReadFile(const UnicodeString FileName,
     {
       UnicodeString Path = RemoteExtractFilePath(FileName);
       UnicodeString NameOnly;
-      int P;
+      int P = 0; // shut up
       bool MVSPath =
         FMVS && Path.IsEmpty() &&
         (FileName.SubString(1, 1) == L"'") && (FileName.SubString(FileName.Length(), 1) == L"'") &&
@@ -3433,8 +3432,6 @@ void __fastcall TFTPFileSystem::StoreLastResponse(const UnicodeString & Text)
 //---------------------------------------------------------------------------
 void __fastcall TFTPFileSystem::HandleReplyStatus(UnicodeString Response)
 {
-  int Code;
-
   if (FOnCaptureOutput != NULL)
   {
     FOnCaptureOutput(Response, cotOutput);
@@ -3476,6 +3473,7 @@ void __fastcall TFTPFileSystem::HandleReplyStatus(UnicodeString Response)
 
   // Partially duplicated in CFtpControlSocket::OnReceive
 
+  int Code = 0; // shut up
   bool HasCodePrefix =
     (Response.Length() >= 3) &&
     TryStrToInt(Response.SubString(1, 3), Code) &&
@@ -4045,7 +4043,7 @@ UnicodeString __fastcall FormatValidityTime(const TFtpsCertificateData::TValidit
 bool __fastcall VerifyNameMask(UnicodeString Name, UnicodeString Mask)
 {
   bool Result = true;
-  int Pos;
+  int Pos = 0; // shut up
   while (Result && (Pos = Mask.Pos(L"*")) > 0)
   {
     // Pos will typically be 1 here, so not actual comparison is done
@@ -4642,7 +4640,7 @@ bool __fastcall TFTPFileSystem::Unquote(UnicodeString & Str)
   DebugAssert((Str.Length() > 0) && ((Str[1] == L'"') || (Str[1] == L'\'')));
 
   int Index = 1;
-  wchar_t Quote;
+  wchar_t Quote = wchar_t(); // shut up
   while (Index <= Str.Length())
   {
     switch (State)

+ 2 - 2
source/core/Global.h

@@ -45,7 +45,7 @@ private:
 #define DebugCheck(p) (p)
 #define DebugFail()
 #else // ifndef DODEBUGGING
-void __fastcall DoAssert(wchar_t * Message, wchar_t * Filename, int LineNumber);
+void __fastcall DoAssert(const wchar_t * Message, const wchar_t * Filename, int LineNumber);
 #define DebugAssert(p) ((p) ? (void)0 : DoAssert(TEXT(#p), TEXT(__FILE__), __LINE__))
 #define DebugCheck(p) { bool __CHECK_RESULT__ = (p); DebugAssert(__CHECK_RESULT__); }
 #define DebugFail() DebugAssert(false)
@@ -56,7 +56,7 @@ void __fastcall DoAssert(wchar_t * Message, wchar_t * Filename, int LineNumber);
 #define DebugNotNull(p) (p)
 #define TraceInitPtr(p) (p)
 #define TraceInitStr(p) (p)
-#define DebugUsedParam2(p1, p2) ((&p1) == (&p2))
+#define DebugUsedParam2(p1, p2) (static_cast<const void *>(&p1) == static_cast<const void *>(&p2))
 #define DebugUsedParam(p) DebugUsedParam2(p, p)
 #define DebugUsedArg(p)
 //---------------------------------------------------------------------------

+ 8 - 6
source/core/HierarchicalStorage.cpp

@@ -114,7 +114,7 @@ UnicodeString __fastcall MungeIniName(const UnicodeString & Str, bool ForceAnsi)
   return Result;
 }
 //---------------------------------------------------------------------------
-UnicodeString EscapedBom(TraceInitStr(PuttyEscape(Bom, false)));
+static UnicodeString EscapedBom(TraceInitStr(PuttyEscape(Bom, false)));
 //---------------------------------------------------------------------------
 UnicodeString __fastcall UnMungeIniName(const UnicodeString & Str)
 {
@@ -178,10 +178,10 @@ TIntMapping CreateIntMappingFromEnumNames(const UnicodeString & ANames)
 //---------------------------------------------------------------------------
 TIntMapping AutoSwitchMapping = CreateIntMapping(L"on", asOn, L"off", asOff, L"auto", asAuto);
 TIntMapping AutoSwitchReversedMapping = CreateIntMapping(L"on", asOff, L"off", asOn, L"auto", asAuto);
-TIntMapping BoolMapping = CreateIntMapping(L"on", true, L"off", false);
+static TIntMapping BoolMapping = CreateIntMapping(L"on", true, L"off", false);
 //===========================================================================
-UnicodeString AccessValueName(L"Access");
-UnicodeString DefaultAccessString(L"inherit");
+static UnicodeString AccessValueName(L"Access");
+static UnicodeString DefaultAccessString(L"inherit");
 //---------------------------------------------------------------------------
 __fastcall THierarchicalStorage::THierarchicalStorage(const UnicodeString & AStorage)
 {
@@ -355,7 +355,7 @@ unsigned int __fastcall THierarchicalStorage::GetCurrentAccess()
 bool __fastcall THierarchicalStorage::OpenSubKeyPath(const UnicodeString & KeyPath, bool CanCreate)
 {
   DebugAssert(!KeyPath.IsEmpty() && (KeyPath[KeyPath.Length()] != L'\\'));
-  bool Result;
+  bool Result = false; // shut up
   UnicodeString Buf(KeyPath);
   int Opens = 0;
   while (!Buf.IsEmpty())
@@ -1447,7 +1447,7 @@ bool __fastcall TCustomIniFileStorage::DoReadBool(const UnicodeString & Name, bo
 //---------------------------------------------------------------------------
 int __fastcall TCustomIniFileStorage::DoReadIntegerWithMapping(const UnicodeString & Name, int Default, const TIntMapping * Mapping)
 {
-  int Result;
+  int Result = 0; // shut up
   bool ReadAsInteger = true;
   UnicodeString MungedName = MungeIniName(Name);
   if (Mapping != NULL) // optimization
@@ -2053,11 +2053,13 @@ void __fastcall TOptionsIniFile::ReadSections(TStrings * Strings)
 //---------------------------------------------------------------------------
 void __fastcall TOptionsIniFile::ReadSectionValues(const UnicodeString Section, TStrings * /*Strings*/)
 {
+  DebugUsedParam(Section);
   NotImplemented();
 }
 //---------------------------------------------------------------------------
 void __fastcall TOptionsIniFile::EraseSection(const UnicodeString Section)
 {
+  DebugUsedParam(Section);
   if (AllowWrite())
   {
     NotImplemented();

+ 2 - 2
source/core/HierarchicalStorage.h

@@ -2,7 +2,7 @@
 #ifndef HierarchicalStorageH
 #define HierarchicalStorageH
 
-#include <registry.hpp>
+#include <Registry.hpp>
 #include <memory>
 #include <map>
 //---------------------------------------------------------------------------
@@ -39,7 +39,7 @@ public:
 
   bool __fastcall ReadBool(const UnicodeString & Name, bool Default);
   template<typename T>
-  typename T __fastcall ReadEnum(
+  T __fastcall ReadEnum(
     const UnicodeString & Name, const T & Default, const TIntMapping & Mapping = TIntMapping());
   int __fastcall ReadInteger(const UnicodeString & Name, int Default);
   __int64 __fastcall ReadInt64(const UnicodeString & Name, __int64 Default);

+ 2 - 2
source/core/NamedObjs.cpp

@@ -52,7 +52,7 @@ void __fastcall TNamedObject::MakeUniqueIn(TNamedObjectList * List)
   if (List && (List->IndexOf(this) == -1))
     while (List->FindByName(Name))
     {
-      Integer N = 0, P;
+      Integer N = 0, P = 0; // shut up
       // If name already contains number parenthesis remove it (and remember it)
       if ((Name[Name.Length()] == L')') && ((P = Name.LastDelimiter(L'(')) > 0))
         try
@@ -61,7 +61,7 @@ void __fastcall TNamedObject::MakeUniqueIn(TNamedObjectList * List)
           Name.Delete(P, Name.Length() - P + 1);
           Name = Name.TrimRight();
         }
-        catch (Exception &E)
+        catch (Exception &)
         {
           N = 0;
         }

+ 3 - 3
source/core/NamedObjs.h

@@ -2,8 +2,8 @@
 #ifndef NamedObjsH
 #define NamedObjsH
 
-#include <system.hpp>
-#include <contnrs.hpp>
+#include <System.hpp>
+#include <Contnrs.hpp>
 //---------------------------------------------------------------------------
 class TNamedObjectList;
 class TNamedObject : public TPersistent
@@ -11,7 +11,7 @@ class TNamedObject : public TPersistent
 public:
   __property UnicodeString Name = { read = FName, write = SetName };
   __property bool Hidden = { read = FHidden };
-  __fastcall TNamedObject() {};
+  __fastcall TNamedObject() {}
   bool __fastcall IsSameName(const UnicodeString & Name);
   virtual int __fastcall Compare(TNamedObject * Other);
   __fastcall TNamedObject(UnicodeString aName);

+ 0 - 1
source/core/NeonIntf.cpp

@@ -10,7 +10,6 @@
 #include "Terminal.h"
 #include "Cryptography.h"
 #include <TextsCore.h>
-#define WINSCP
 extern "C"
 {
 #include <ne_redirect.h>

+ 0 - 1
source/core/NeonIntf.h

@@ -2,7 +2,6 @@
 #ifndef NeonIntfH
 #define NeonIntfH
 //---------------------------------------------------------------------------
-#define WINSCP
 #include <ne_uri.h>
 #include <ne_session.h>
 #include <SessionData.h>

+ 10 - 9
source/core/PuttyIntf.cpp

@@ -15,9 +15,9 @@ char sshver[50];
 extern const char commitid[] = "";
 const bool platform_uses_x11_unix_by_default = true;
 CRITICAL_SECTION putty_section;
-bool SaveRandomSeed;
-bool HadRandomSeed;
-char appname_[50];
+static bool SaveRandomSeed;
+static bool HadRandomSeed;
+static char appname_[50];
 const char *const appname = appname_;
 extern const bool share_can_be_downstream = false;
 extern const bool share_can_be_upstream = false;
@@ -320,6 +320,7 @@ const SeatDialogPromptDescriptions * prompt_descriptions(Seat *)
         /*.hk_connect_once_action =*/ "",
         /*.hk_cancel_action =*/ "",
         /*.hk_cancel_action_Participle =*/ "",
+        NULL, NULL,
     };
     return &descs;
 }
@@ -470,8 +471,8 @@ THierarchicalStorage * PuttyStorage = NULL;
 enum TPuttyRegistryMode { prmPass, prmRedirect, prmCollect, prmFail };
 static TPuttyRegistryMode PuttyRegistryMode = prmRedirect;
 typedef std::map<UnicodeString, unsigned long> TPuttyRegistryTypes;
-TPuttyRegistryTypes PuttyRegistryTypes;
-HKEY RandSeedFileStorage = reinterpret_cast<HKEY>(1);
+static TPuttyRegistryTypes PuttyRegistryTypes;
+static HKEY RandSeedFileStorage = reinterpret_cast<HKEY>(1);
 //---------------------------------------------------------------------------
 int reg_override_winscp()
 {
@@ -505,7 +506,7 @@ HKEY open_regkey_fn_winscp(bool Create, bool Write, HKEY Key, const char * Path,
   }
   else if (PuttyRegistryMode == prmFail)
   {
-    Result = false;
+    Result = reinterpret_cast<HKEY>(false);
   }
   else if (PuttyRegistryMode == prmRedirect)
   {
@@ -1354,7 +1355,7 @@ struct TCipherGroup
   int CipherGroup;
   const ssh2_ciphers * Cipher;
 };
-TCipherGroup Ciphers[] =
+static TCipherGroup Ciphers[] =
   {
     { CIPHER_AES, &ssh2_aes },
     { CIPHER_CHACHA20, &ssh2_ccp },
@@ -1464,7 +1465,7 @@ TStrings * SshHostKeyList()
 TStrings * SshMacList()
 {
   std::unique_ptr<TStrings> Result(new TStringList());
-  const struct ssh2_macalg ** Macs = NULL;
+  const struct ssh2_macalg * const * Macs = NULL;
   int Count = 0;
   get_macs(&Count, &Macs);
 
@@ -1540,7 +1541,7 @@ void WritePuttySettings(THierarchicalStorage * Storage, const UnicodeString & AS
     if (IType != PuttyRegistryTypes.end())
     {
       UnicodeString Value = Settings->ValueFromIndex[Index];
-      int I;
+      int I = 0; // shut up
       if (IType->second == REG_SZ)
       {
         Storage->WriteStringRaw(Name, Value);

+ 16 - 19
source/core/Queue.cpp

@@ -40,7 +40,7 @@ public:
   {
   }
 
-  virtual void __fastcall Execute(void * Arg)
+  virtual void __fastcall Execute(void *)
   {
     if (OnNotify != NULL)
     {
@@ -60,7 +60,7 @@ public:
   {
   }
 
-  virtual void __fastcall Execute(void * Arg)
+  virtual void __fastcall Execute(void *)
   {
     if (OnInformation != NULL)
     {
@@ -168,7 +168,7 @@ public:
   {
   }
 
-  virtual void __fastcall Execute(void * Arg)
+  virtual void __fastcall Execute(void *)
   {
     if (OnDisplayBanner != NULL)
     {
@@ -193,7 +193,7 @@ public:
   {
   }
 
-  virtual void __fastcall Execute(void * Arg)
+  virtual void __fastcall Execute(void *)
   {
     if (OnReadDirectory != NULL)
     {
@@ -214,7 +214,7 @@ public:
   {
   }
 
-  virtual void __fastcall Execute(void * Arg)
+  virtual void __fastcall Execute(void *)
   {
     if (OnReadDirectoryProgress != NULL)
     {
@@ -351,7 +351,7 @@ void __fastcall TSimpleThread::WaitFor(unsigned int Milliseconds)
 //---------------------------------------------------------------------------
 __fastcall TSignalThread::TSignalThread(bool LowPriority, HANDLE Event) :
   TSimpleThread(),
-  FTerminated(true), FEvent(NULL)
+  FEvent(NULL), FTerminated(true)
 {
   if (Event == NULL)
   {
@@ -434,11 +434,9 @@ void __fastcall TSignalThread::Terminate()
 //---------------------------------------------------------------------------
 __fastcall TTerminalQueue::TTerminalQueue(TTerminal * Terminal,
   TConfiguration * Configuration) :
-  TSignalThread(true),
-  FTerminal(Terminal), FTransfersLimit(2), FKeepDoneItemsFor(0), FEnabled(true),
-  FConfiguration(Configuration), FSessionData(NULL), FItems(NULL), FDoneItems(NULL),
-  FTerminals(NULL), FItemsSection(NULL), FFreeTerminals(0),
-  FItemsInProcess(0), FTemporaryTerminals(0), FOverallTerminals(0)
+  TSignalThread(true), FTerminal(Terminal), FConfiguration(Configuration), FSessionData(NULL), FItems(NULL), FDoneItems(NULL),
+  FItemsInProcess(0), FItemsSection(NULL), FFreeTerminals(0), FTerminals(NULL), FTemporaryTerminals(0),
+  FOverallTerminals(0), FTransfersLimit(2), FKeepDoneItemsFor(0), FEnabled(true)
 {
   FOnQueryUser = NULL;
   FOnPromptUser = NULL;
@@ -755,7 +753,7 @@ bool __fastcall TTerminalQueue::ItemProcessUserAction(TQueueItem * Item, void *
   bool Result = !FFinished;
   if (Result)
   {
-    TTerminalItem * TerminalItem;
+    TTerminalItem * TerminalItem = NULL; // shut up
 
     {
       TGuard Guard(FItemsSection);
@@ -905,7 +903,7 @@ bool __fastcall TTerminalQueue::ItemPause(TQueueItem * Item, bool Pause)
   bool Result = !FFinished;
   if (Result)
   {
-    TTerminalItem * TerminalItem;
+    TTerminalItem * TerminalItem = NULL; // shut up
 
     {
       TGuard Guard(FItemsSection);
@@ -1617,8 +1615,8 @@ bool TTerminalItem::IsCancelled()
 // TQueueItem
 //---------------------------------------------------------------------------
 __fastcall TQueueItem::TQueueItem() :
-  FStatus(qsPending), FTerminalItem(NULL), FSection(NULL), FProgressData(NULL),
-  FQueue(NULL), FInfo(NULL), FCompleteEvent(INVALID_HANDLE_VALUE),
+  FStatus(qsPending), FSection(NULL), FTerminalItem(NULL), FProgressData(NULL),
+  FInfo(NULL), FQueue(NULL), FCompleteEvent(INVALID_HANDLE_VALUE),
   FCPSLimit(-1)
 {
   FSection = new TCriticalSection();
@@ -1794,9 +1792,8 @@ UnicodeString __fastcall TQueueItem::StartupDirectory() const
 //---------------------------------------------------------------------------
 __fastcall TQueueItemProxy::TQueueItemProxy(TTerminalQueue * Queue,
   TQueueItem * QueueItem) :
-  FQueue(Queue), FQueueItem(QueueItem), FProgressData(NULL),
-  FQueueStatus(NULL), FInfo(NULL),
-  FProcessingUserAction(false), FUserData(NULL)
+  UserData(NULL), FProgressData(NULL), FQueue(Queue), FQueueItem(QueueItem),
+  FQueueStatus(NULL), FInfo(NULL), FProcessingUserAction(false)
 {
   FProgressData = new TFileOperationProgressType();
   FInfo = new TQueueItem::TInfo();
@@ -2276,7 +2273,7 @@ bool __fastcall TTransferQueueItem::UpdateFileList(TQueueFileList * FileList)
 static void ExtractLocalSourcePath(TStrings * Files, UnicodeString & Path)
 {
   ExtractCommonPath(Files, Path);
-  // this way the trailing backslash is preserved for root directories like D:\\
+  // this way the trailing backslash is preserved for root directories like "D:\"
   Path = ExtractFileDir(IncludeTrailingBackslash(Path));
 }
 //---------------------------------------------------------------------------

+ 3 - 2
source/core/Queue.h

@@ -54,6 +54,7 @@ class TTerminalQueue;
 class TQueueItemProxy;
 class TTerminalQueueStatus;
 class TQueueFileList;
+class TTerminalItem;
 //---------------------------------------------------------------------------
 typedef void __fastcall (__closure * TQueueListUpdate)
   (TTerminalQueue * Queue);
@@ -240,7 +241,8 @@ public:
   __property TQueueItem::TStatus Status = { read = FStatus };
   __property bool ProcessingUserAction = { read = FProcessingUserAction };
   __property int Index = { read = GetIndex };
-  __property void * UserData = { read = FUserData, write = FUserData };
+  // Clang warns on property backed by private field which is never used
+  void * UserData;
 
 private:
   TFileOperationProgressType * FProgressData;
@@ -250,7 +252,6 @@ private:
   TTerminalQueueStatus * FQueueStatus;
   TQueueItem::TInfo * FInfo;
   bool FProcessingUserAction;
-  void * FUserData;
 
   __fastcall TQueueItemProxy(TTerminalQueue * Queue, TQueueItem * QueueItem);
   virtual __fastcall ~TQueueItemProxy();

+ 4 - 6
source/core/RemoteFiles.cpp

@@ -745,13 +745,11 @@ void __fastcall TRemoteTokenList::Add(const TRemoteToken & Token)
   FTokens.push_back(Token);
   if (Token.IDValid)
   {
-    std::pair<TIDMap::iterator, bool> Position =
-      FIDMap.insert(TIDMap::value_type(Token.ID, FTokens.size() - 1));
+    FIDMap.insert(TIDMap::value_type(Token.ID, FTokens.size() - 1));
   }
   if (Token.NameValid)
   {
-    std::pair<TNameMap::iterator, bool> Position =
-      FNameMap.insert(TNameMap::value_type(Token.Name, FTokens.size() - 1));
+    FNameMap.insert(TNameMap::value_type(Token.Name, FTokens.size() - 1));
   }
 }
 //---------------------------------------------------------------------------
@@ -2859,7 +2857,7 @@ void __fastcall TRemoteProperties::Save(THierarchicalStorage * Storage) const
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 TSynchronizeChecklist::TItem::TItem() :
-  Action(saNone), IsDirectory(false), RemoteFile(NULL), Checked(true), ImageIndex(-1), FDirectoryHasSize(false)
+  Action(saNone), IsDirectory(false), ImageIndex(-1), Checked(true), RemoteFile(NULL), FDirectoryHasSize(false)
 {
   Local.ModificationFmt = mfFull;
   Local.Modification = 0;
@@ -3223,7 +3221,7 @@ int TSynchronizeProgress::Progress(const TFileOperationProgressType * CurrentIte
     __int64 Processed = GetProcessed(CurrentItemOperationProgress);
     if (FTotalSize > 0)
     {
-      Result = (Processed * 100) / FTotalSize;
+      Result = static_cast<int>((Processed * 100) / FTotalSize);
     }
     else
     {

+ 18 - 15
source/core/S3FileSystem.cpp

@@ -3,7 +3,6 @@
 #pragma hdrstop
 
 #define NE_LFS
-#define WINSCP
 #define NEED_LIBS3
 
 #include "S3FileSystem.h"
@@ -52,7 +51,7 @@
 //---------------------------------------------------------------------------
 static std::unique_ptr<TCriticalSection> LibS3Section(TraceInitPtr(new TCriticalSection()));
 //---------------------------------------------------------------------------
-UTF8String LibS3Delimiter(L"/");
+static UTF8String LibS3Delimiter(L"/");
 //---------------------------------------------------------------------------
 UnicodeString __fastcall S3LibVersion()
 {
@@ -103,19 +102,19 @@ static void NeedS3Config(
   }
 }
 //---------------------------------------------------------------------------
-UnicodeString S3CredentialsFileName;
-TDateTime S3CredentialsTimestamp;
-std::unique_ptr<TCustomIniFile> S3CredentialsFile;
-UnicodeString S3ConfigFileName;
-TDateTime S3ConfigTimestamp;
-std::unique_ptr<TCustomIniFile> S3ConfigFile;
-UnicodeString S3Profile;
-bool S3SecurityProfileChecked = false;
-TDateTime S3CredentialsExpiration;
-UnicodeString S3SessionToken;
-UnicodeString S3SecurityProfile;
+static UnicodeString S3CredentialsFileName;
+static TDateTime S3CredentialsTimestamp;
+static std::unique_ptr<TCustomIniFile> S3CredentialsFile;
+static UnicodeString S3ConfigFileName;
+static TDateTime S3ConfigTimestamp;
+static std::unique_ptr<TCustomIniFile> S3ConfigFile;
+static UnicodeString S3Profile;
+static bool S3SecurityProfileChecked = false;
+static TDateTime S3CredentialsExpiration;
+static UnicodeString S3SessionToken;
+static UnicodeString S3SecurityProfile;
 typedef std::map<UnicodeString, UnicodeString> TS3Credentials;
-TS3Credentials S3Credentials;
+static TS3Credentials S3Credentials;
 //---------------------------------------------------------------------------
 static void NeedS3Config()
 {
@@ -1807,6 +1806,7 @@ void __fastcall TS3FileSystem::CreateDirectory(const UnicodeString & ADirName, b
 void __fastcall TS3FileSystem::CreateLink(const UnicodeString FileName,
   const UnicodeString PointTo, bool /*Symbolic*/)
 {
+  DebugUsedParam2(FileName, PointTo);
   DebugFail();
 }
 //---------------------------------------------------------------------------
@@ -2259,12 +2259,14 @@ void __fastcall TS3FileSystem::CalculateFilesChecksum(
 void __fastcall TS3FileSystem::CustomCommandOnFile(const UnicodeString FileName,
   const TRemoteFile * /*File*/, UnicodeString Command, int /*Params*/, TCaptureOutputEvent /*OutputEvent*/)
 {
+  DebugUsedParam2(FileName, Command);
   DebugFail();
 }
 //---------------------------------------------------------------------------
 void __fastcall TS3FileSystem::AnyCommand(const UnicodeString Command,
   TCaptureOutputEvent /*OutputEvent*/)
 {
+  DebugUsedParam(Command);
   DebugFail();
 }
 //---------------------------------------------------------------------------
@@ -2276,6 +2278,7 @@ TStrings * __fastcall TS3FileSystem::GetFixedPaths()
 void __fastcall TS3FileSystem::SpaceAvailable(const UnicodeString Path,
   TSpaceAvailable & /*ASpaceAvailable*/)
 {
+  DebugUsedParam(Path);
   DebugFail();
 }
 //---------------------------------------------------------------------------
@@ -2645,7 +2648,7 @@ void __fastcall TS3FileSystem::Source(
       MultipartUploadId = RawByteString();
     }
   }
-  catch (Exception & E)
+  catch (Exception &)
   {
     if (!MultipartUploadId.IsEmpty())
     {

+ 13 - 10
source/core/ScpFileSystem.cpp

@@ -759,7 +759,7 @@ void __fastcall TSCPFileSystem::DetectUtf()
           FSecureShell->UtfStrings = true;
         }
       }
-      catch (Exception & E)
+      catch (Exception &)
       {
         // ignore non-fatal errors
         if (!FTerminal->Active)
@@ -835,12 +835,12 @@ void __fastcall TSCPFileSystem::DetectReturnVar()
           Abort();
         }
       }
-      catch (EFatal &E)
+      catch (EFatal &)
       {
         // if fatal error occurs, we need to exit ...
         throw;
       }
-      catch (Exception &E)
+      catch (Exception &)
       {
         // ...otherwise, we will try next variable (if any)
         Success = false;
@@ -1205,7 +1205,7 @@ void __fastcall TSCPFileSystem::CopyFile(
   {
     ExecCommand(fsCopyFile, ARRAYOFCONST((AdditionalSwitches, DelimitedFileName, DelimitedNewName)));
   }
-  catch (Exception & E)
+  catch (Exception &)
   {
     if (FTerminal->Active)
     {
@@ -1420,7 +1420,7 @@ void __fastcall TSCPFileSystem::CalculateFilesChecksum(
           BatchChecksums->Add(Checksum);
         }
       }
-      catch (Exception & E)
+      catch (Exception &)
       {
         if (!FTerminal->Active)
         {
@@ -1574,6 +1574,7 @@ void __fastcall TSCPFileSystem::SpaceAvailable(const UnicodeString Path,
   TSpaceAvailable & /*ASpaceAvailable*/)
 {
   DebugFail();
+  DebugUsedParam(Path);
 }
 //---------------------------------------------------------------------------
 // transfer protocol
@@ -1791,6 +1792,7 @@ void __fastcall TSCPFileSystem::CopyToRemote(TStrings * FilesToCopy,
               break;
 
             default:
+              CanProceed = false; // shut up
               DebugFail();
               break;
           }
@@ -2114,13 +2116,13 @@ void __fastcall TSCPFileSystem::SCPSource(const UnicodeString FileName,
         // side already know, that file transfer finished, even if it failed
         // so we don't have to throw EFatal
       }
-      catch (EScp &E)
+      catch (EScp &)
       {
         // SCP protocol fatal error
         OperationProgress->SetTransferringFile(false);
         throw;
       }
-      catch (EScpFileSkipped &E)
+      catch (EScpFileSkipped &)
       {
         // SCP protocol non-fatal error
         OperationProgress->SetTransferringFile(false);
@@ -2356,7 +2358,7 @@ void __fastcall TSCPFileSystem::CopyToLocal(TStrings * FilesToCopy,
               FTerminal->ExceptionOnFail = false;
             }
           }
-          catch (EFatal &E)
+          catch (EFatal &)
           {
             throw;
           }
@@ -2434,6 +2436,7 @@ void __fastcall TSCPFileSystem::SCPError(const UnicodeString Message, bool Fatal
 //---------------------------------------------------------------------------
 void __fastcall TSCPFileSystem::SCPSendError(const UnicodeString Message, bool Fatal)
 {
+  DebugUsedParam(Message);
   unsigned char ErrorLevel = (char)(Fatal ? 2 : 1);
   FTerminal->LogEvent(FORMAT(L"Sending SCP error (%d) to remote side:",
     ((int)ErrorLevel)));
@@ -2783,12 +2786,12 @@ void __fastcall TSCPFileSystem::SCPSink(const UnicodeString TargetDir,
                 // If one of following exception occurs, we still need
                 // to send confirmation to other side
               }
-              catch (EScp &E)
+              catch (EScp &)
               {
                 FSecureShell->SendNull();
                 throw;
               }
-              catch (EScpFileSkipped &E)
+              catch (EScpFileSkipped &)
               {
                 FSecureShell->SendNull();
                 throw;

+ 3 - 3
source/core/Script.cpp

@@ -473,7 +473,7 @@ void __fastcall TScript::LogPendingLines(TTerminal * ATerminal)
     for (int Index = 0; Index < FPendingLogLines->Count; Index++)
     {
       ATerminal->Log->Add(
-        reinterpret_cast<TLogLineType>(FPendingLogLines->Objects[Index]),
+        static_cast<TLogLineType>(reinterpret_cast<uintptr_t>(FPendingLogLines->Objects[Index])),
         FPendingLogLines->Strings[Index]);
     }
     FPendingLogLines->Clear();
@@ -2456,7 +2456,7 @@ void __fastcall TManagementScript::TerminalOperationProgress(
         UnicodeString ProgressMessage = FORMAT(L"%-*s | %14s | %6.1f KB/s | %-6.6s | %3d%%",
           (Configuration->ScriptProgressFileNameLimit, FileName,
            TransferredSizeStr,
-           static_cast<float>(ProgressData.CPS()) / 1024,
+           static_cast<long double>(ProgressData.CPS()) / 1024,
            ProgressData.AsciiTransfer ? L"ascii" : L"binary",
            ProgressData.TransferProgress()));
         if (FLastProgressMessage != ProgressMessage)
@@ -3070,7 +3070,7 @@ void __fastcall TManagementScript::LLsProc(TScriptProcParams * Parameters)
         }
         else
         {
-          SizeStr = FORMAT(L"%14.0n", (double(SearchRec.Size)));
+          SizeStr = FORMAT(L"%14.0n", (static_cast<long double>(SearchRec.Size)));
         }
         PrintLine(FORMAT(L"%-*s  %-*s    %-14s %s", (
           DateLen, DateStr, TimeLen, TimeStr, SizeStr, SearchRec.Name)));

+ 2 - 2
source/core/SecureShell.cpp

@@ -197,7 +197,7 @@ Conf * __fastcall TSecureShell::StoreToConfig(TSessionData * Data, bool Simple)
       case cipArcfour: pcipher = CIPHER_ARCFOUR; break;
       case cipChaCha20: pcipher = CIPHER_CHACHA20; break;
       case cipAESGCM: pcipher = CIPHER_AESGCM; break;
-      default: DebugFail();
+      default: DebugFail(); pcipher = NULL; // shut up
     }
     conf_set_int_int(conf, CONF_ssh_cipherlist, c, pcipher);
   }
@@ -220,7 +220,7 @@ Conf * __fastcall TSecureShell::StoreToConfig(TSessionData * Data, bool Simple)
       case kexNTRUHybrid: pkex = KEX_NTRU_HYBRID; break;
       case kexMLKEM25519Hybrid: pkex = KEX_MLKEM_25519_HYBRID; break;
       case kexMLKEMNISTHybrid: pkex = KEX_MLKEM_NIST_HYBRID; break;
-      default: DebugFail();
+      default: DebugFail(); pkex = NULL; // shutup
     }
     conf_set_int_int(conf, CONF_ssh_kexlist, k, pkex);
   }

+ 1 - 1
source/core/Security.cpp

@@ -11,7 +11,7 @@
 #define PWALG_SIMPLE_INTERNAL 0x00
 #define PWALG_SIMPLE_EXTERNAL 0x01
 #define PWALG_SIMPLE_INTERNAL2 0x02
-RawByteString PWALG_SIMPLE_STRING("0123456789ABCDEF");
+static RawByteString PWALG_SIMPLE_STRING("0123456789ABCDEF");
 //---------------------------------------------------------------------------
 RawByteString SimpleEncryptChar(unsigned char Ch)
 {

+ 9 - 8
source/core/SessionData.cpp

@@ -11,7 +11,7 @@
 #include "TextsCore.h"
 #include "PuttyIntf.h"
 #include "RemoteFiles.h"
-#include "SFTPFileSystem.h"
+#include "SftpFileSystem.h"
 #include "S3FileSystem.h"
 #include "FileMasks.h"
 #include <Soap.EncdDecd.hpp>
@@ -31,8 +31,8 @@
 const wchar_t * PingTypeNames = L"Off;Null;Dummy";
 const wchar_t * FtpPingTypeNames = L"Off;Dummy;Dummy;List";
 const wchar_t * ProxyMethodNames = L"None;SOCKS4;SOCKS5;HTTP;Telnet;Cmd";
-TIntMapping ProxyMethodMapping = CreateIntMappingFromEnumNames(LowerCase(ProxyMethodNames));
-const wchar_t * DefaultName = L"Default Settings";
+static TIntMapping ProxyMethodMapping = CreateIntMappingFromEnumNames(LowerCase(ProxyMethodNames));
+static const wchar_t * DefaultName = L"Default Settings";
 const UnicodeString CipherNames[CIPHER_COUNT] = {L"WARN", L"3des", L"blowfish", L"aes", L"des", L"arcfour", L"chacha20", "aesgcm"};
 const UnicodeString KexNames[KEX_COUNT] = {L"WARN", L"dh-group1-sha1", L"dh-group14-sha1", L"dh-group15-sha512", L"dh-group16-sha512", L"dh-group17-sha512", L"dh-group18-sha512", L"dh-gex-sha1", L"rsa", L"ecdh", L"ntru-curve25519", L"mlkem-curve25519", L"mlkem-nist"};
 const UnicodeString HostKeyNames[HOSTKEY_COUNT] = {L"WARN", L"rsa", L"dsa", L"ecdsa", L"ed25519", L"ed448"};
@@ -2155,8 +2155,8 @@ bool __fastcall TSessionData::ParseUrl(UnicodeString Url, TOptions * Options,
 {
   bool ProtocolDefined = true;
   bool PortNumberDefined = false;
-  TFSProtocol AFSProtocol;
-  int DefaultProtocolPortNumber;
+  TFSProtocol AFSProtocol = TFSProtocol(); // shut up
+  int DefaultProtocolPortNumber = 0; // shut up
   TFtps AFtps = ftpsNone;
   int ProtocolLen = 0;
   bool HttpForWebdav = FLAGCLEAR(Flags, pufPreferProtocol) || (FSProtocol != fsS3);
@@ -2699,6 +2699,7 @@ void __fastcall TSessionData::ExpandEnvironmentVariables()
 //---------------------------------------------------------------------
 void __fastcall TSessionData::ValidatePath(const UnicodeString Path)
 {
+  DebugUsedParam(Path);
   // noop
 }
 //---------------------------------------------------------------------
@@ -3324,7 +3325,7 @@ void __fastcall TSessionData::SetFSProtocol(TFSProtocol value)
 //---------------------------------------------------------------------
 UnicodeString __fastcall TSessionData::GetFSProtocolStr()
 {
-  DebugAssert(FSProtocol >= 0 && FSProtocol < FSPROTOCOL_COUNT);
+  DebugAssert(FSProtocol >= 0 && static_cast<int>(FSProtocol) < FSPROTOCOL_COUNT);
   return FSProtocolNames[FSProtocol];
 }
 //---------------------------------------------------------------------------
@@ -3709,7 +3710,7 @@ UnicodeString __fastcall TSessionData::GenerateSessionUrl(unsigned int Flags)
   return Url;
 }
 //---------------------------------------------------------------------
-UnicodeString ScriptCommandOpenLink(TraceInitStr(ScriptCommandLink(L"open")));
+static UnicodeString ScriptCommandOpenLink(TraceInitStr(ScriptCommandLink(L"open")));
 //---------------------------------------------------------------------
 void __fastcall TSessionData::AddSwitch(
   UnicodeString & Result, const UnicodeString & Name, bool Rtf)
@@ -3822,7 +3823,7 @@ UnicodeString __fastcall TSessionData::GenerateOpenCommandArgs(bool Rtf)
   return Result;
 }
 //---------------------------------------------------------------------
-UnicodeString SessionOptionsClassName(L"SessionOptions");
+static UnicodeString SessionOptionsClassName(L"SessionOptions");
 //---------------------------------------------------------------------
 void __fastcall TSessionData::AddAssemblyProperty(
   UnicodeString & Result, TAssemblyLanguage Language,

+ 1 - 1
source/core/SessionInfo.cpp

@@ -794,7 +794,7 @@ FILE * __fastcall OpenFile(UnicodeString LogFileName, TDateTime Started, TSessio
 }
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
-const wchar_t *LogLineMarks = L"<>!.*";
+static const wchar_t *LogLineMarks = L"<>!.*";
 __fastcall TSessionLog::TSessionLog(TSessionUI* UI, TDateTime Started, TSessionData * SessionData,
   TConfiguration * Configuration)
 {

+ 33 - 32
source/core/SftpFileSystem.cpp

@@ -57,13 +57,11 @@
 #define SSH_FXP_ATTRS              105
 #define SSH_FXP_EXTENDED           200
 #define SSH_FXP_EXTENDED_REPLY     201
-#define SSH_FXP_ATTRS              105
 
 #define SSH_FILEXFER_ATTR_SIZE              0x00000001
 #define SSH_FILEXFER_ATTR_UIDGID            0x00000002
 #define SSH_FILEXFER_ATTR_PERMISSIONS       0x00000004
 #define SSH_FILEXFER_ATTR_ACMODTIME         0x00000008
-#define SSH_FILEXFER_ATTR_EXTENDED          0x80000000
 #define SSH_FILEXFER_ATTR_ACCESSTIME        0x00000008
 #define SSH_FILEXFER_ATTR_CREATETIME        0x00000010
 #define SSH_FILEXFER_ATTR_MODIFYTIME        0x00000020
@@ -86,9 +84,9 @@
 
 #define SSH_FILEXFER_TYPE_REGULAR          1
 #define SSH_FILEXFER_TYPE_DIRECTORY        2
-#define SSH_FILEXFER_TYPE_SYMLINK          3
-#define SSH_FILEXFER_TYPE_SPECIAL          4
-#define SSH_FILEXFER_TYPE_UNKNOWN          5
+//      SSH_FILEXFER_TYPE_SYMLINK          3
+//      SSH_FILEXFER_TYPE_SPECIAL          4
+//      SSH_FILEXFER_TYPE_UNKNOWN          5
 
 #define SSH_FXF_READ            0x00000001
 #define SSH_FXF_WRITE           0x00000002
@@ -98,37 +96,37 @@
 #define SSH_FXF_EXCL            0x00000020
 #define SSH_FXF_TEXT            0x00000040
 
-#define SSH_FXF_ACCESS_DISPOSITION        0x00000007
+//      SSH_FXF_ACCESS_DISPOSITION        0x00000007
 #define     SSH_FXF_CREATE_NEW            0x00000000
 #define     SSH_FXF_CREATE_TRUNCATE       0x00000001
 #define     SSH_FXF_OPEN_EXISTING         0x00000002
 #define     SSH_FXF_OPEN_OR_CREATE        0x00000003
-#define     SSH_FXF_TRUNCATE_EXISTING     0x00000004
+//          SSH_FXF_TRUNCATE_EXISTING     0x00000004
 #define SSH_FXF_ACCESS_APPEND_DATA        0x00000008
-#define SSH_FXF_ACCESS_APPEND_DATA_ATOMIC 0x00000010
+//      SSH_FXF_ACCESS_APPEND_DATA_ATOMIC 0x00000010
 #define SSH_FXF_ACCESS_TEXT_MODE          0x00000020
 
 #define ACE4_READ_DATA         0x00000001
-#define ACE4_LIST_DIRECTORY    0x00000001
+//      ACE4_LIST_DIRECTORY    0x00000001
 #define ACE4_WRITE_DATA        0x00000002
-#define ACE4_ADD_FILE          0x00000002
+//      ACE4_ADD_FILE          0x00000002
 #define ACE4_APPEND_DATA       0x00000004
-#define ACE4_ADD_SUBDIRECTORY  0x00000004
-#define ACE4_READ_NAMED_ATTRS  0x00000008
-#define ACE4_WRITE_NAMED_ATTRS 0x00000010
-#define ACE4_EXECUTE           0x00000020
-#define ACE4_DELETE_CHILD      0x00000040
-#define ACE4_READ_ATTRIBUTES   0x00000080
-#define ACE4_WRITE_ATTRIBUTES  0x00000100
-#define ACE4_DELETE            0x00010000
-#define ACE4_READ_ACL          0x00020000
-#define ACE4_WRITE_ACL         0x00040000
-#define ACE4_WRITE_OWNER       0x00080000
-#define ACE4_SYNCHRONIZE       0x00100000
+//      ACE4_ADD_SUBDIRECTORY  0x00000004
+//      ACE4_READ_NAMED_ATTRS  0x00000008
+//      ACE4_WRITE_NAMED_ATTRS 0x00000010
+//      ACE4_EXECUTE           0x00000020
+//      ACE4_DELETE_CHILD      0x00000040
+//      ACE4_READ_ATTRIBUTES   0x00000080
+//      ACE4_WRITE_ATTRIBUTES  0x00000100
+//      ACE4_DELETE            0x00010000
+//      ACE4_READ_ACL          0x00020000
+//      ACE4_WRITE_ACL         0x00040000
+//      ACE4_WRITE_OWNER       0x00080000
+//      ACE4_SYNCHRONIZE       0x00100000
 
 #define SSH_FILEXFER_ATTR_FLAGS_HIDDEN           0x00000004
 
-#define SSH_FXP_REALPATH_NO_CHECK    0x00000001
+//      SSH_FXP_REALPATH_NO_CHECK    0x00000001
 #define SSH_FXP_REALPATH_STAT_IF     0x00000002
 #define SSH_FXP_REALPATH_STAT_ALWAYS 0x00000003
 
@@ -658,7 +656,7 @@ public:
 
       // SSH-2.0-cryptlib returns file type 0 in response to SSH_FXP_LSTAT,
       // handle this undefined value as "unknown"
-      static wchar_t * Types = L"U-DLSUOCBF";
+      static const wchar_t * Types = L"U-DLSUOCBF";
       if (FXType > (unsigned char)wcslen(Types))
       {
         throw Exception(FMTLOAD(SFTP_UNKNOWN_FILE_TYPE, (int(FXType))));
@@ -949,7 +947,7 @@ private:
   TSFTPFileSystem * FReservedBy;
 
   static int FMessageCounter;
-  static const FSendPrefixLen = 4;
+  static const int FSendPrefixLen = 4;
 
   void Init()
   {
@@ -2593,7 +2591,7 @@ int __fastcall TSFTPFileSystem::ReceivePacket(TSFTPPacket * Packet,
 
   int Result = SSH_FX_OK;
   int Reservation = FPacketReservations->IndexOf(Packet);
-  bool NotLogged;
+  bool NotLogged = false; // shut up
 
   if (Reservation < 0 || Packet->Capacity == 0)
   {
@@ -3369,7 +3367,7 @@ void __fastcall TSFTPFileSystem::DoStartup()
       TSFTPPacket Packet(SSH_FXP_EXTENDED);
       Packet.AddString(SFTP_EXT_LIMITS);
       SendPacketAndReceiveResponse(&Packet, &Packet, SSH_FXP_EXTENDED_REPLY);
-      unsigned int MaxPacketSize = std::min(static_cast<__int64>(std::numeric_limits<unsigned long>::max()), Packet.GetInt64());
+      unsigned int MaxPacketSize = static_cast<unsigned int>(std::min(static_cast<__int64>(std::numeric_limits<unsigned int>::max()), Packet.GetInt64()));
       FTerminal->LogEvent(FORMAT(L"Limiting packet size to server's limit of %d + %d bytes",
         (static_cast<int>(MaxPacketSize), static_cast<int>(PacketPayload))));
       FMaxPacketSize = MaxPacketSize + PacketPayload;
@@ -3407,7 +3405,7 @@ void __fastcall TSFTPFileSystem::DoStartup()
 
 }
 //---------------------------------------------------------------------------
-char * __fastcall TSFTPFileSystem::GetEOL() const
+const char * __fastcall TSFTPFileSystem::GetEOL() const
 {
   if (FVersion >= 4)
   {
@@ -3429,7 +3427,7 @@ void __fastcall TSFTPFileSystem::LookupUsersGroups()
 
   TSFTPPacket * Packets[] = { &PacketOwners, &PacketGroups };
   TRemoteTokenList * Lists[] = { &FTerminal->FUsers, &FTerminal->FGroups };
-  wchar_t ListTypes[] = { OGQ_LIST_OWNERS, OGQ_LIST_GROUPS };
+  unsigned char ListTypes[] = { OGQ_LIST_OWNERS, OGQ_LIST_GROUPS };
 
   for (size_t Index = 0; Index < LENOF(Packets); Index++)
   {
@@ -4611,7 +4609,9 @@ bool TSFTPFileSystem::SFTPConfirmResume(const UnicodeString DestFileName,
         break;
 
       case qaCancel:
+      default:
         OperationProgress->SetCancelAtLeast(csCancel);
+        ResumeTransfer = false; // shut up
         Abort();
         break;
     }
@@ -4625,9 +4625,10 @@ bool TSFTPFileSystem::SFTPConfirmResume(const UnicodeString DestFileName,
 //---------------------------------------------------------------------------
 bool __fastcall TSFTPFileSystem::DoesFileLookLikeSymLink(TRemoteFile * File)
 {
+  unsigned short AllInt = static_cast<unsigned short>(TRights::rfAll);
   return
     (FVersion < 4) &&
-    ((*File->Rights & TRights::rfAll) == TRights::rfAll) &&
+    ((*File->Rights & AllInt) == AllInt) &&
     (File->Size < 100);
 }
 //---------------------------------------------------------------------------
@@ -4644,7 +4645,7 @@ void __fastcall TSFTPFileSystem::Source(
   bool DestFileExists = false;
   TRights DestRights;
 
-  __int64 ResumeOffset;
+  __int64 ResumeOffset = 0; // shut up
 
   // should we check for interrupted transfer?
   ResumeAllowed =
@@ -5647,7 +5648,7 @@ void __fastcall TSFTPFileSystem::Sink(
         int GapCount = 0;
         unsigned long Missing = 0;
         unsigned long DataLen = 0;
-        unsigned long BlockSize;
+        unsigned long BlockSize = 0; // shut up
         bool ConvertToken = false;
         TEncryption Encryption(FTerminal->GetEncryptKey());
         bool Decrypt = FTerminal->IsFileEncrypted(FileName);

+ 2 - 2
source/core/SftpFileSystem.h

@@ -5,7 +5,7 @@
 #include <FileSystems.h>
 //---------------------------------------------------------------------------
 class TSFTPPacket;
-class TOverwriteFileParams;
+struct TOverwriteFileParams;
 struct TSFTPSupport;
 class TSecureShell;
 class TEncryption;
@@ -181,7 +181,7 @@ protected:
     TSFTPOverwriteMode & Mode, const TOverwriteFileParams * FileParams);
   bool SFTPConfirmResume(const UnicodeString DestFileName, bool PartialBiggerThanSource,
     TFileOperationProgressType * OperationProgress);
-  char * __fastcall GetEOL() const;
+  const char * __fastcall GetEOL() const;
   inline void __fastcall BusyStart();
   inline void __fastcall BusyEnd();
   inline unsigned long __fastcall TransferBlockSize(

+ 11 - 6
source/core/Terminal.cpp

@@ -341,8 +341,8 @@ private:
 };
 //---------------------------------------------------------------------------
 __fastcall TCallbackGuard::TCallbackGuard(TTerminal * Terminal) :
-  FTerminal(Terminal),
   FFatalError(NULL),
+  FTerminal(Terminal),
   FGuarding(FTerminal->FCallbackGuard == NULL)
 {
   if (FGuarding)
@@ -2090,6 +2090,10 @@ unsigned int __fastcall TTerminal::QueryUserException(const UnicodeString Query,
       delete MoreMessages;
     }
   }
+  else
+  {
+    Result = AbortAnswer(Answers);
+  }
   return Result;
 }
 //---------------------------------------------------------------------------
@@ -3115,7 +3119,7 @@ unsigned int __fastcall TTerminal::ConfirmFileOverwrite(
   TOperationSide Side, const TCopyParamType * CopyParam, int Params, TFileOperationProgressType * OperationProgress,
   UnicodeString Message)
 {
-  unsigned int Result;
+  unsigned int Result = qaCancel; // shut up
   TBatchOverwrite BatchOverwrite;
   bool CanAlternateResume =
     (FileParams != NULL) &&
@@ -5491,7 +5495,7 @@ bool __fastcall TTerminal::DoCreateLocalFile(const UnicodeString FileName,
     {
       // save the error, otherwise it gets overwritten by call to FileExists
       int LastError = GetLastError();
-      int FileAttr;
+      int FileAttr = 0; // shut up
       if (::FileExists(ApiPath(FileName)) &&
         (((FileAttr = FileGetAttrFix(ApiPath(FileName))) & (faReadOnly | faHidden)) != 0))
       {
@@ -6341,7 +6345,7 @@ bool TTerminal::SameFileChecksum(const UnicodeString & LocalFileName, const TRem
   }
 
   std::unique_ptr<TStrings> FileList(new TStringList());
-  FileList->AddObject(File->FullFileName, File);
+  FileList->AddObject(File->FullFileName, const_cast<TRemoteFile *>(File));
   DebugAssert(FCollectedCalculatedChecksum.IsEmpty());
   FCollectedCalculatedChecksum = EmptyStr;
   CalculateFilesChecksum(Alg, FileList.get(), CollectCalculatedChecksum);
@@ -6362,6 +6366,7 @@ bool TTerminal::SameFileChecksum(const UnicodeString & LocalFileName, const TRem
 void __fastcall TTerminal::DoSynchronizeCollectFile(const UnicodeString FileName,
   const TRemoteFile * File, /*TSynchronizeData*/ void * Param)
 {
+  DebugUsedParam(FileName);
   TSynchronizeData * Data = static_cast<TSynchronizeData *>(Param);
 
   // Can be NULL in scripting
@@ -8806,7 +8811,7 @@ TTerminal::TEncryptedFileNames::const_iterator __fastcall TTerminal::GetEncrypte
     {
       delete DoReadDirectoryListing(FileDir, true);
     }
-    catch (Exception & E)
+    catch (Exception &)
     {
       if (!Active)
       {
@@ -8919,7 +8924,7 @@ TRemoteFile * TTerminal::CheckRights(const UnicodeString & EntryType, const Unic
       LogEvent(FORMAT(L"%s \"%s\" exists and has correct permissions %s.", (EntryType, FileName, File->Rights->Octal)));
     }
   }
-  catch (Exception & E)
+  catch (Exception &)
   {
   }
   return File.release();

+ 1 - 1
source/core/Terminal.h

@@ -654,7 +654,7 @@ public:
 
   const TSessionInfo & __fastcall GetSessionInfo();
   const TFileSystemInfo & __fastcall GetFileSystemInfo(bool Retrieve = false);
-  void __fastcall inline LogEvent(const UnicodeString & Str);
+  void __fastcall LogEvent(const UnicodeString & Str);
   void __fastcall LogEvent(int Level, const UnicodeString & Str);
   void __fastcall GetSupportedChecksumAlgs(TStrings * Algs);
   UnicodeString __fastcall ChangeFileName(const TCopyParamType * CopyParam,

+ 1 - 1
source/core/Usage.cpp

@@ -336,5 +336,5 @@ void __fastcall TUsage::Serialize(
 int __fastcall TUsage::CalculateCounterSize(__int64 Size)
 {
   const int SizeCounterFactor = 10240;
-  return (Size <= 0) ? 0 : (Size < SizeCounterFactor ? 1 : Size / SizeCounterFactor);
+  return (Size <= 0) ? 0 : (Size < SizeCounterFactor ? 1 : static_cast<int>(Size / SizeCounterFactor));
 }

+ 11 - 7
source/core/WebDAVFileSystem.cpp

@@ -7,7 +7,6 @@
 #include <wincrypt.h>
 
 #define NE_LFS
-#define WINSCP
 #include <ne_basic.h>
 #include <ne_auth.h>
 #include <ne_props.h>
@@ -157,12 +156,12 @@ TWebDAVFileSystem::TWebDAVFileSystem(TTerminal * ATerminal) :
   TCustomFileSystem(ATerminal),
   FActive(false),
   FHasTrailingSlash(false),
-  FSessionContext(NULL),
-  FNeonLockStore(NULL),
-  FNeonLockStoreSection(new TCriticalSection()),
   FUploading(false),
   FDownloading(false),
+  FNeonLockStore(NULL),
+  FNeonLockStoreSection(new TCriticalSection()),
   FInitialHandshake(false),
+  FSessionContext(NULL),
   FIgnoreAuthenticationFailure(iafNo)
 {
   FFileSystemInfo.ProtocolBaseName = CONST_WEBDAV_PROTOCOL_BASE_NAME;
@@ -372,7 +371,7 @@ TWebDAVFileSystem::TSessionContext * TWebDAVFileSystem::NeonOpen(const UnicodeSt
 //---------------------------------------------------------------------------
 bool TWebDAVFileSystem::IsTlsSession(ne_session * Session)
 {
-  ne_uri uri = {0};
+  ne_uri uri = ne_uri();
   ne_fill_server_uri(Session, &uri);
   bool Result = IsTlsUri(uri);
   ne_uri_free(&uri);
@@ -1114,7 +1113,7 @@ void __fastcall TWebDAVFileSystem::ParsePropResultSet(TRemoteFile * File,
     if (IsWin8())
     {
       // The "lock" character is supported since Windows 8
-      LockRights = L"\uD83D\uDD12" + Owner;
+      LockRights = U"\U0001F512" + Owner;
     }
     else
     {
@@ -1166,6 +1165,7 @@ void __fastcall TWebDAVFileSystem::CustomReadFile(UnicodeString FileName,
 void __fastcall TWebDAVFileSystem::DeleteFile(const UnicodeString FileName,
   const TRemoteFile * File, int /*Params*/, TRmSessionAction & Action)
 {
+  DebugUsedParam(FileName);
   Action.Recursive();
   ClearNeonError();
   TOperationVisualizer Visualizer(FTerminal->UseBusyCursor);
@@ -1236,6 +1236,7 @@ void __fastcall TWebDAVFileSystem::CreateLink(const UnicodeString FileName,
   const UnicodeString PointTo, bool /*Symbolic*/)
 {
   DebugFail();
+  DebugUsedParam2(FileName, PointTo);
 }
 //---------------------------------------------------------------------------
 void __fastcall TWebDAVFileSystem::ChangeFileProperties(const UnicodeString FileName,
@@ -1243,6 +1244,7 @@ void __fastcall TWebDAVFileSystem::ChangeFileProperties(const UnicodeString File
   TChmodSessionAction & /*Action*/)
 {
   DebugFail();
+  DebugUsedParam(FileName);
 }
 //---------------------------------------------------------------------------
 bool __fastcall TWebDAVFileSystem::LoadFilesProperties(TStrings * /*FileList*/)
@@ -1311,12 +1313,14 @@ void __fastcall TWebDAVFileSystem::CustomCommandOnFile(const UnicodeString FileN
   const TRemoteFile * /*File*/, UnicodeString Command, int /*Params*/, TCaptureOutputEvent /*OutputEvent*/)
 {
   DebugFail();
+  DebugUsedParam2(FileName, Command);
 }
 //---------------------------------------------------------------------------
 void __fastcall TWebDAVFileSystem::AnyCommand(const UnicodeString Command,
   TCaptureOutputEvent /*OutputEvent*/)
 {
   DebugFail();
+  DebugUsedParam(Command);
 }
 //---------------------------------------------------------------------------
 TStrings * __fastcall TWebDAVFileSystem::GetFixedPaths()
@@ -2173,7 +2177,7 @@ void TWebDAVFileSystem::LockResult(void * UserData, const struct ne_lock * Lock,
 //---------------------------------------------------------------------------
 struct ne_lock * __fastcall TWebDAVFileSystem::FindLock(const RawByteString & Path)
 {
-  ne_uri Uri = {0};
+  ne_uri Uri = ne_uri();
   Uri.path = Path.c_str();
   return ne_lockstore_findbyuri(FNeonLockStore, &Uri);
 }

+ 11 - 12
source/core/WebDAVFileSystem.h

@@ -103,7 +103,17 @@ protected:
     const TOverwriteFileParams * FileParams, const TCopyParamType * CopyParam,
     int Params);
   void CheckStatus(int NeonStatus);
-  struct TSessionContext;
+  struct TSessionContext
+  {
+    TSessionContext();
+    ~TSessionContext();
+    TWebDAVFileSystem * FileSystem;
+    ne_session_s * NeonSession; // The main one (there might be aux session for the same context)
+    UnicodeString HostName;
+    int PortNumber;
+    bool NtlmAuthenticationFailed;
+    UnicodeString AuthorizationProtocol;
+  };
   void CheckStatus(TSessionContext * SessionContext, int NeonStatus);
   void __fastcall ClearNeonError();
   static void NeonPropsResult(
@@ -162,17 +172,6 @@ private:
   RawByteString FPassword;
   UnicodeString FTlsVersionStr;
   unsigned int FCapabilities;
-  struct TSessionContext
-  {
-    TSessionContext();
-    ~TSessionContext();
-    TWebDAVFileSystem * FileSystem;
-    ne_session_s * NeonSession; // The main one (there might be aux session for the same context)
-    UnicodeString HostName;
-    int PortNumber;
-    bool NtlmAuthenticationFailed;
-    UnicodeString AuthorizationProtocol;
-  };
   TSessionContext * FSessionContext;
   enum TIgnoreAuthenticationFailure { iafNo, iafWaiting, iafPasswordFailed } FIgnoreAuthenticationFailure;
   UnicodeString FAuthorizationProtocol;

+ 1 - 1
source/filezilla/AsyncProxySocketLayer.cpp

@@ -758,7 +758,7 @@ void CAsyncProxySocketLayer::OnConnect(int nErrorCode)
       else
       {
         pHost = new char[16];
-        sprintf(pHost, "%d.%d.%d.%d", m_nProxyPeerIp%256, (m_nProxyPeerIp>>8) % 256, (m_nProxyPeerIp>>16) %256, m_nProxyPeerIp>>24);
+        sprintf(pHost, "%lu.%lu.%lu.%lu", m_nProxyPeerIp%256, (m_nProxyPeerIp>>8) % 256, (m_nProxyPeerIp>>16) %256, m_nProxyPeerIp>>24);
       }
       if (!m_ProxyData.bUseLogon)
         sprintf(str, "CONNECT %s:%d HTTP/1.1\r\nHost: %s:%d\r\n\r\n", pHost, ntohs(m_nProxyPeerPort),

+ 2 - 2
source/filezilla/AsyncSocketEx.cpp

@@ -790,7 +790,7 @@ BOOL CAsyncSocketEx::Bind(UINT nSocketPort, LPCTSTR lpszSocketAddress)
     memset(&hints, 0, sizeof(addrinfo));
     hints.ai_family = m_SocketData.nFamily;
     hints.ai_socktype = SOCK_STREAM;
-    _snprintf(port, 9, "%lu", nSocketPort);
+    _snprintf(port, 9, "%u", nSocketPort);
     error = getaddrinfo(lpszAscii, port, &hints, &res0);
     if (error)
       return FALSE;
@@ -1092,7 +1092,7 @@ BOOL CAsyncSocketEx::Connect(LPCTSTR lpszHostAddress, UINT nHostPort)
     memset(&hints, 0, sizeof(addrinfo));
     hints.ai_family = m_SocketData.nFamily;
     hints.ai_socktype = SOCK_STREAM;
-    _snprintf(port, 9, "%lu", nHostPort);
+    _snprintf(port, 9, "%u", nHostPort);
     error = getaddrinfo(T2CA(lpszHostAddress), port, &hints, &m_SocketData.addrInfo);
     if (error)
       return FALSE;

+ 1 - 1
source/filezilla/AsyncSocketExLayer.cpp

@@ -326,7 +326,7 @@ BOOL CAsyncSocketExLayer::ConnectNext(LPCTSTR lpszHostAddress, UINT nHostPort)
     hints.ai_family = m_nFamily;
     hints.ai_socktype = SOCK_STREAM;
     hints.ai_flags = 0;
-    _snprintf(port, 9, "%lu", nHostPort);
+    _snprintf(port, 9, "%u", nHostPort);
     error = getaddrinfo(T2CA(lpszHostAddress), port, &hints, &res0);
     if (error)
       return FALSE;

+ 2 - 2
source/filezilla/AsyncSslSocketLayer.cpp

@@ -1135,7 +1135,7 @@ void CAsyncSslSocketLayer::apps_ssl_info_callback(const SSL *s, int where, int r
   if (!pLayer->m_bUseSSL && (where != SSL_CB_LOOP))
     return;
 
-  char * str;
+  const char * str;
   int w;
 
   w = where& ~SSL_ST_MASK;
@@ -1823,7 +1823,7 @@ BOOL CAsyncSslSocketLayer::SetCertStorage(CString file)
 void CAsyncSslSocketLayer::OnClose(int nErrorCode)
 {
   m_onCloseCalled = true;
-  if (m_bUseSSL && BIO_ctrl)
+  if (m_bUseSSL)
   {
     size_t pending = BIO_ctrl_pending(m_sslbio);
     if (pending > 0)

+ 1 - 1
source/filezilla/FileZillaApi.cpp

@@ -1,7 +1,7 @@
 //---------------------------------------------------------------------------
 #include "stdafx.h"
 #include "FileZillaApi.h"
-#include "mainthread.h"
+#include "MainThread.h"
 
 //////////////////////////////////////////////////////////////////////
 // Konstruktion/Destruktion

+ 18 - 18
source/filezilla/FtpControlSocket.cpp

@@ -1,7 +1,7 @@
 //---------------------------------------------------------------------------
 #include "stdafx.h"
 #include "FtpControlSocket.h"
-#include "mainthread.h"
+#include "MainThread.h"
 #include "transfersocket.h"
 #include "asyncproxysocketlayer.h"
 #include "AsyncSslSocketLayer.h"
@@ -92,7 +92,7 @@ public:
   CString subdir;
   BOOL bPasv;
   CString host;
-  UINT port;
+  int port;
   int nFinish;
   t_directory *pDirectoryListing;
   BOOL bTriedPortPasvOnce;
@@ -248,7 +248,7 @@ void CFtpControlSocket::ShowTimeoutError(UINT nID) const
   CString str2;
   str2.LoadString(nID);
   CString message;
-  message.Format(L"%s (%s)", str1, str2);
+  message.Format(L"%s (%s)", (LPCTSTR)str1, (LPCTSTR)str2);
   ShowStatus(message, FZ_LOG_ERROR);
 }
 
@@ -521,14 +521,14 @@ void CFtpControlSocket::Connect(t_server &server)
     temp=fwhost;
     port=fwport;
     if(fwport!=21)
-      fwhost.Format( L"%s:%d", fwhost, fwport); // add port to fwhost (only if port is not 21)
+      fwhost.Format( L"%s:%d", (LPCTSTR)fwhost, fwport); // add port to fwhost (only if port is not 21)
   }
 
   CString hostname = server.host;
   if(server.port!=21)
-    hostname.Format( L"%s:%d", hostname, server.port); // add port to hostname (only if port is not 21)
+    hostname.Format( L"%s:%d", (LPCTSTR)hostname, server.port); // add port to hostname (only if port is not 21)
   CString str;
-  str.Format(IDS_STATUSMSG_CONNECTING, hostname);
+  str.Format(IDS_STATUSMSG_CONNECTING, (LPCTSTR)hostname);
   ShowStatus(str, FZ_LOG_STATUS);
 
   if (!Connect(temp, port))
@@ -990,7 +990,7 @@ void CFtpControlSocket::LogOnToServer(BOOL bSkipReply /*=FALSE*/)
     if (logontype)
     {
       CString str;
-      str.Format(IDS_STATUSMSG_FWCONNECT,hostname);
+      str.Format(IDS_STATUSMSG_FWCONNECT,(LPCTSTR)hostname);
       ShowStatus(str,FZ_LOG_STATUS);
     }
     m_Operation.nOpState++;
@@ -1181,7 +1181,7 @@ void CFtpControlSocket::OnReceive(int nErrorCode)
     }
     m_MultiLine = "";
     CString str;
-    str.Format(IDS_STATUSMSG_CONNECTEDWITH, m_ServerName);
+    str.Format(IDS_STATUSMSG_CONNECTEDWITH, (LPCTSTR)m_ServerName);
     ShowStatus(str, FZ_LOG_PROGRESS);
     m_pOwner->SetConnected(TRUE);
   }
@@ -1397,7 +1397,7 @@ void CFtpControlSocket::OnConnect(int nErrorCode)
       CString str;
       str.Format(
         m_pSslLayer ? IDS_STATUSMSG_CONNECTEDWITHSSL : IDS_STATUSMSG_CONNECTEDWITH,
-        m_ServerName);
+        (LPCTSTR)m_ServerName);
       ShowStatus(str,FZ_LOG_PROGRESS);
     }
   }
@@ -1406,7 +1406,7 @@ void CFtpControlSocket::OnConnect(int nErrorCode)
     if (nErrorCode == WSAHOST_NOT_FOUND)
     {
       CString str;
-      str.Format(IDS_ERRORMSG_CANTRESOLVEHOST2, m_ServerName);
+      str.Format(IDS_ERRORMSG_CANTRESOLVEHOST2, (LPCTSTR)m_ServerName);
       ShowStatus(str, FZ_LOG_ERROR);
     }
     else
@@ -2335,9 +2335,9 @@ void CFtpControlSocket::List(BOOL bFinish, int nError /*=FALSE*/, CServerPath pa
 bool CFtpControlSocket::ConnectTransferSocket(const CString & host, UINT port)
 {
   CString hostname;
-  hostname.Format(L"%s:%d", host, port);
+  hostname.Format(L"%s:%d", (LPCTSTR)host, port);
   CString str;
-  str.Format(IDS_STATUSMSG_CONNECTING, hostname);
+  str.Format(IDS_STATUSMSG_CONNECTING, (LPCTSTR)hostname);
   ShowStatus(str, FZ_LOG_PROGRESS);
 
   bool result = true;
@@ -2653,7 +2653,7 @@ int CFtpControlSocket::OpenTransferFile(CFileTransferData * pData)
     wchar_t * Error = m_pTools->LastSysErrorMessage();
     //Error opening the file
     CString str;
-    str.Format(IDS_ERRORMSG_FILEOPENFAILED,pData->transferfile.localfile);
+    str.Format(IDS_ERRORMSG_FILEOPENFAILED,(LPCTSTR)pData->transferfile.localfile);
     str += L"\n";
     str += Error;
     free(Error);
@@ -2939,7 +2939,7 @@ void CFtpControlSocket::FileTransfer(t_transferfile *transferfile/*=0*/,BOOL bFi
     {
       CString str;
       str.Format(transferfile->get?IDS_STATUSMSG_DOWNLOADSTART:IDS_STATUSMSG_UPLOADSTART,
-            transferfile->get ? transferfile->remotepath.FormatFilename(transferfile->remotefile) : transferfile->localfile);
+            transferfile->get ? (LPCTSTR)transferfile->remotepath.FormatFilename(transferfile->remotefile) : (LPCTSTR)transferfile->localfile);
       ShowStatus(str,FZ_LOG_STATUS);
     }
 
@@ -5623,7 +5623,7 @@ void CFtpControlSocket::Chmod(CString filename, const CServerPath &path, int nVa
 {
   m_Operation.nOpMode=CSMODE_CHMOD;
   CString str;
-  str.Format( L"SITE CHMOD %03d %s", nValue, path.FormatFilename(filename));
+  str.Format( L"SITE CHMOD %03d %s", nValue, (LPCTSTR)path.FormatFilename(filename));
   Send(str);
 }
 
@@ -5856,7 +5856,7 @@ int CFtpControlSocket::OnLayerCallback(std::list<t_callbackMsg>& callbacks)
           break;
         case SSL_VERIFY_CERT:
           t_SslCertData *pData = new t_SslCertData;
-          LPTSTR CertError = NULL;
+          LPCTSTR CertError = NULL;
           if (m_pSslLayer->GetPeerCertificateData(*pData, CertError))
           {
             CVerifyCertRequestData *pRequestData = new CVerifyCertRequestData;
@@ -6425,7 +6425,7 @@ bool CFtpControlSocket::CheckForcePasvIp(CString & host)
 
       if (ahost != host)
       {
-        LogMessage(FZ_LOG_WARNING, L"Using host address %s instead of the one suggested by the server: %s", ahost, host);
+        LogMessage(FZ_LOG_WARNING, L"Using host address %s instead of the one suggested by the server: %s", (LPCTSTR)ahost, (LPCTSTR)host);
         host = ahost;
       }
       break;
@@ -6441,7 +6441,7 @@ bool CFtpControlSocket::CheckForcePasvIp(CString & host)
       }
       else if (!IsRoutableAddress(host) && IsRoutableAddress(ahost))
       {
-        LogMessage(FZ_LOG_WARNING, L"Server sent passive reply with unroutable address %s, using host address instead.", host, ahost);
+        LogMessage(FZ_LOG_WARNING, L"Server sent passive reply with unroutable address %s, using host address instead.", (LPCTSTR)host);
         host = ahost;
       }
       break;

+ 2 - 2
source/filezilla/FtpListResult.cpp

@@ -72,7 +72,7 @@ CFtpListResult::CFtpListResult(t_server server, bool mlst, bool *bUTF8, bool vms
 
   //French month names
   m_MonthNamesMap[L"janv"] = 1;
-  m_MonthNamesMap[L"f\xE9"L"b"] = 1;
+  m_MonthNamesMap[L"f\xE9" L"b"] = 1;
   m_MonthNamesMap[L"f\xE9v"] = 2;
   m_MonthNamesMap[L"fev"] = 2;
   m_MonthNamesMap[L"f\xE9vr"] = 2;
@@ -86,7 +86,7 @@ CFtpListResult::CFtpListResult(t_server server, bool mlst, bool *bUTF8, bool vms
   m_MonthNamesMap[L"ao\xFB"] = 8;
   m_MonthNamesMap[L"ao\xFBt"] = 8;
   m_MonthNamesMap[L"aout"] = 8;
-  m_MonthNamesMap[L"d\xE9"L"c"] = 12;
+  m_MonthNamesMap[L"d\xE9" L"c"] = 12;
   m_MonthNamesMap[L"dec"] = 12;
 
   //Italian month names

+ 0 - 1
source/filezilla/ServerPath.h

@@ -35,7 +35,6 @@ protected:
   std::list<CString> m_Segments;
   typedef std::list<CString>::iterator tIter;
   typedef std::list<CString>::const_iterator tConstIter;
-  typedef std::list<CString>::const_iterator tConstIter;
   CString m_Prefix;
   int m_nServerType;
 

+ 4 - 4
source/filezilla/TransferSocket.cpp

@@ -1,7 +1,7 @@
 //---------------------------------------------------------------------------
 #include "stdafx.h"
 #include "TransferSocket.h"
-#include "mainthread.h"
+#include "MainThread.h"
 #include "AsyncProxySocketLayer.h"
 #ifndef MPEXT_NO_GSS
 #include "AsyncGssSocketLayer.h"
@@ -1046,7 +1046,7 @@ int CTransferSocket::OnLayerCallback(std::list<t_callbackMsg>& callbacks)
           break;
         case SSL_VERIFY_CERT:
           t_SslCertData data;
-          LPTSTR CertError = NULL;
+          LPCTSTR CertError = NULL;
           if (m_pSslLayer->GetPeerCertificateData(data, CertError))
             m_pSslLayer->SetNotifyReply(data.priv_data, SSL_VERIFY_CERT, 1);
           else
@@ -1111,7 +1111,7 @@ void CTransferSocket::WriteData(const char * buffer, int len)
 {
   if (m_OnTransferOut != NULL)
   {
-    m_OnTransferOut(NULL, m_pBuffer, len);
+    m_OnTransferOut(NULL, reinterpret_cast<const unsigned char *>(m_pBuffer), len);
   }
   else
   {
@@ -1124,7 +1124,7 @@ int CTransferSocket::ReadData(char * buffer, int len)
   int result;
   if (m_OnTransferIn != NULL)
   {
-    result = m_OnTransferIn(NULL, buffer, len);
+    result = m_OnTransferIn(NULL, reinterpret_cast<unsigned char *>(buffer), len);
   }
   else
   {

+ 8 - 5
source/putty/defs.h

@@ -11,6 +11,14 @@
 #ifndef PUTTY_DEFS_H
 #define PUTTY_DEFS_H
 
+#ifdef WINSCP
+#define HAVE_AES_NI 1
+#define HAVE_WMEMCHR 1
+#define HAVE_CMAKE_H 0
+#define HAVE_NO_STDINT_H 0
+#define HAVE_ARM_DIT 0
+#endif
+
 #ifndef WINSCP
 #ifdef NDEBUG
 /*
@@ -33,11 +41,6 @@
 #include <stdio.h>                     /* for __MINGW_PRINTF_FORMAT */
 #include <stdbool.h>
 
-#ifdef WINSCP
-#define HAVE_AES_NI 1
-#define HAVE_WMEMCHR 1
-#endif
-
 #if defined _MSC_VER && _MSC_VER < 1800
 /* Work around lack of inttypes.h and strtoumax in older MSVC */
 #define PRIx32 "x"

+ 6 - 3
source/putty/network.h

@@ -250,12 +250,15 @@ static inline size_t sk_write_oob(Socket *s, const void *data, size_t len)
 static inline void sk_write_eof(Socket *s)
 { s->vt->write_eof(s); }
 
-#pragma option push -w-bei // WINSCP
+#ifdef __cplusplus
+#define WINSCP_ENUM_CAST(TYPE, EXPR) static_cast<TYPE>(EXPR)
+#else
+#define WINSCP_ENUM_CAST(TYPE, EXPR) (EXPR)
+#endif
 static inline void plug_log(
     Plug *p, Socket *s, int type, SockAddr *addr, int port,
     const char *msg, int code)
-{ p->vt->log(p, s, type, addr, port, msg, code); }
-#pragma option pop // WINSCP
+{ p->vt->log(p, s, WINSCP_ENUM_CAST(PlugLogType, type), addr, port, msg, code); }
 static inline void plug_closing(Plug *p, PlugCloseType type, const char *msg)
 { p->vt->closing(p, type, msg); }
 static inline void plug_closing_normal(Plug *p)

+ 5 - 0
source/putty/putty.h

@@ -19,6 +19,8 @@ typedef enum {
     FILTER_SOUND_FILES, /* whatever kind of sound file we can use as bell */
 } FilereqFilter;
 
+struct callback_set;
+
 #include "defs.h"
 #include "platform.h"
 #include "network.h"
@@ -2518,6 +2520,8 @@ void conf_filesel_handler(dlgcontrol *ctrl, dlgparam *dlg,
 void conf_fontsel_handler(dlgcontrol *ctrl, dlgparam *dlg,
                           void *data, int event);
 
+// to avoid "[bcc32c Warning] anonymous types declared in an anonymous union are an extension"
+#ifndef WINSCP
 struct conf_editbox_handler_type {
     /* Structure passed as context2 to conf_editbox_handler */
     enum { EDIT_STR, EDIT_INT, EDIT_FIXEDPOINT } type;
@@ -2552,6 +2556,7 @@ extern const struct conf_editbox_handler_type conf_editbox_str;
 extern const struct conf_editbox_handler_type conf_editbox_int;
 #define ED_STR CP(&conf_editbox_str)
 #define ED_INT CP(&conf_editbox_int)
+#endif
 
 void setup_config_box(struct controlbox *b, bool midsession,
                       int protocol, int protcfginfo);

+ 1 - 1
source/putty/puttyexp.h

@@ -21,7 +21,7 @@ unsigned int winscp_query(Backend * be, int query);
 void md5checksum(const char * buffer, int len, unsigned char output[16]);
 typedef const struct ssh_keyalg * cp_ssh_keyalg;
 void get_hostkey_algs(int type, int * count, cp_ssh_keyalg ** sign_keys);
-void get_macs(int * count, const struct ssh2_macalg *** amacs);
+void get_macs(int * count, const struct ssh2_macalg * const ** amacs);
 int have_any_ssh2_hostkey(Seat * seat, const char * host, int port);
 
 // from wingss.c

+ 1 - 0
source/putty/ssh.h

@@ -1505,6 +1505,7 @@ int x11_identify_auth_proto(ptrlen protoname);
 void *x11_dehexify(ptrlen hex, int *outlen);
 bool x11_parse_ip(const char *addr_string, unsigned long *ip);
 
+struct callback_set;
 Channel *agentf_new(SshChannel *c, struct callback_set *callback_set); // WINSCP
 
 bool dh_is_gex(const ssh_kex *kex);

+ 2 - 2
source/putty/ssh/transport2.c

@@ -2844,7 +2844,7 @@ void get_hostkey_algs(int type, int * count, cp_ssh_keyalg ** sign_keys)
     int i;
     int max = lenof(ssh2_hostkey_algs);
     *count = 0;
-    *sign_keys = snewn(max, cp_ssh_keyalg *);
+    *sign_keys = snewn(max, cp_ssh_keyalg);
     for (i = 0; i < max; i++)
     {
         if ((type < 0) || (ssh2_hostkey_algs[i].id == type))
@@ -2856,7 +2856,7 @@ void get_hostkey_algs(int type, int * count, cp_ssh_keyalg ** sign_keys)
 }
 
 // WINSCP
-void get_macs(int * count, const struct ssh2_macalg *** amacs)
+void get_macs(int * count, const struct ssh2_macalg * const ** amacs)
 {
     *amacs = macs;
     *count = lenof(macs);

+ 1 - 1
source/putty/ssh/userauth2-client.c

@@ -1433,7 +1433,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
                 /* Import server name if not cached from KEX */
                 if (s->shgss->srv_name == GSS_C_NO_NAME) {
                     // WINSCP
-                    const char * fullhostname = s->fullhostname;
+                    char * fullhostname = s->fullhostname;
                     if (s->loghost[0] != '\0')
                     {
                         fullhostname = s->loghost;

+ 2 - 0
source/putty/windows/gss.c

@@ -3,7 +3,9 @@
 #include <limits.h>
 #include "putty.h"
 
+#ifndef WINSCP // already defined globally
 #define SECURITY_WIN32
+#endif
 #include <security.h>
 
 #include "ssh/pgssapi.h"

+ 5 - 4
source/putty/windows/handle-io.c

@@ -44,6 +44,7 @@ struct handle_list_node {
     handle_list_node *next, *prev;
 };
 #endif
+struct handle_generic; // WINSCP
 static void add_to_ready_list(struct handle_generic *ctx); // WINSCP
 
 /*
@@ -187,7 +188,7 @@ static DWORD WINAPI handle_input_threadfunc(void *param)
          */
         finished = (ctx->len == 0);
 
-        add_to_ready_list(ctx); // WINSCP
+        add_to_ready_list((struct handle_generic *)ctx); // WINSCP
 
         if (finished)
             break;
@@ -200,7 +201,7 @@ static DWORD WINAPI handle_input_threadfunc(void *param)
              * not touch ctx at all, because the main thread might
              * have freed it.
              */
-            add_to_ready_list(ctx); // WINSCP
+            add_to_ready_list((struct handle_generic *)ctx); // WINSCP
             break;
         }
     }
@@ -316,7 +317,7 @@ static DWORD WINAPI handle_output_threadfunc(void *param)
              * not touch ctx at all, because the main thread might
              * have freed it.
              */
-            add_to_ready_list(ctx); // WINSCP
+            add_to_ready_list((struct handle_generic *)ctx); // WINSCP
             break;
         }
         if (povl) {
@@ -339,7 +340,7 @@ static DWORD WINAPI handle_output_threadfunc(void *param)
                 ctx->writeerr = 0;
         }
 
-        add_to_ready_list(ctx); // WINSCP
+        add_to_ready_list((struct handle_generic *)ctx); // WINSCP
         if (!writeret) {
             /*
              * The write operation has suffered an error. Telling that