citra-emu
/
citra-canary
Archived
1
0
Fork 0

src/CMakeLists: Enforce multiple warnings on MSVC (#5692)

This commit is contained in:
Tobias 2022-11-09 23:14:28 +01:00 committed by GitHub
parent 38b8bf12de
commit bb05d8c12a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 53 additions and 30 deletions

View File

@ -834,7 +834,7 @@ struct MicroProfile
inline int MicroProfileLogType(MicroProfileLogEntry Index) inline int MicroProfileLogType(MicroProfileLogEntry Index)
{ {
return ((MP_LOG_BEGIN_MASK & Index)>>62) & 0x3; return (int)(((MP_LOG_BEGIN_MASK & Index)>>62) & 0x3ULL);
} }
inline uint64_t MicroProfileLogTimerIndex(MicroProfileLogEntry Index) inline uint64_t MicroProfileLogTimerIndex(MicroProfileLogEntry Index)
@ -881,12 +881,12 @@ T MicroProfileMax(T a, T b)
inline int64_t MicroProfileMsToTick(float fMs, int64_t nTicksPerSecond) inline int64_t MicroProfileMsToTick(float fMs, int64_t nTicksPerSecond)
{ {
return (int64_t)(fMs*0.001f*nTicksPerSecond); return (int64_t)(fMs*0.001f*(float)nTicksPerSecond);
} }
inline float MicroProfileTickToMsMultiplier(int64_t nTicksPerSecond) inline float MicroProfileTickToMsMultiplier(int64_t nTicksPerSecond)
{ {
return 1000.f / nTicksPerSecond; return 1000.f / (float)nTicksPerSecond;
} }
inline uint16_t MicroProfileGetGroupIndex(MicroProfileToken t) inline uint16_t MicroProfileGetGroupIndex(MicroProfileToken t)
@ -902,8 +902,10 @@ inline uint16_t MicroProfileGetGroupIndex(MicroProfileToken t)
#include <windows.h> #include <windows.h>
#define snprintf _snprintf #define snprintf _snprintf
#ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
#pragma warning(disable: 4244) #pragma warning(disable: 4244)
#endif
int64_t MicroProfileTicksPerSecondCpu() int64_t MicroProfileTicksPerSecondCpu()
{ {
static int64_t nTicksPerSecond = 0; static int64_t nTicksPerSecond = 0;
@ -929,14 +931,14 @@ typedef void* (*MicroProfileThreadFunc)(void*);
#ifndef _WIN32 #ifndef _WIN32
typedef pthread_t MicroProfileThread; typedef pthread_t MicroProfileThread;
void MicroProfileThreadStart(MicroProfileThread* pThread, MicroProfileThreadFunc Func) inline void MicroProfileThreadStart(MicroProfileThread* pThread, MicroProfileThreadFunc Func)
{ {
pthread_attr_t Attr; pthread_attr_t Attr;
int r = pthread_attr_init(&Attr); int r = pthread_attr_init(&Attr);
MP_ASSERT(r == 0); MP_ASSERT(r == 0);
pthread_create(pThread, &Attr, Func, 0); pthread_create(pThread, &Attr, Func, 0);
} }
void MicroProfileThreadJoin(MicroProfileThread* pThread) inline void MicroProfileThreadJoin(MicroProfileThread* pThread)
{ {
int r = pthread_join(*pThread, 0); int r = pthread_join(*pThread, 0);
MP_ASSERT(r == 0); MP_ASSERT(r == 0);
@ -953,11 +955,11 @@ DWORD _stdcall ThreadTrampoline(void* pFunc)
return static_cast<DWORD>(reinterpret_cast<uint64_t>(F(0))); return static_cast<DWORD>(reinterpret_cast<uint64_t>(F(0)));
} }
void MicroProfileThreadStart(MicroProfileThread* pThread, MicroProfileThreadFunc Func) inline void MicroProfileThreadStart(MicroProfileThread* pThread, MicroProfileThreadFunc Func)
{ {
*pThread = CreateThread(0, 0, ThreadTrampoline, Func, 0, 0); *pThread = CreateThread(0, 0, ThreadTrampoline, Func, 0, 0);
} }
void MicroProfileThreadJoin(MicroProfileThread* pThread) inline void MicroProfileThreadJoin(MicroProfileThread* pThread)
{ {
WaitForSingleObject(*pThread, INFINITE); WaitForSingleObject(*pThread, INFINITE);
CloseHandle(*pThread); CloseHandle(*pThread);
@ -1154,7 +1156,7 @@ inline void MicroProfileSetThreadLog(MicroProfileThreadLog* pLog)
pthread_setspecific(g_MicroProfileThreadLogKey, pLog); pthread_setspecific(g_MicroProfileThreadLogKey, pLog);
} }
#else #else
MicroProfileThreadLog* MicroProfileGetThreadLog() inline MicroProfileThreadLog* MicroProfileGetThreadLog()
{ {
return g_MicroProfileThreadLog; return g_MicroProfileThreadLog;
} }
@ -1270,7 +1272,7 @@ MicroProfileToken MicroProfileFindToken(const char* pGroup, const char* pName)
return MICROPROFILE_INVALID_TOKEN; return MICROPROFILE_INVALID_TOKEN;
} }
uint16_t MicroProfileGetGroup(const char* pGroup, MicroProfileTokenType Type) inline uint16_t MicroProfileGetGroup(const char* pGroup, MicroProfileTokenType Type)
{ {
for(uint32_t i = 0; i < S.nGroupCount; ++i) for(uint32_t i = 0; i < S.nGroupCount; ++i)
{ {
@ -1299,7 +1301,7 @@ uint16_t MicroProfileGetGroup(const char* pGroup, MicroProfileTokenType Type)
return nGroupIndex; return nGroupIndex;
} }
void MicroProfileRegisterGroup(const char* pGroup, const char* pCategory, uint32_t nColor) inline void MicroProfileRegisterGroup(const char* pGroup, const char* pCategory, uint32_t nColor)
{ {
int nCategoryIndex = -1; int nCategoryIndex = -1;
for(uint32_t i = 0; i < S.nCategoryCount; ++i) for(uint32_t i = 0; i < S.nCategoryCount; ++i)
@ -1465,7 +1467,7 @@ void MicroProfileGpuLeave(MicroProfileToken nToken_, uint64_t nTickStart)
} }
} }
void MicroProfileContextSwitchPut(MicroProfileContextSwitch* pContextSwitch) inline void MicroProfileContextSwitchPut(MicroProfileContextSwitch* pContextSwitch)
{ {
if(S.nRunning || pContextSwitch->nTicks <= S.nPauseTicks) if(S.nRunning || pContextSwitch->nTicks <= S.nPauseTicks)
{ {
@ -1746,10 +1748,10 @@ void MicroProfileFlip()
} }
} }
} }
for(uint32_t i = 0; i < MICROPROFILE_MAX_GROUPS; ++i) for(uint32_t j = 0; j < MICROPROFILE_MAX_GROUPS; ++j)
{ {
pLog->nGroupTicks[i] += nGroupTicks[i]; pLog->nGroupTicks[j] += nGroupTicks[j];
pFrameGroup[i] += nGroupTicks[i]; pFrameGroup[j] += nGroupTicks[j];
} }
pLog->nStackPos = nStackPos; pLog->nStackPos = nStackPos;
} }
@ -1917,7 +1919,7 @@ void MicroProfileSetEnableAllGroups(bool bEnableAllGroups)
S.nAllGroupsWanted = bEnableAllGroups ? 1 : 0; S.nAllGroupsWanted = bEnableAllGroups ? 1 : 0;
} }
void MicroProfileEnableCategory(const char* pCategory, bool bEnabled) inline void MicroProfileEnableCategory(const char* pCategory, bool bEnabled)
{ {
int nCategoryIndex = -1; int nCategoryIndex = -1;
for(uint32_t i = 0; i < S.nCategoryCount; ++i) for(uint32_t i = 0; i < S.nCategoryCount; ++i)
@ -2027,7 +2029,7 @@ void MicroProfileForceDisableGroup(const char* pGroup, MicroProfileTokenType Typ
} }
void MicroProfileCalcAllTimers(float* pTimers, float* pAverage, float* pMax, float* pCallAverage, float* pExclusive, float* pAverageExclusive, float* pMaxExclusive, float* pTotal, uint32_t nSize) inline void MicroProfileCalcAllTimers(float* pTimers, float* pAverage, float* pMax, float* pCallAverage, float* pExclusive, float* pAverageExclusive, float* pMaxExclusive, float* pTotal, uint32_t nSize)
{ {
for(uint32_t i = 0; i < S.nTotalTimers && i < nSize; ++i) for(uint32_t i = 0; i < S.nTotalTimers && i < nSize; ++i)
{ {
@ -3332,7 +3334,7 @@ bool MicroProfileIsLocalThread(uint32_t nThreadId)
#endif #endif
#else #else
bool MicroProfileIsLocalThread(uint32_t nThreadId){return false;} bool MicroProfileIsLocalThread([[maybe_unused]] uint32_t nThreadId) { return false; }
void MicroProfileStopContextSwitchTrace(){} void MicroProfileStopContextSwitchTrace(){}
void MicroProfileStartContextSwitchTrace(){} void MicroProfileStartContextSwitchTrace(){}
@ -3580,7 +3582,7 @@ int MicroProfileGetGpuTickReference(int64_t* pOutCpu, int64_t* pOutGpu)
#undef S #undef S
#ifdef _WIN32 #ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
#endif #endif

View File

@ -46,7 +46,16 @@ if (MSVC)
# Warnings # Warnings
/W3 /W3
/we4062 # enumerator 'identifier' in a switch of enum 'enumeration' is not handled
/we4101 # 'identifier': unreferenced local variable
/we4265 # 'class': class has virtual functions, but destructor is not virtual
/we4267 # 'var': conversion from 'size_t' to 'type', possible loss of data /we4267 # 'var': conversion from 'size_t' to 'type', possible loss of data
/we4388 # signed/unsigned mismatch
/we4547 # 'operator' : operator before comma has no effect; expected operator with side-effect
/we4549 # 'operator1': operator before comma has no effect; did you intend 'operator2'?
/we4555 # Expression has no effect; expected expression with side-effect
/we4834 # Discarding return value of function with 'nodiscard' attribute
/we5038 # data member 'member1' will be initialized after data member 'member2'
) )
else() else()
add_compile_options( add_compile_options(
@ -64,7 +73,16 @@ if (MSVC)
# Warnings # Warnings
/W3 /W3
/we4062 # enumerator 'identifier' in a switch of enum 'enumeration' is not handled
/we4101 # 'identifier': unreferenced local variable
/we4265 # 'class': class has virtual functions, but destructor is not virtual
/we4267 # 'var': conversion from 'size_t' to 'type', possible loss of data /we4267 # 'var': conversion from 'size_t' to 'type', possible loss of data
/we4388 # signed/unsigned mismatch
/we4547 # 'operator' : operator before comma has no effect; expected operator with side-effect
/we4549 # 'operator1': operator before comma has no effect; did you intend 'operator2'?
/we4555 # Expression has no effect; expected expression with side-effect
/we4834 # Discarding return value of function with 'nodiscard' attribute
/we5038 # data member 'member1' will be initialized after data member 'member2'
) )
endif() endif()

View File

@ -139,7 +139,8 @@ static void OnNetworkError(const Network::RoomMember::Error& error) {
LOG_ERROR(Network, "You have been banned by the host"); LOG_ERROR(Network, "You have been banned by the host");
break; break;
default: default:
LOG_ERROR(Network, "Unknown network error {}", error); LOG_ERROR(Network, "Unknown network error: {}", error);
break;
} }
} }

View File

@ -138,7 +138,7 @@ public:
// Only implemented for T=float // Only implemented for T=float
[[nodiscard]] float Length() const; [[nodiscard]] float Length() const;
[[nodiscard]] float Normalize(); // returns the previous length, which is often useful float Normalize(); // returns the previous length, which is often useful
[[nodiscard]] constexpr T& operator[](std::size_t i) { [[nodiscard]] constexpr T& operator[](std::size_t i) {
return *((&x) + i); return *((&x) + i);
@ -314,7 +314,7 @@ public:
// Only implemented for T=float // Only implemented for T=float
[[nodiscard]] float Length() const; [[nodiscard]] float Length() const;
[[nodiscard]] Vec3 Normalized() const; [[nodiscard]] Vec3 Normalized() const;
[[nodiscard]] float Normalize(); // returns the previous length, which is often useful float Normalize(); // returns the previous length, which is often useful
[[nodiscard]] constexpr T& operator[](std::size_t i) { [[nodiscard]] constexpr T& operator[](std::size_t i) {
return *((&x) + i); return *((&x) + i);

View File

@ -45,7 +45,7 @@ void CheatEngine::AddCheat(const std::shared_ptr<CheatBase>& cheat) {
cheats_list.push_back(cheat); cheats_list.push_back(cheat);
} }
void CheatEngine::RemoveCheat(int index) { void CheatEngine::RemoveCheat(std::size_t index) {
std::unique_lock<std::shared_mutex> lock(cheats_list_mutex); std::unique_lock<std::shared_mutex> lock(cheats_list_mutex);
if (index < 0 || index >= static_cast<int>(cheats_list.size())) { if (index < 0 || index >= static_cast<int>(cheats_list.size())) {
LOG_ERROR(Core_Cheats, "Invalid index {}", index); LOG_ERROR(Core_Cheats, "Invalid index {}", index);
@ -54,7 +54,7 @@ void CheatEngine::RemoveCheat(int index) {
cheats_list.erase(cheats_list.begin() + index); cheats_list.erase(cheats_list.begin() + index);
} }
void CheatEngine::UpdateCheat(int index, const std::shared_ptr<CheatBase>& new_cheat) { void CheatEngine::UpdateCheat(std::size_t index, const std::shared_ptr<CheatBase>& new_cheat) {
std::unique_lock<std::shared_mutex> lock(cheats_list_mutex); std::unique_lock<std::shared_mutex> lock(cheats_list_mutex);
if (index < 0 || index >= static_cast<int>(cheats_list.size())) { if (index < 0 || index >= static_cast<int>(cheats_list.size())) {
LOG_ERROR(Core_Cheats, "Invalid index {}", index); LOG_ERROR(Core_Cheats, "Invalid index {}", index);

View File

@ -29,8 +29,8 @@ public:
void Connect(); void Connect();
std::vector<std::shared_ptr<CheatBase>> GetCheats() const; std::vector<std::shared_ptr<CheatBase>> GetCheats() const;
void AddCheat(const std::shared_ptr<CheatBase>& cheat); void AddCheat(const std::shared_ptr<CheatBase>& cheat);
void RemoveCheat(int index); void RemoveCheat(std::size_t index);
void UpdateCheat(int index, const std::shared_ptr<CheatBase>& new_cheat); void UpdateCheat(std::size_t index, const std::shared_ptr<CheatBase>& new_cheat);
void SaveCheatFile() const; void SaveCheatFile() const;
private: private:

View File

@ -705,7 +705,7 @@ static bool IsDataAvailable() {
fd_set fd_socket; fd_set fd_socket;
FD_ZERO(&fd_socket); FD_ZERO(&fd_socket);
FD_SET(gdbserver_socket, &fd_socket); FD_SET(static_cast<u32>(gdbserver_socket), &fd_socket);
struct timeval t; struct timeval t;
t.tv_sec = 0; t.tv_sec = 0;

View File

@ -198,7 +198,7 @@ void ExtraHID::HandleReadCalibrationDataRequest(const std::vector<u8>& request_b
const u16 offset = Common::AlignDown(request.offset, 16); const u16 offset = Common::AlignDown(request.offset, 16);
const u16 size = Common::AlignDown(request.size, 16); const u16 size = Common::AlignDown(request.size, 16);
if (offset + size > calibration_data.size()) { if (static_cast<std::size_t>(offset + size) > calibration_data.size()) {
LOG_ERROR(Service_IR, "Read beyond the end of calibration data! (offset={}, size={})", LOG_ERROR(Service_IR, "Read beyond the end of calibration data! (offset={}, size={})",
offset, size); offset, size);
return; return;

View File

@ -93,8 +93,9 @@ static void SetShaderUniformBlockBinding(GLuint shader, const char* name, Unifor
} }
GLint ub_size = 0; GLint ub_size = 0;
glGetActiveUniformBlockiv(shader, ub_index, GL_UNIFORM_BLOCK_DATA_SIZE, &ub_size); glGetActiveUniformBlockiv(shader, ub_index, GL_UNIFORM_BLOCK_DATA_SIZE, &ub_size);
ASSERT_MSG(ub_size == expected_size, "Uniform block size did not match! Got {}, expected {}", ASSERT_MSG(static_cast<std::size_t>(ub_size) == expected_size,
static_cast<int>(ub_size), expected_size); "Uniform block size did not match! Got {}, expected {}", static_cast<int>(ub_size),
expected_size);
glUniformBlockBinding(shader, ub_index, static_cast<GLuint>(binding)); glUniformBlockBinding(shader, ub_index, static_cast<GLuint>(binding));
} }

View File

@ -192,7 +192,8 @@ void JitShader::Compile_SwizzleSrc(Instruction instr, unsigned src_num, SourceRe
} }
int src_offset_disp = (int)src_offset; int src_offset_disp = (int)src_offset;
ASSERT_MSG(src_offset == src_offset_disp, "Source register offset too large for int type"); ASSERT_MSG(src_offset == static_cast<std::size_t>(src_offset_disp),
"Source register offset too large for int type");
unsigned operand_desc_id; unsigned operand_desc_id;