[TOOLS] Fix/suppress all MSVC/x64 warnings (#1525)

This commit is contained in:
Timo Kreuzer 2019-04-15 13:29:33 +02:00 committed by Colin Finck
parent 0aed8b09a4
commit f47f45dbdd
No known key found for this signature in database
GPG key ID: 1BA74E70456BA1A9
29 changed files with 140 additions and 37 deletions

View 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;

View 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)

View file

@ -582,7 +582,7 @@ InfpGetStringField(PINFCONTEXT Context,
0);
if (RequiredSize != NULL)
*RequiredSize = Size + 1;
*RequiredSize = (ULONG)Size + 1;
if (ReturnBuffer != NULL)
{

View 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)

View 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 */

View 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,

View 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()

View file

@ -30,6 +30,10 @@
#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>

View file

@ -0,0 +1,7 @@
#pragma once
#if defined(_WIN32)
#include <io.h>
#define HAVE_PROCESS_H 1
#endif

View 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()

View 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()

View 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]);

View 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>

View file

@ -34,7 +34,7 @@ typedef struct tagKEYNAME
typedef struct tagSCVK
{
USHORT ScanCode;
USHORT VirtualKey;
UCHAR VirtualKey;
PCHAR Name;
BOOLEAN Processed;
} SCVK, *PSCVK;

View 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};

View 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)

View 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);
}

View 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.

View file

@ -195,12 +195,19 @@
#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 */

View 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";

View 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 */

View 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()

View 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;

View 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++)

View 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()

View file

@ -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);

View 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)

View 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()

View 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)