[TOOLS] Fix/suppress all MSVC/x64 warnings (#1525)
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Mon, 15 Apr 2019 11:29:33 +0000 (13:29 +0200)
committerColin Finck <colin@reactos.org>
Sun, 28 Apr 2019 21:21:48 +0000 (23:21 +0200)
29 files changed:
sdk/lib/cmlib/hivebin.c
sdk/lib/inflib/CMakeLists.txt
sdk/lib/inflib/infget.c
sdk/tools/CMakeLists.txt
sdk/tools/bin2c.c
sdk/tools/cabman/cabinet.cxx
sdk/tools/hhpcomp/CMakeLists.txt
sdk/tools/hhpcomp/chmc/chmc.c
sdk/tools/hhpcomp/port/config.h [new file with mode: 0644]
sdk/tools/hpp/CMakeLists.txt
sdk/tools/isohybrid/CMakeLists.txt
sdk/tools/isohybrid/isohybrid.c
sdk/tools/isohybrid/reactos_support_code.h
sdk/tools/kbdtool/kbdtool.h
sdk/tools/kbdtool/main.c
sdk/tools/kbdtool/output.c
sdk/tools/mkhive/reginf.c
sdk/tools/mkisofs/CMakeLists.txt
sdk/tools/mkisofs/reactos/xconfig.h
sdk/tools/mkshelllink/mkshelllink.c
sdk/tools/spec2def/spec2def.c
sdk/tools/unicode/CMakeLists.txt
sdk/tools/unicode/string.c
sdk/tools/utf16le/utf16le.cpp
sdk/tools/widl/CMakeLists.txt
sdk/tools/widl/port/config.h [new file with mode: 0644]
sdk/tools/wpp/CMakeLists.txt
sdk/tools/xml2sdb/CMakeLists.txt
sdk/tools/xml2sdb/main.cpp

index 23ca9cb..1b6cdf1 100644 (file)
@@ -16,7 +16,7 @@ HvpAddBin(
 {
     PHMAP_ENTRY BlockList;
     PHBIN Bin;
-    SIZE_T BinSize;
+    ULONG BinSize;
     ULONG i;
     ULONG BitmapSize;
     ULONG BlockCount;
@@ -24,7 +24,7 @@ HvpAddBin(
     PHCELL Block;
 
     BinSize = ROUND_UP(Size + sizeof(HBIN), HBLOCK_SIZE);
-    BlockCount = (ULONG)(BinSize / HBLOCK_SIZE);
+    BlockCount = BinSize / HBLOCK_SIZE;
 
     Bin = RegistryHive->Allocate(BinSize, TRUE, TAG_CM);
     if (Bin == NULL)
@@ -34,7 +34,7 @@ HvpAddBin(
     Bin->Signature = HV_HBIN_SIGNATURE;
     Bin->FileOffset = RegistryHive->Storage[Storage].Length *
                       HBLOCK_SIZE;
-    Bin->Size = (ULONG)BinSize;
+    Bin->Size = BinSize;
 
     /* Allocate new block list */
     OldBlockListSize = RegistryHive->Storage[Storage].Length;
index e6ed96f..bf8086a 100644 (file)
@@ -21,7 +21,7 @@ else()
         infhostput.c
         infhostrtl.c)
 
-    add_definitions(-D__NO_CTYPE_INLINES -DINFLIB_HOST)
+    add_definitions(-D__NO_CTYPE_INLINES -DINFLIB_HOST -D_CRT_SECURE_NO_WARNINGS)
     add_library(inflibhost ${SOURCE})
 
     if(NOT MSVC)
index 5e1ccdb..70b3473 100644 (file)
@@ -582,7 +582,7 @@ InfpGetStringField(PINFCONTEXT Context,
                               0);
 
   if (RequiredSize != NULL)
-    *RequiredSize = Size + 1;
+    *RequiredSize = (ULONG)Size + 1;
 
   if (ReturnBuffer != NULL)
     {
index bbcf9e7..f721728 100644 (file)
@@ -9,8 +9,11 @@ endfunction()
 #add_executable(pefixup pefixup.c)
 
 if(MSVC)
-    add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+    add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -DHAVE_IO_H=1)
     add_compile_flags_language("/EHsc" "CXX")
+
+    # Disable warning "conversion from 'size_t' to 'int', possible loss of data"
+    add_compile_flags("/wd4267")
 endif()
 
 add_host_tool(bin2c bin2c.c)
@@ -19,10 +22,10 @@ add_host_tool(geninc geninc/geninc.c)
 add_host_tool(mkshelllink mkshelllink/mkshelllink.c)
 add_host_tool(obj2bin obj2bin/obj2bin.c)
 add_host_tool(spec2def spec2def/spec2def.c)
-
 add_host_tool(utf16le utf16le/utf16le.cpp)
 
 add_subdirectory(cabman)
+add_subdirectory(fatten)
 add_subdirectory(hhpcomp)
 add_subdirectory(hpp)
 add_subdirectory(isohybrid)
@@ -38,5 +41,3 @@ if(NOT MSVC)
     add_subdirectory(log2lines)
     add_subdirectory(rsym)
 endif()
-
-add_subdirectory(fatten)
index f7ee025..12b2a3f 100644 (file)
@@ -167,8 +167,8 @@ int main(int argc, char* argv[])
 
     /* Generate the header file and close it */
     fprintf(outHFile, "/* This file is autogenerated, do not edit. */\n\n");
-    fprintf(outHFile, "#define %s_SIZE %lu\n"          , argv[5], bufLen);
-    fprintf(outHFile, "extern unsigned char %s[%lu];\n", argv[5], bufLen);
+    fprintf(outHFile, "#define %s_SIZE %lu\n"          , argv[5], (unsigned long)bufLen);
+    fprintf(outHFile, "extern unsigned char %s[%lu];\n", argv[5], (unsigned long)bufLen);
     fclose(outHFile);
 
     /* Close the input file */
index 5202404..3940049 100644 (file)
@@ -3106,7 +3106,7 @@ ULONG CCabinet::GetFileTimes(FILE* FileHandle, PCFFILE_NODE File)
 {
 #if defined(_WIN32)
     FILETIME FileTime;
-    HANDLE FileNo = (HANDLE)_fileno(FileHandle);
+    HANDLE FileNo = UlongToHandle(_fileno(FileHandle));
 
     if (GetFileTime(FileNo, NULL, NULL, &FileTime))
         FileTimeToDosDateTime(&FileTime,
index bbe004a..8e073ff 100644 (file)
@@ -14,3 +14,11 @@ add_definitions(-DNONSLIDE)
 
 add_executable(hhpcomp ${SOURCE})
 target_link_libraries(hhpcomp)
+
+if(MSVC)
+    # Disable warning "'x': unreferenced local variable"
+    add_target_compile_flags(hhpcomp "/wd4101")
+
+    # Disable warning "'=': conversion from 'a' to 'b', possible loss of data"
+    add_target_compile_flags(hhpcomp "/wd4244")
+endif()
index 50c4b46..934bfba 100644 (file)
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifdef __REACTOS__
+#include <io.h>
+int mkstemps(char* template, int suffix_len);
+#endif /* __REACTOS__ */
 #else
 #ifdef __REACTOS__
 #include <sys/types.h>
diff --git a/sdk/tools/hhpcomp/port/config.h b/sdk/tools/hhpcomp/port/config.h
new file mode 100644 (file)
index 0000000..74ef33d
--- /dev/null
@@ -0,0 +1,7 @@
+
+#pragma once
+
+#if defined(_WIN32)
+#include <io.h>
+#define HAVE_PROCESS_H 1
+#endif
index 684214f..3ca527e 100644 (file)
@@ -1,2 +1,7 @@
 
 add_host_tool(hpp hpp.c)
+
+if(MSVC)
+    # Disable warning "'=': conversion from 'a' to 'b', possible loss of data"
+    add_target_compile_flags(hpp "/wd4244")
+endif()
index 13b57e1..d24f3b9 100644 (file)
@@ -5,3 +5,11 @@ add_definitions(
 add_host_tool(isohybrid
     isohybrid.c
     reactos_support_code.c)
+
+if(MSVC)
+    # Disable warning "'x': unreferenced local variable"
+    add_target_compile_flags(isohybrid "/wd4101")
+
+    # Disable warning "'return': conversion from '__int64' to 'int', possible loss of data"
+    add_target_compile_flags(isohybrid "/wd4244")
+endif()
index dd78c79..b8d2da6 100644 (file)
@@ -57,12 +57,12 @@ uint8_t mode = 0;
 enum { VERBOSE = 1 , EFI = 2 , MAC = 4};
 
 /* user options */
-uint16_t head = 64;             /* 1 <= head <= 256 */
-uint8_t sector = 32;            /* 1 <= sector <= 63  */
+uint32_t head = 64;             /* 1 <= head <= 256 */
+uint32_t sector = 32;           /* 1 <= sector <= 63  */
 
-uint8_t entry = 0;              /* partition number: 1 <= entry <= 4 */
-uint8_t offset = 0;             /* partition offset: 0 <= offset <= 64 */
-uint16_t type = 0x17;           /* partition type: 0 <= type <= 255 */
+uint32_t entry = 0;             /* partition number: 1 <= entry <= 4 */
+uint32_t offset = 0;            /* partition offset: 0 <= offset <= 64 */
+uint32_t type = 0x17;           /* partition type: 0 <= type <= 255 */
 uint32_t id = 0;                /* MBR: 0 <= id <= 0xFFFFFFFF(4294967296) */
 
 uint8_t hd0 = 0;                /* 0 <= hd0 <= 2 */
@@ -994,7 +994,7 @@ main(int argc, char *argv[])
        errx(1, "%s: --offset is invalid with UEFI images\n", argv[0]);
 #endif
 
-    srand(time(NULL) << (getppid() << getpid()));
+    srand((unsigned int)time(NULL) << (getppid() << getpid()));
 
     if (!(fp = fopen(argv[0], "rb+")))
         err(1, "could not open file `%s'", argv[0]);
index 3f3344c..591ace9 100644 (file)
@@ -9,6 +9,8 @@
 #ifdef _WIN32
 #include <malloc.h>
 #include <windows.h>
+#include <process.h>
+#include <io.h>
 #else
 #include <alloca.h>
 #include <unistd.h>
index bf14307..b2b9612 100644 (file)
@@ -34,7 +34,7 @@ typedef struct tagKEYNAME
 typedef struct tagSCVK
 {
     USHORT ScanCode;
-    USHORT VirtualKey;
+    UCHAR VirtualKey;
     PCHAR Name;
     BOOLEAN Processed;
 } SCVK, *PSCVK;
index 9a5517a..16cb86f 100644 (file)
@@ -61,7 +61,8 @@ INT
 main(INT argc,
      PCHAR* argv)
 {
-    ULONG i, ErrorCode, FailureCode;
+    int i;
+    ULONG ErrorCode, FailureCode;
     CHAR Option;
     PCHAR OpenFlags;
     CHAR BuildOptions[16] = {0};
index 8b3e376..6d1846a 100644 (file)
@@ -855,7 +855,7 @@ kbd_c(IN ULONG StateCount,
             if (i >= 1)
             {
                 /* J is the loop variable, K is the double */
-                for (NeedPlus = 0, j = 0, k = 1; (1 << j) <= i; j++, k = (1 << j))
+                for (NeedPlus = 0, j = 0, k = 1; (1u << j) <= i; j++, k = (1 << j))
                 {
                     /* Do we need to add a plus? */
                     if (NeedPlus)
index b630d75..53db880 100644 (file)
@@ -345,7 +345,7 @@ do_reg_operation(
                                0,
                                Type,
                                (PVOID)Str,
-                               Size * sizeof(WCHAR));
+                               (ULONG)(Size * sizeof(WCHAR)));
             }
             else
             {
@@ -372,7 +372,7 @@ do_reg_operation(
             if (Data == NULL)
                 return FALSE;
 
-            DPRINT("setting binary data '%S' len %d\n", ValueName, Size);
+            DPRINT("setting binary data '%S' len %d\n", ValueName, (ULONG)Size);
             InfHostGetBinaryField(Context, 5, Data, Size, NULL);
         }
 
@@ -381,7 +381,7 @@ do_reg_operation(
                        0,
                        Type,
                        (PVOID)Data,
-                       Size);
+                       (ULONG)Size);
 
         free(Data);
     }
index a045c03..82704df 100644 (file)
@@ -88,7 +88,20 @@ if(MSVC)
     if (ARCH STREQUAL "amd64")
         # Disable warning "conversion from 'size_t' to 'int', possible loss of data"
         add_target_compile_flags(mkisofs "/wd4267")
+
+        # Disable warning "'type cast': pointer truncation from 'const char *' to 'long'"
+        add_target_compile_flags(libschily "/wd4311")
     endif()
+
+    # Disable warning "'<': signed/unsigned mismatch"
+    add_target_compile_flags(mkisofs "/wd4018")
+
+    # Disable warning "'nchar': unreferenced local variable"
+    add_target_compile_flags(mkisofs "/wd4101")
+
+    # Disable warning "'+=': conversion from 'x' to 'y', possible loss of data"
+    add_target_compile_flags(libschily "/wd4244")
+    add_target_compile_flags(mkisofs "/wd4244")
 else()
     # libschily implements an own printf function with support for the %r formatter.
     # Silence compilers checking for invalid formatting sequences.
index 3fdd3a8..484acc3 100644 (file)
 
 #define HAVE_TYPE_INTMAX_T 1
 #define HAVE_TYPE_UINTMAX_T 1
+#define HAVE_ENVIRON_DEF 1
+#define HAVE_RENAME 1
+#define HAVE_STRNLEN 1
+#ifdef _WIN32
+    #define _CRT_NONSTDC_NO_DEPRECATE 1
+#endif
 
 /*
  * ReactOS additions
  */
 #ifdef _MSC_VER
-    #define ssize_t int
+    #define ssize_t intptr_t
+    #include <io.h>
 #endif
 
 /* Would need additional fprformat.c, less portable */
index cf88f45..2cb921e 100644 (file)
@@ -129,7 +129,7 @@ typedef struct _ID_LIST_DRIVE
 
 int main(int argc, const char *argv[])
 {
-    unsigned i;
+    int i;
     const char *pszOutputPath = "shortcut.lnk";
     const char *pszTarget = NULL;
     const char *pszDescription = "Description";
index 1246ce3..fe89a12 100644 (file)
@@ -500,7 +500,7 @@ PrintName(FILE *fileDest, EXPORT *pexp, PSTRING pstr, int fDeco)
         {
             /* Skip leading underscore and remove trailing decoration */
             pcName++;
-            nNameLength = pcAt - pcName;
+            nNameLength = (int)(pcAt - pcName);
         }
 
         /* Print the undecorated function name */
@@ -515,7 +515,7 @@ PrintName(FILE *fileDest, EXPORT *pexp, PSTRING pstr, int fDeco)
         if (pcDot)
         {
             /* First print the dll name, followed by a dot */
-            nNameLength = pcDot - pcName;
+            nNameLength = (int)(pcDot - pcName);
             fprintf(fileDest, "%.*s.", nNameLength, pcName);
 
             /* Now the actual function name */
index a715719..8e6c09f 100644 (file)
@@ -84,3 +84,14 @@ list(APPEND SOURCE
     wctype.c)
 
 add_library(unicode ${SOURCE})
+
+if(MSVC)
+    # Disable warning "'<': signed/unsigned mismatch"
+    add_target_compile_flags(unicode "/wd4018")
+
+    # Disable warning "unary minus operator applied to unsigned type, result still unsigned"
+    add_target_compile_flags(unicode "/wd4146")
+
+    # Disable warning "conversion from 'const WCHAR' to 'char', possible loss of data"
+    add_target_compile_flags(unicode "/wd4244")
+endif()
index 09499ea..4eab49c 100644 (file)
@@ -469,8 +469,7 @@ int vsnprintfW(WCHAR *str, size_t len, const WCHAR *format, va_list valist)
                 /* FIXME: for unrecognised types, should ignore % when printing */
                 char *bufaiter = bufa;
                 if (*iter == 'p')
-                    sprintf(bufaiter, "%0*lX", 2 * (int)sizeof(void*),
-                            (unsigned long)va_arg(valist, void *));
+                    sprintf(bufaiter, "%p", va_arg(valist, void*));
                 else
                 {
                     *fmta++ = *iter;
index 7ba25b1..391205c 100644 (file)
@@ -35,7 +35,8 @@ protected:
     err_types error;
     enc_types encoding;
     bom_types bom_type;
-    unsigned char buffer[4], fill, index; // need 4 char buffer for optional BOM handling
+    unsigned char buffer[4], index; // need 4 char buffer for optional BOM handling
+    std::streamsize fill;
     fstream inputfile,outputfile;
     static const unsigned char utf8table[64];
 public:
@@ -75,7 +76,7 @@ public:
         valid values are 0xef, 0xff, 0xfe, 0x00
         */
         inputfile.read(reinterpret_cast<char*>(&buffer),4);
-        fill =inputfile.gcount();
+        fill = inputfile.gcount();
         // stupid utf8 bom
         if ((fill > 2) &&
             (buffer[0] == 0xef) &&
@@ -135,7 +136,7 @@ public:
         }
         return utf8; // no valid bom so use utf8 as default
     }
-    int getByte(unsigned char &c)
+    std::streamsize getByte(unsigned char &c)
     {
         if (fill)
         {
@@ -149,7 +150,7 @@ public:
             return inputfile.gcount();
         }
     }
-    int getWord(unsigned short &w)
+    std::streamsize getWord(unsigned short &w)
     {
         unsigned char c[2];
         if (!getByte(c[0]))
@@ -162,7 +163,7 @@ public:
             w = c[1] | (c[0] << 8);
         return 2;
     }
-    int getDWord(wchar_t &d)
+    std::streamsize getDWord(wchar_t &d)
     {
         unsigned char c[4];
         for (int i=0;i<4;i++)
index 40bf916..17239f0 100644 (file)
@@ -35,3 +35,14 @@ list(APPEND SOURCE
 add_definitions(-DINT16=SHORT)
 add_host_tool(widl ${SOURCE})
 target_link_libraries(widl wpphost)
+
+if(MSVC)
+    # Disable warning "'>': signed/unsigned mismatch"
+    add_target_compile_flags(widl "/wd4018")
+
+    # Disable warning "unary minus operator applied to unsigned type, result still unsigned"
+    add_target_compile_flags(widl "/wd4146")
+
+    # Disable warning "'=': conversion from 'a' to 'b', possible loss of data"
+    add_target_compile_flags(widl "/wd4244")
+endif()
diff --git a/sdk/tools/widl/port/config.h b/sdk/tools/widl/port/config.h
new file mode 100644 (file)
index 0000000..568b15d
--- /dev/null
@@ -0,0 +1,15 @@
+
+#pragma once
+
+#include <io.h>
+
+#define HAVE_PROCESS_H 1
+
+int
+_getopt_internal(
+    int argc,
+    char *const *argv,
+    const char *optstring,
+    const struct option *longopts,
+    int *longind,
+    int long_only);
index 2539e6b..39f3b2d 100644 (file)
@@ -11,6 +11,13 @@ if(MSVC)
             add_definitions(-Dvsnprintf=_vsnprintf)
         endif()
     endif()
+
+    # Disable warning " unary minus operator applied to unsigned type, result still unsigned"
+    add_compile_flags("/wd4146")
+
+    # Disable warning "'=': conversion from 'a' to 'b', possible loss of data"
+    add_compile_flags("/wd4244")
+
 endif()
 
 if(CMAKE_CROSSCOMPILING)
index 1a59e62..15e2fc7 100644 (file)
@@ -14,6 +14,9 @@ include_directories(
     ${REACTOS_SOURCE_DIR}/sdk/include/reactos/appcompat)
 add_host_tool(xml2sdb ${SOURCE})
 
-if(NOT MSVC)
+if(MSVC)
+    # Disable warning "'=': conversion from 'a' to 'b', possible loss of data"
+    add_target_compile_flags(xml2sdb "/wd4244")
+else()
     add_target_compile_flags(xml2sdb "-fshort-wchar")
 endif()
index c39a083..14a7d68 100644 (file)
@@ -132,7 +132,7 @@ BOOL WINAPIV ShimDbgPrint(SHIM_LOG_LEVEL Level, PCSTR FunctionName, PCSTR Format
     va_list ArgList;
     const char* LevelStr;
 
-    if (Level > g_ShimDebugLevel)
+    if ((ULONG)Level > g_ShimDebugLevel)
         return FALSE;
 
     switch (Level)