Resolve or silence some warnings (#1905)

* Resolve some warnings

- Their frequent appearance in the build logs is driving me nuts

* Silence warnings about `offsetof`

* Don't apply `-Wno-invalid-offset` to C, only to C++
This commit is contained in:
Jesse Talavera 2023-12-28 08:54:31 -05:00 committed by GitHub
parent 6d0de509c4
commit a4b2b0c40d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 40 additions and 29 deletions

View File

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

View File

@ -128,6 +128,15 @@ add_subdirectory(teakra EXCLUDE_FROM_ALL)
target_compile_options(teakra PRIVATE "$<$<CONFIG:DEBUG>:-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 "$<$<COMPILE_LANGUAGE:CXX>:-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)

View File

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

View File

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

View File

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

View File

@ -621,6 +621,8 @@ s32 SPUChannel::Run()
(PrevSample[0] * InterpCubic[samplepos][2]) +
(val * InterpCubic[samplepos][3])) >> 14;
break;
default:
break;
}
}