summaryrefslogtreecommitdiff
path: root/Source/Core/Common
diff options
context:
space:
mode:
authorshuffle2 <godisgovernment@gmail.com>2017-06-07 20:33:54 -0700
committerGitHub <noreply@github.com>2017-06-07 20:33:54 -0700
commitb11d722eeda67bc498f7bf727649fb4ae4e5f997 (patch)
tree597b9596564442ac1c125f5f7332ffc6ec97ce03 /Source/Core/Common
parente6aa118f2111351c7fb38a611f3523793927addb (diff)
parentfd166032abec349b9fae7240830133bf7e0c77b5 (diff)
Merge pull request #5572 from shuffle2/msvc-w4
msvc: use /W4 (and fixes to make it work)
Diffstat (limited to 'Source/Core/Common')
-rw-r--r--Source/Core/Common/Config/Section.h1
-rw-r--r--Source/Core/Common/Crypto/ec.cpp9
-rw-r--r--Source/Core/Common/FileUtil.cpp6
-rw-r--r--Source/Core/Common/GL/GLInterface/WGL.cpp7
-rw-r--r--Source/Core/Common/MathUtil.h2
-rw-r--r--Source/Core/Common/Profiler.cpp6
-rw-r--r--Source/Core/Common/SDCardUtil.cpp9
-rw-r--r--Source/Core/Common/Thread.cpp9
8 files changed, 33 insertions, 16 deletions
diff --git a/Source/Core/Common/Config/Section.h b/Source/Core/Common/Config/Section.h
index 8b36ce157e..0a4662d156 100644
--- a/Source/Core/Common/Config/Section.h
+++ b/Source/Core/Common/Config/Section.h
@@ -27,6 +27,7 @@ class Section
public:
Section(LayerType layer, System system, const std::string& name);
+ virtual ~Section() = default;
virtual bool Exists(const std::string& key) const;
bool Delete(const std::string& key);
diff --git a/Source/Core/Common/Crypto/ec.cpp b/Source/Core/Common/Crypto/ec.cpp
index 9dca32878b..5fe7e9bb2b 100644
--- a/Source/Core/Common/Crypto/ec.cpp
+++ b/Source/Core/Common/Crypto/ec.cpp
@@ -15,6 +15,11 @@
#include "Common/Crypto/bn.h"
#include "Common/Crypto/ec.h"
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable : 4505)
+#endif
+
// y**2 + x*y = x**3 + x + b
UNUSED static const u8 ec_b[30] = {0x00, 0x66, 0x64, 0x7e, 0xde, 0x6c, 0x33, 0x2c, 0x7f, 0x8c,
0x09, 0x23, 0xbb, 0x58, 0x21, 0x3b, 0x33, 0x3b, 0x20, 0xe9,
@@ -404,3 +409,7 @@ void ec_priv_to_pub(const u8* k, u8* Q)
{
point_mul(Q, k, ec_G);
}
+
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp
index ebab9e9c48..203ddbac4b 100644
--- a/Source/Core/Common/FileUtil.cpp
+++ b/Source/Core/Common/FileUtil.cpp
@@ -631,9 +631,9 @@ void CopyDir(const std::string& source_path, const std::string& dest_path)
// Returns the current directory
std::string GetCurrentDir()
{
- char* dir;
// Get the current working directory (getcwd uses malloc)
- if (!(dir = __getcwd(nullptr, 0)))
+ char* dir = __getcwd(nullptr, 0);
+ if (!dir)
{
ERROR_LOG(COMMON, "GetCurrentDirectory failed: %s", GetLastErrorMsg().c_str());
return nullptr;
@@ -986,7 +986,7 @@ u64 IOFile::Tell() const
if (IsOpen())
return ftello(m_file);
else
- return -1;
+ return UINT64_MAX;
}
bool IOFile::Flush()
diff --git a/Source/Core/Common/GL/GLInterface/WGL.cpp b/Source/Core/Common/GL/GLInterface/WGL.cpp
index 57c46cb42b..3e500f5866 100644
--- a/Source/Core/Common/GL/GLInterface/WGL.cpp
+++ b/Source/Core/Common/GL/GLInterface/WGL.cpp
@@ -248,8 +248,8 @@ bool cInterfaceWGL::Create(void* window_handle, bool core)
return false;
}
- int pixel_format;
- if (!(pixel_format = ChoosePixelFormat(m_dc, &pfd)))
+ int pixel_format = ChoosePixelFormat(m_dc, &pfd);
+ if (!pixel_format)
{
PanicAlert("(2) Can't find a suitable PixelFormat.");
return false;
@@ -261,7 +261,8 @@ bool cInterfaceWGL::Create(void* window_handle, bool core)
return false;
}
- if (!(m_rc = wglCreateContext(m_dc)))
+ m_rc = wglCreateContext(m_dc);
+ if (!m_rc)
{
PanicAlert("(4) Can't create an OpenGL rendering context.");
return false;
diff --git a/Source/Core/Common/MathUtil.h b/Source/Core/Common/MathUtil.h
index 7e48e38d80..becaf09792 100644
--- a/Source/Core/Common/MathUtil.h
+++ b/Source/Core/Common/MathUtil.h
@@ -198,7 +198,7 @@ inline int IntLog2(u64 val)
return 63 - __builtin_clzll(val);
#elif defined(_MSC_VER)
- unsigned long result = -1;
+ unsigned long result = ULONG_MAX;
_BitScanReverse64(&result, val);
return result;
diff --git a/Source/Core/Common/Profiler.cpp b/Source/Core/Common/Profiler.cpp
index fdc356a164..0be14073bd 100644
--- a/Source/Core/Common/Profiler.cpp
+++ b/Source/Core/Common/Profiler.cpp
@@ -29,8 +29,8 @@ std::string Profiler::s_lazy_result = "";
int Profiler::s_lazy_delay = 0;
Profiler::Profiler(const std::string& name)
- : m_name(name), m_usecs(0), m_usecs_min(-1), m_usecs_max(0), m_usecs_quad(0), m_calls(0),
- m_depth(0)
+ : m_name(name), m_usecs(0), m_usecs_min(UINT64_MAX), m_usecs_max(0), m_usecs_quad(0),
+ m_calls(0), m_depth(0)
{
m_time = Common::Timer::GetTimeUs();
s_max_length = std::max<u32>(s_max_length, u32(m_name.length()));
@@ -154,7 +154,7 @@ std::string Profiler::Read()
buffer << std::setw(PROFILER_FIELD_LENGTH) << std::right << m_usecs_max;
m_usecs = 0;
- m_usecs_min = -1;
+ m_usecs_min = UINT64_MAX;
m_usecs_max = 0;
m_usecs_quad = 0;
m_calls = 0;
diff --git a/Source/Core/Common/SDCardUtil.cpp b/Source/Core/Common/SDCardUtil.cpp
index 1bb09878b6..9e72990747 100644
--- a/Source/Core/Common/SDCardUtil.cpp
+++ b/Source/Core/Common/SDCardUtil.cpp
@@ -49,6 +49,11 @@
#include <unistd.h> // for unlink()
#endif
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable : 4310)
+#endif
+
/* Believe me, you *don't* want to change these constants !! */
#define BYTES_PER_SECTOR 512
#define RESERVED_SECTORS 32
@@ -289,3 +294,7 @@ FailWrite:
ERROR_LOG(COMMON, "unlink(%s) failed: %s", filename.c_str(), GetLastErrorMsg().c_str());
return false;
}
+
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
diff --git a/Source/Core/Common/Thread.cpp b/Source/Core/Common/Thread.cpp
index 190653ee31..fa81314795 100644
--- a/Source/Core/Common/Thread.cpp
+++ b/Source/Core/Common/Thread.cpp
@@ -62,11 +62,8 @@ void SwitchCurrentThread()
}
// Sets the debugger-visible name of the current thread.
-// Uses undocumented (actually, it is now documented) trick.
-// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxtsksettingthreadname.asp
-
-// This is implemented much nicer in upcoming msvc++, see:
-// http://msdn.microsoft.com/en-us/library/xcb2z8hs(VS.100).aspx
+// Uses trick documented in:
+// https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-set-a-thread-name-in-native-code
void SetCurrentThreadName(const char* szThreadName)
{
static const DWORD MS_VC_EXCEPTION = 0x406D1388;
@@ -83,7 +80,7 @@ void SetCurrentThreadName(const char* szThreadName)
info.dwType = 0x1000;
info.szName = szThreadName;
- info.dwThreadID = -1; // dwThreadID;
+ info.dwThreadID = static_cast<DWORD>(-1);
info.dwFlags = 0;
__try