1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-12 01:40:47 +00:00

Fix some more GCC warnings, mark some bugs based on GCC warnings (#2309)

* Fix some more GCC warnings, mark some bugs based on GCC warnings

* Weird formatting

* Suggested changes

* More weird indentation I guess

* UNREACHABLE() macro, add missing NORETURNs to fault_n64.c

* AVOID_UB for PAL path in z_file_nameset.c

* Remove comments about return types

* Remove temp no longer needed
This commit is contained in:
Tharo 2024-12-02 09:40:49 +00:00 committed by GitHub
parent 6199634ffb
commit 3f703a39d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 156 additions and 83 deletions

View file

@ -1146,6 +1146,8 @@ void BossVa_BodyPhase2(BossVa* this, PlayState* play) {
sKillBari++;
if ((this->actor.colorFilterTimer != 0) && !(this->actor.colorFilterParams & 0x4000)) {
this->invincibilityTimer = this->actor.colorFilterTimer - 5;
//! @bug This condition is always false as this->invincibilityTimer is an s8 so can never
//! be larger than 160.
if (this->invincibilityTimer > 160) {
this->invincibilityTimer = 0;
}

View file

@ -230,7 +230,8 @@ s32 DemoGj_FindGanon(DemoGj* this, PlayState* play) {
PRINTF("Demo_Gj_Search_Boss_Ganon %d:ガノン発見出来ず\n", this->dyna.actor.params);
return false;
}
//! @bug: Missing return value when `this->ganon` is already set.
//! @bug Missing return value when `this->ganon` is already set. No caller uses the return value
//! so it doesn't matter.
}
static InitChainEntry sInitChain[] = {

View file

@ -834,6 +834,8 @@ s32 EnKo_ChildStart(EnKo* this, PlayState* play) {
case ENKO_TYPE_CHILD_FADO:
return func_80A97E18(this, play);
}
// Note this function assumes the kokiri type is valid
UNREACHABLE();
}
s32 EnKo_ChildStone(EnKo* this, PlayState* play) {
@ -865,6 +867,8 @@ s32 EnKo_ChildStone(EnKo* this, PlayState* play) {
case ENKO_TYPE_CHILD_FADO:
return func_80A97E18(this, play);
}
// Note this function assumes the kokiri type is valid
UNREACHABLE();
}
s32 EnKo_ChildSaria(EnKo* this, PlayState* play) {
@ -896,6 +900,8 @@ s32 EnKo_ChildSaria(EnKo* this, PlayState* play) {
case ENKO_TYPE_CHILD_FADO:
return func_80A97E18(this, play);
}
// Note this function assumes the kokiri type is valid
UNREACHABLE();
}
s32 EnKo_AdultEnemy(EnKo* this, PlayState* play) {
@ -927,6 +933,8 @@ s32 EnKo_AdultEnemy(EnKo* this, PlayState* play) {
case ENKO_TYPE_CHILD_FADO:
return func_80A97E18(this, play);
}
// Note this function assumes the kokiri type is valid
UNREACHABLE();
}
s32 EnKo_AdultSaved(EnKo* this, PlayState* play) {
@ -958,7 +966,10 @@ s32 EnKo_AdultSaved(EnKo* this, PlayState* play) {
case ENKO_TYPE_CHILD_FADO:
return func_80A97E18(this, play);
}
// Note this function assumes the kokiri type is valid
UNREACHABLE();
}
void func_80A9877C(EnKo* this, PlayState* play) {
Player* player = GET_PLAYER(play);
@ -1136,6 +1147,8 @@ s32 func_80A98ECC(EnKo* this, PlayState* play) {
case ENKO_FQS_ADULT_SAVED:
return EnKo_AdultSaved(this, play);
}
// Note this function assumes the kokiri type is valid
UNREACHABLE();
}
void EnKo_Init(Actor* thisx, PlayState* play) {

View file

@ -563,7 +563,9 @@ s32 EnSt_DecrStunTimer(EnSt* this) {
if (this->stunTimer == 0) {
return 0;
}
this->stunTimer--; //! @bug no return but v0 ends up being stunTimer before decrement
this->stunTimer--;
//! @bug No return, v0 ends up being stunTimer before decrement.
//! The return value is not used so it doesn't matter.
}
/**

View file

@ -111,7 +111,7 @@ s32 func_80B0BE20(EnSw* this, CollisionPoly* poly) {
this->unk_3D8.zw = 0.0f;
this->unk_3D8.ww = 1.0f;
Matrix_MtxFToYXZRotS(&this->unk_3D8, &this->actor.world.rot, 0);
//! @bug: Does not return.
//! @bug Does not return, but the return value is not used by any caller so it doesn't matter.
}
CollisionPoly* func_80B0C020(PlayState* play, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, s32* arg4) {

View file

@ -651,7 +651,7 @@ void EnfHG_Retreat(EnfHG* this, PlayState* play) {
BossGanondrof* bossGnd = (BossGanondrof*)this->actor.parent;
s16 paintingIdxReal;
s16 paintingIdxFake;
Actor* child;
UNUSED_NDEBUG Actor* child;
if (this->actor.params != GND_REAL_BOSS) {
this->killActor = true;

View file

@ -1700,7 +1700,6 @@ BAD_RETURN(s32) Player_ZeroSpeedXZ(Player* this) {
this->speedXZ = 0.0f;
}
// return type can't be void due to regalloc in func_8083F72C
BAD_RETURN(s32) func_80832224(Player* this) {
Player_ZeroSpeedXZ(this);
this->unk_6AD = 0;
@ -12117,7 +12116,9 @@ void Player_Update(Actor* thisx, PlayState* play) {
Player_UpdateCommon(this, play, &input);
#if DEBUG_FEATURES
skip_update:;
#endif
{
s32 pad;

View file

@ -64,7 +64,7 @@ void FileSelect_SetKeyboardVtx(GameState* thisx) {
phi_s1 = 0x26;
#if OOT_NTSC
for (phi_t2 = 0, phi_s2 = 0, phi_t3 = 0; phi_s2 < 5; phi_s2++) {
for (phi_s2 = 0, phi_t3 = 0; phi_s2 < 5; phi_s2++) {
for (phi_t0 = -0x60, phi_t1 = 0; phi_t1 < 13; phi_t1++, phi_t3 += 4) {
this->keyboardVtx[phi_t3].v.ob[0] = this->keyboardVtx[phi_t3 + 2].v.ob[0] = phi_t0;
this->keyboardVtx[phi_t3 + 1].v.ob[0] = this->keyboardVtx[phi_t3 + 3].v.ob[0] = phi_t0 + 12;
@ -1747,13 +1747,21 @@ void FileSelect_DrawOptionsImpl(GameState* thisx) {
gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255);
}
#ifndef AVOID_UB
//! @bug Mistakenly using sOptionsMenuHeaders instead of sOptionsMenuSettings for the height.
//! This is also an OOB read that happens to access the height of the first two elements in
//! sOptionsMenuSettings, and since all heights are 16, it works out anyway.
#define sOptionsMenuSettingsBug sOptionsMenuHeaders
#else
// Avoid UB: Use the correct array for the heights to avoid reading out of bounds memory that may not
// happen to work out nicely.
#define sOptionsMenuSettingsBug sOptionsMenuSettings
#endif
gDPLoadTextureBlock(POLY_OPA_DISP++, sOptionsMenuSettings[i].texture[gSaveContext.language], G_IM_FMT_IA,
G_IM_SIZ_8b, OPTIONS_MENU_TEXTURE_WIDTH(sOptionsMenuSettings[i]),
OPTIONS_MENU_TEXTURE_HEIGHT(sOptionsMenuHeaders[i]), 0, G_TX_NOMIRROR | G_TX_WRAP,
OPTIONS_MENU_TEXTURE_HEIGHT(sOptionsMenuSettingsBug[i]), 0, G_TX_NOMIRROR | G_TX_WRAP,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
#undef sOptionsMenuSettingsBug
gSP1Quadrangle(POLY_OPA_DISP++, vtx, vtx + 2, vtx + 3, vtx + 1, 0);
}
#else
@ -1786,10 +1794,21 @@ void FileSelect_DrawOptionsImpl(GameState* thisx) {
gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255);
}
#ifndef AVOID_UB
//! @bug Mistakenly using sOptionsMenuHeaders instead of sOptionsMenuSettings for the height.
//! This is also an OOB read that happens to access the height of up to the first three elements
//! in sOptionsMenuSettings, and since all heights are 16, it works out anyway.
#define sOptionsMenuSettingsBug sOptionsMenuHeaders
#else
// Avoid UB: Use the correct array for the heights to avoid reading out of bounds memory that may not
// happen to work out nicely.
#define sOptionsMenuSettingsBug sOptionsMenuSettings
#endif
gDPLoadTextureBlock(POLY_OPA_DISP++, sOptionsMenuSettings[i].texture[gSaveContext.language], G_IM_FMT_IA,
G_IM_SIZ_8b, sZTargetSettingWidths[j][gSaveContext.language],
OPTIONS_MENU_TEXTURE_HEIGHT(sOptionsMenuHeaders[i]), 0, G_TX_NOMIRROR | G_TX_WRAP,
OPTIONS_MENU_TEXTURE_HEIGHT(sOptionsMenuSettingsBug[i]), 0, G_TX_NOMIRROR | G_TX_WRAP,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
#undef sOptionsMenuSettingsBug
gSP1Quadrangle(POLY_OPA_DISP++, vtx, vtx + 2, vtx + 3, vtx + 1, 0);
}