diff --git a/src/ARMJIT_A64/ARMJIT_Compiler.h b/src/ARMJIT_A64/ARMJIT_Compiler.h index 04f12e85..2b0048a9 100644 --- a/src/ARMJIT_A64/ARMJIT_Compiler.h +++ b/src/ARMJIT_A64/ARMJIT_Compiler.h @@ -69,7 +69,7 @@ struct Op2 bool IsSimpleReg() { return !IsImm && !Reg.ShiftAmount && Reg.ShiftType == Arm64Gen::ST_LSL; } bool ImmFits12Bit() - { return IsImm && (Imm & 0xFFF == Imm); } + { return IsImm && ((Imm & 0xFFF) == Imm); } bool IsZero() { return IsImm && !Imm; } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b1ae4c47..afabc03f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -128,6 +128,15 @@ add_subdirectory(teakra EXCLUDE_FROM_ALL) target_compile_options(teakra PRIVATE "$<$:-Og>") target_link_libraries(core PRIVATE teakra) +if (NOT MSVC) + # MSVC has its own compiler flag syntax; if we ever support it, + # be sure to silence any equivalent warnings there. + + target_compile_options(core PRIVATE "$<$:-Wno-invalid-offsetof>") + # These warnings are excessive, and are only triggered in the ARMJIT code + # (which is fundamentally non-portable, so this is fine) +endif() + find_library(m MATH_LIBRARY) if (MATH_LIBRARY) diff --git a/src/GPU3D_OpenGL.cpp b/src/GPU3D_OpenGL.cpp index 27711a89..3e9ce5b0 100644 --- a/src/GPU3D_OpenGL.cpp +++ b/src/GPU3D_OpenGL.cpp @@ -31,7 +31,7 @@ namespace melonDS bool GLRenderer::BuildRenderShader(u32 flags, const char* vs, const char* fs) { char shadername[32]; - sprintf(shadername, "RenderShader%02X", flags); + snprintf(shadername, sizeof(shadername), "RenderShader%02X", flags); int headerlen = strlen(kShaderHeader); diff --git a/src/GPU3D_Soft.h b/src/GPU3D_Soft.h index 8fb42013..de65944e 100644 --- a/src/GPU3D_Soft.h +++ b/src/GPU3D_Soft.h @@ -178,7 +178,7 @@ private: { // Z-buffering: linear interpolation // still doesn't quite match hardware... - s32 base, disp, factor; + s32 base = 0, disp = 0, factor = 0; if (z0 < z1) { @@ -337,7 +337,7 @@ private: constexpr s32 XVal() const { - s32 ret; + s32 ret = 0; if (Negative) ret = x0 - (dx >> 18); else ret = x0 + (dx >> 18); diff --git a/src/NDS.cpp b/src/NDS.cpp index 7c176fae..1d7e34a9 100644 --- a/src/NDS.cpp +++ b/src/NDS.cpp @@ -1497,40 +1497,40 @@ void NDS::NocashPrint(u32 ncpu, u32 addr) if (cmd[0] == 'r') { - if (!strcmp(cmd, "r0")) sprintf(subs, "%08X", cpu->R[0]); - else if (!strcmp(cmd, "r1")) sprintf(subs, "%08X", cpu->R[1]); - else if (!strcmp(cmd, "r2")) sprintf(subs, "%08X", cpu->R[2]); - else if (!strcmp(cmd, "r3")) sprintf(subs, "%08X", cpu->R[3]); - else if (!strcmp(cmd, "r4")) sprintf(subs, "%08X", cpu->R[4]); - else if (!strcmp(cmd, "r5")) sprintf(subs, "%08X", cpu->R[5]); - else if (!strcmp(cmd, "r6")) sprintf(subs, "%08X", cpu->R[6]); - else if (!strcmp(cmd, "r7")) sprintf(subs, "%08X", cpu->R[7]); - else if (!strcmp(cmd, "r8")) sprintf(subs, "%08X", cpu->R[8]); - else if (!strcmp(cmd, "r9")) sprintf(subs, "%08X", cpu->R[9]); - else if (!strcmp(cmd, "r10")) sprintf(subs, "%08X", cpu->R[10]); - else if (!strcmp(cmd, "r11")) sprintf(subs, "%08X", cpu->R[11]); - else if (!strcmp(cmd, "r12")) sprintf(subs, "%08X", cpu->R[12]); - else if (!strcmp(cmd, "r13")) sprintf(subs, "%08X", cpu->R[13]); - else if (!strcmp(cmd, "r14")) sprintf(subs, "%08X", cpu->R[14]); - else if (!strcmp(cmd, "r15")) sprintf(subs, "%08X", cpu->R[15]); + if (!strcmp(cmd, "r0")) snprintf(subs, sizeof(subs), "%08X", cpu->R[0]); + else if (!strcmp(cmd, "r1")) snprintf(subs, sizeof(subs), "%08X", cpu->R[1]); + else if (!strcmp(cmd, "r2")) snprintf(subs, sizeof(subs), "%08X", cpu->R[2]); + else if (!strcmp(cmd, "r3")) snprintf(subs, sizeof(subs), "%08X", cpu->R[3]); + else if (!strcmp(cmd, "r4")) snprintf(subs, sizeof(subs), "%08X", cpu->R[4]); + else if (!strcmp(cmd, "r5")) snprintf(subs, sizeof(subs), "%08X", cpu->R[5]); + else if (!strcmp(cmd, "r6")) snprintf(subs, sizeof(subs), "%08X", cpu->R[6]); + else if (!strcmp(cmd, "r7")) snprintf(subs, sizeof(subs), "%08X", cpu->R[7]); + else if (!strcmp(cmd, "r8")) snprintf(subs, sizeof(subs), "%08X", cpu->R[8]); + else if (!strcmp(cmd, "r9")) snprintf(subs, sizeof(subs), "%08X", cpu->R[9]); + else if (!strcmp(cmd, "r10")) snprintf(subs, sizeof(subs), "%08X", cpu->R[10]); + else if (!strcmp(cmd, "r11")) snprintf(subs, sizeof(subs), "%08X", cpu->R[11]); + else if (!strcmp(cmd, "r12")) snprintf(subs, sizeof(subs), "%08X", cpu->R[12]); + else if (!strcmp(cmd, "r13")) snprintf(subs, sizeof(subs), "%08X", cpu->R[13]); + else if (!strcmp(cmd, "r14")) snprintf(subs, sizeof(subs), "%08X", cpu->R[14]); + else if (!strcmp(cmd, "r15")) snprintf(subs, sizeof(subs), "%08X", cpu->R[15]); } else { - if (!strcmp(cmd, "sp")) sprintf(subs, "%08X", cpu->R[13]); - else if (!strcmp(cmd, "lr")) sprintf(subs, "%08X", cpu->R[14]); - else if (!strcmp(cmd, "pc")) sprintf(subs, "%08X", cpu->R[15]); - else if (!strcmp(cmd, "frame")) sprintf(subs, "%u", NumFrames); - else if (!strcmp(cmd, "scanline")) sprintf(subs, "%u", GPU.VCount); - else if (!strcmp(cmd, "totalclks")) sprintf(subs, "%" PRIu64, GetSysClockCycles(0)); - else if (!strcmp(cmd, "lastclks")) sprintf(subs, "%" PRIu64, GetSysClockCycles(1)); + if (!strcmp(cmd, "sp")) snprintf(subs, sizeof(subs), "%08X", cpu->R[13]); + else if (!strcmp(cmd, "lr")) snprintf(subs, sizeof(subs), "%08X", cpu->R[14]); + else if (!strcmp(cmd, "pc")) snprintf(subs, sizeof(subs), "%08X", cpu->R[15]); + else if (!strcmp(cmd, "frame")) snprintf(subs, sizeof(subs), "%u", NumFrames); + else if (!strcmp(cmd, "scanline")) snprintf(subs, sizeof(subs), "%u", GPU.VCount); + else if (!strcmp(cmd, "totalclks")) snprintf(subs, sizeof(subs), "%" PRIu64, GetSysClockCycles(0)); + else if (!strcmp(cmd, "lastclks")) snprintf(subs, sizeof(subs), "%" PRIu64, GetSysClockCycles(1)); else if (!strcmp(cmd, "zeroclks")) { - sprintf(subs, "%s", ""); + snprintf(subs, sizeof(subs), "%s", ""); GetSysClockCycles(1); } } - int slen = strlen(subs); + int slen = strnlen(subs, sizeof(subs)); if ((ptr+slen) > 1023) slen = 1023-ptr; strncpy(&output[ptr], subs, slen); ptr += slen; diff --git a/src/SPU.cpp b/src/SPU.cpp index f0d59464..86307097 100644 --- a/src/SPU.cpp +++ b/src/SPU.cpp @@ -621,6 +621,8 @@ s32 SPUChannel::Run() (PrevSample[0] * InterpCubic[samplepos][2]) + (val * InterpCubic[samplepos][3])) >> 14; break; + default: + break; } }