Enable warning C4127 - conditional expression is constant

This commit is contained in:
baldurk
2016-04-09 11:26:53 +02:00
parent cda0b4cb5a
commit 6550b5eefc
6 changed files with 37 additions and 32 deletions
+23 -23
View File
@@ -36,20 +36,20 @@
// Utility macros
#ifndef SAFE_DELETE
#define SAFE_DELETE(p) do { if (p) { delete (p); (p)=NULL; } } while(0)
#define SAFE_DELETE(p) do { if (p) { delete (p); (p)=NULL; } } while((void)0,0)
#endif
#ifndef SAFE_DELETE_ARRAY
#define SAFE_DELETE_ARRAY(p) do { if (p) { delete[] (p); (p)=NULL; } } while(0)
#define SAFE_DELETE_ARRAY(p) do { if (p) { delete[] (p); (p)=NULL; } } while((void)0,0)
#endif
#ifndef SAFE_ADDREF
#define SAFE_ADDREF(p) do { if (p) { (p)->AddRef(); } } while(0)
#define SAFE_ADDREF(p) do { if (p) { (p)->AddRef(); } } while((void)0,0)
#endif
#ifndef SAFE_RELEASE
#define SAFE_RELEASE(p) do { if (p) { (p)->Release(); (p)=NULL; } } while(0)
#define SAFE_RELEASE_NOCLEAR(p) do { if (p) { (p)->Release(); } } while(0)
#define SAFE_RELEASE(p) do { if (p) { (p)->Release(); (p)=NULL; } } while((void)0,0)
#define SAFE_RELEASE_NOCLEAR(p) do { if (p) { (p)->Release(); } } while((void)0,0)
#endif
#ifndef ARRAY_COUNT
@@ -98,15 +98,15 @@ uint32_t CalcNumMips(int Width, int Height, int Depth);
/////////////////////////////////////////////////
// Debugging features
#define RDCDUMP() do { OSUtility::ForceCrash(); } while(0)
#define RDCDUMP() do { OSUtility::ForceCrash(); } while((void)0,0)
#if !defined(RELEASE) || defined(FORCE_DEBUGBREAK)
#define RDCBREAK() do { if(OSUtility::DebuggerPresent()) OS_DEBUG_BREAK(); } while(0)
#define RDCBREAK() do { if(OSUtility::DebuggerPresent()) OS_DEBUG_BREAK(); } while((void)0,0)
#else
#define RDCBREAK() do { } while(0)
#define RDCBREAK() do { } while((void)0,0)
#endif
#define RDCUNIMPLEMENTED(...) do { rdclog(RDCLog_Warning, "Unimplemented: " __VA_ARGS__); RDCBREAK(); } while(0)
#define RDCUNIMPLEMENTED(...) do { rdclog(RDCLog_Warning, "Unimplemented: " __VA_ARGS__); RDCBREAK(); } while((void)0,0)
//
// Logging
@@ -124,15 +124,15 @@ enum LogType
};
#if defined(STRIP_LOG)
#define RDCLOGFILE(fn) do { } while(0)
#define RDCLOGDELETE() do { } while(0)
#define RDCLOGFILE(fn) do { } while((void)0,0)
#define RDCLOGDELETE() do { } while((void)0,0)
#define RDCDEBUG(...) do { } while(0)
#define RDCLOG(...) do { } while(0)
#define RDCWARN(...) do { } while(0)
#define RDCERR(...) do { } while(0)
#define RDCFATAL(...) do { RDCDUMP(); exit(0); } while(0)
#define RDCDUMPMSG(message) do { RDCDUMP(); exit(0); } while(0)
#define RDCDEBUG(...) do { } while((void)0,0)
#define RDCLOG(...) do { } while((void)0,0)
#define RDCWARN(...) do { } while((void)0,0)
#define RDCERR(...) do { } while((void)0,0)
#define RDCFATAL(...) do { RDCDUMP(); exit(0); } while((void)0,0)
#define RDCDUMPMSG(message) do { RDCDUMP(); exit(0); } while((void)0,0)
#else
// perform any operations necessary to flush the log
void rdclog_flush();
@@ -155,20 +155,20 @@ void rdclog_filename(const char *filename);
#if ( !defined(RELEASE) || defined(FORCE_DEBUG_LOGS) ) && !defined(STRIP_DEBUG_LOGS)
#define RDCDEBUG(...) rdclog(RDCLog_Debug, __VA_ARGS__)
#else
#define RDCDEBUG(...) do { } while(0)
#define RDCDEBUG(...) do { } while((void)0,0)
#endif
#define RDCLOG(...) rdclog(RDCLog_Comment, __VA_ARGS__)
#define RDCWARN(...) rdclog(RDCLog_Warning, __VA_ARGS__)
#if defined(DEBUGBREAK_ON_ERROR_LOG)
#define RDCERR(...) do { rdclog(RDCLog_Error, __VA_ARGS__); rdclog_flush(); RDCBREAK(); } while(0)
#define RDCERR(...) do { rdclog(RDCLog_Error, __VA_ARGS__); rdclog_flush(); RDCBREAK(); } while((void)0,0)
#else
#define RDCERR(...) rdclog(RDCLog_Error, __VA_ARGS__)
#endif
#define RDCFATAL(...) do { rdclog(RDCLog_Fatal, __VA_ARGS__); rdclog_flush(); RDCDUMP(); exit(0); } while(0)
#define RDCDUMPMSG(message) do { rdclogprint_int(message); rdclog_flush(); RDCDUMP(); exit(0); } while(0)
#define RDCFATAL(...) do { rdclog(RDCLog_Fatal, __VA_ARGS__); rdclog_flush(); RDCDUMP(); exit(0); } while((void)0,0)
#define RDCDUMPMSG(message) do { rdclogprint_int(message); rdclog_flush(); RDCDUMP(); exit(0); } while((void)0,0)
#endif
//
@@ -184,7 +184,7 @@ void rdcassert(const char *msg, const char *file, unsigned int line, const char
#include "custom_assert.h"
#else
#define RDCASSERTMSG(cond) do { } while(0)
#define RDCASSERTMSG(cond) do { } while((void)0,0)
#endif
#define RDCASSERT(...) RDCASSERTMSG("", __VA_ARGS__)
@@ -196,7 +196,7 @@ void rdcassert(const char *msg, const char *file, unsigned int line, const char
//
#if defined(STRIP_COMPILE_ASSERTS)
#define RDCCOMPILE_ASSERT(condition, message) do { } while(0)
#define RDCCOMPILE_ASSERT(condition, message) do { } while((void)0,0)
#else
#define RDCCOMPILE_ASSERT(condition, message) static_assert(condition, message)
#endif
+2 -2
View File
@@ -107,7 +107,7 @@
if(!(RDCASSERT_IFCOND(__VA_ARGS__))) { \
const char custommsg[] = msg; (void)custommsg; \
std::string assertmsg = "'" STRINGIZE(RDCASSERT_GETCOND(__VA_ARGS__)) "' "; \
if(sizeof(custommsg) > 1) assertmsg += msg " "; \
assertmsg += (sizeof(custommsg) > 1) ? msg " " : ""; \
std::string failmsg; \
RDCASSERT_FAILMSG(__VA_ARGS__); \
if(!failmsg.empty()) { failmsg.pop_back(); failmsg.pop_back(); } \
@@ -116,4 +116,4 @@
rdclog_flush(); \
RDCBREAK(); \
}\
} while(0)
} while((void)0,0)
+1 -1
View File
@@ -48,7 +48,7 @@
using std::map;
// similar to RDCUNIMPLEMENTED but for things that are hit often so we don't want to fire the debugbreak.
#define VULKANNOTIMP(...) do { static bool msgprinted = false; if(!msgprinted) RDCDEBUG("Vulkan not implemented - " __VA_ARGS__); msgprinted = true; } while(0)
#define VULKANNOTIMP(...) do { static bool msgprinted = false; if(!msgprinted) RDCDEBUG("Vulkan not implemented - " __VA_ARGS__); msgprinted = true; } while((void)0,0)
// allows easy disabling of MSAA
#define VULKAN_MESH_VIEW_SAMPLES VK_SAMPLE_COUNT_1_BIT
+5
View File
@@ -302,7 +302,12 @@ Socket *CreateClientSocket(const char *host, uint16_t port, int timeoutMS)
{
fd_set set;
FD_ZERO(&set);
// macro FD_SET contains the do { } while(0) idiom, which warns
#pragma warning(push)
#pragma warning(disable : 4127) // conditional expression is constant
FD_SET(s, &set);
#pragma warning(pop)
int err = WSAGetLastError();
+4 -4
View File
@@ -109,7 +109,7 @@
<PreprocessorDefinitions>RENDERDOC_EXPORTS;RENDERDOC_PLATFORM=win32;USE_BREAKPAD;WIN32;RELEASE;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<AdditionalOptions>/wd4100 /wd4127</AdditionalOptions>
<AdditionalOptions>/wd4100</AdditionalOptions>
<AdditionalIncludeDirectories>$(ProjectDir);$(SolutionDir)renderdoc\3rdparty\</AdditionalIncludeDirectories>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<TreatWarningAsError>true</TreatWarningAsError>
@@ -138,7 +138,7 @@
<PreprocessorDefinitions>RENDERDOC_EXPORTS;RENDERDOC_PLATFORM=win32;USE_BREAKPAD;WIN64;WIN32;RELEASE;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<AdditionalOptions>/wd4100 /wd4127</AdditionalOptions>
<AdditionalOptions>/wd4100</AdditionalOptions>
<AdditionalIncludeDirectories>$(ProjectDir);$(SolutionDir)renderdoc\3rdparty\</AdditionalIncludeDirectories>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<TreatWarningAsError>true</TreatWarningAsError>
@@ -166,7 +166,7 @@
<PreprocessorDefinitions>RENDERDOC_EXPORTS;RENDERDOC_PLATFORM=win32;WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<AdditionalOptions>/wd4100 /wd4127</AdditionalOptions>
<AdditionalOptions>/wd4100</AdditionalOptions>
<WholeProgramOptimization>false</WholeProgramOptimization>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<AdditionalIncludeDirectories>$(ProjectDir);$(SolutionDir)renderdoc\3rdparty\</AdditionalIncludeDirectories>
@@ -198,7 +198,7 @@
<PreprocessorDefinitions>RENDERDOC_EXPORTS;RENDERDOC_PLATFORM=win32;WIN64;WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<AdditionalOptions>/wd4100 /wd4127</AdditionalOptions>
<AdditionalOptions>/wd4100</AdditionalOptions>
<WholeProgramOptimization>false</WholeProgramOptimization>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<AdditionalIncludeDirectories>$(ProjectDir);$(SolutionDir)renderdoc\3rdparty\</AdditionalIncludeDirectories>
+2 -2
View File
@@ -1136,7 +1136,7 @@ int utf8printf(char *buf, size_t bufsize, const char *fmt, va_list args)
// now parsing an argument specifier
// parse out 0 or more flags
do
for(;;)
{
// if flag is found, continue looping to possibly find more flags
// otherwise break out of this loop
@@ -1157,7 +1157,7 @@ int utf8printf(char *buf, size_t bufsize, const char *fmt, va_list args)
formatter.Flags &= ~PrependSpace;
iter++;
} while(true);
}
// possibly parse a width. Note that width always started with 1-9 as it's decimal,
// and 0 or - would have been picked up as a flag above