summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/audio/lib/load.c12
-rw-r--r--src/boot/cic6105.c8
-rw-r--r--src/boot/z_std_dma.c2
-rw-r--r--src/code/db_camera.c4
-rw-r--r--src/code/fault_gc.c4
-rw-r--r--src/code/fault_n64.c4
-rw-r--r--src/code/game.c4
-rw-r--r--src/code/sys_cfb.c2
-rw-r--r--src/code/ucode_disas.c4
-rw-r--r--src/code/z_actor.c3
-rw-r--r--src/code/z_actor_dlftbls.c4
-rw-r--r--src/code/z_bgcheck.c2
-rw-r--r--src/code/z_camera.c42
-rw-r--r--src/code/z_jpeg.c2
-rw-r--r--src/code/z_lights.c3
-rw-r--r--src/code/z_parameter.c2
-rw-r--r--src/code/z_play.c3
-rw-r--r--src/code/z_view.c2
-rw-r--r--src/code/z_vimode.c8
-rw-r--r--src/code/z_vismono.c2
-rw-r--r--src/libleo/api/cacreateleomanager.c2
-rw-r--r--src/libleo/api/cjcreateleomanager.c2
-rw-r--r--src/libleo/leo/leomecha.c7
-rw-r--r--src/libleo/leo/leotimer.c2
-rw-r--r--src/libu64/relocation_gc.c2
-rw-r--r--src/libu64/stackcheck.c4
-rw-r--r--src/libultra/os/settimer.c2
-rw-r--r--src/overlays/actors/ovl_Boss_Va/z_boss_va.c2
-rw-r--r--src/overlays/actors/ovl_Demo_Gj/z_demo_gj.c3
-rw-r--r--src/overlays/actors/ovl_En_Ko/z_en_ko.c13
-rw-r--r--src/overlays/actors/ovl_En_St/z_en_st.c4
-rw-r--r--src/overlays/actors/ovl_En_Sw/z_en_sw.c2
-rw-r--r--src/overlays/actors/ovl_En_fHG/z_en_fhg.c2
-rw-r--r--src/overlays/actors/ovl_player_actor/z_player.c3
-rw-r--r--src/overlays/gamestates/ovl_file_choose/z_file_nameset.c25
35 files changed, 124 insertions, 68 deletions
diff --git a/src/audio/lib/load.c b/src/audio/lib/load.c
index 99217c61f..3e66c7932 100644
--- a/src/audio/lib/load.c
+++ b/src/audio/lib/load.c
@@ -410,6 +410,7 @@ s32 AudioLoad_SyncLoadSample(Sample* sample, s32 fontId) {
sample->sampleAddr = sampleAddr;
}
}
+ //! @bug Missing return, but the return value is never used so it's fine.
}
s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) {
@@ -426,6 +427,7 @@ s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) {
if (instrument->normalRangeHi != 0x7F) {
return AudioLoad_SyncLoadSample(instrument->highPitchTunedSample.sample, fontId);
}
+ //! @bug Missing return, but the return value is never used so it's fine.
} else if (instId == 0x7F) {
Drum* drum = Audio_GetDrum(fontId, drumId);
@@ -508,10 +510,10 @@ s32 AudioLoad_SyncInitSeqPlayer(s32 playerIdx, s32 seqId, s32 arg2) {
gAudioCtx.seqPlayers[playerIdx].skipTicks = 0;
AudioLoad_SyncInitSeqPlayerInternal(playerIdx, seqId, arg2);
- // Intentionally missing return. Returning the result of the above function
- // call matches but is UB because it too is missing a return, and using the
- // result of a non-void function that has failed to return a value is UB.
- // The callers of this function do not use the return value, so it's fine.
+ //! @bug Missing return. Returning the result of the above function call
+ //! matches but is UB because it too is missing a return, and using the
+ //! result of a non-void function that has failed to return a value is UB.
+ //! The callers of this function do not use the return value, so it's fine.
}
s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIdx, s32 seqId, s32 skipTicks) {
@@ -521,7 +523,7 @@ s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIdx, s32 seqId, s32 skipTicks
gAudioCtx.seqPlayers[playerIdx].skipTicks = skipTicks;
AudioLoad_SyncInitSeqPlayerInternal(playerIdx, seqId, 0);
- // Missing return, see above.
+ //! @bug Missing return, see comment in AudioLoad_SyncInitSeqPlayer above.
}
s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) {
diff --git a/src/boot/cic6105.c b/src/boot/cic6105.c
index 85ae47b0c..5ef47053f 100644
--- a/src/boot/cic6105.c
+++ b/src/boot/cic6105.c
@@ -10,11 +10,11 @@ OSTask D_800067C0_unknown = {
4, 0, rspbootTextStart, 0x3E8, cic6105TextStart, 0x20, (u64*)gBuildCreator, 8, NULL, 0, NULL, 0, NULL, 0, NULL, 0,
};
-s32 B_80008EE0;
-s32 B_80008EE4;
+u32 B_80008EE0;
+u32 B_80008EE4;
FaultClient sCIC6105FaultClient;
-s32 B_80008EF8;
-s32 B_80008EFC;
+u32 B_80008EF8;
+u32 B_80008EFC;
void func_800014D0(void) {
R_AUDIOMGR_DEBUG_LEVEL = AUDIOMGR_DEBUG_LEVEL_NO_RSP;
diff --git a/src/boot/z_std_dma.c b/src/boot/z_std_dma.c
index f5d5cda9c..72d04dce1 100644
--- a/src/boot/z_std_dma.c
+++ b/src/boot/z_std_dma.c
@@ -367,7 +367,7 @@ void DmaMgr_ProcessRequest(DmaRequest* req) {
size_t romSize;
u8 found = false;
DmaEntry* iter;
- const char* filename;
+ UNUSED_NDEBUG const char* filename;
s32 i = 0;
#if DEBUG_FEATURES
diff --git a/src/code/db_camera.c b/src/code/db_camera.c
index 242609295..7d81dafc9 100644
--- a/src/code/db_camera.c
+++ b/src/code/db_camera.c
@@ -1,5 +1,7 @@
#include "global.h"
+#if DEBUG_FEATURES
+
#define DEBUG_CAM_CONTROLLER_PORT 2
static PlayState* sPlay;
@@ -2366,3 +2368,5 @@ void func_800BB060(void) {
int func_800BB06C(void) {
return sDebugCamPtr->unk_00 == 2 && sDebugCamAnim.unk_0A != 0;
}
+
+#endif
diff --git a/src/code/fault_gc.c b/src/code/fault_gc.c
index e9b7de4b6..13dfb670a 100644
--- a/src/code/fault_gc.c
+++ b/src/code/fault_gc.c
@@ -1327,9 +1327,7 @@ NORETURN void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2) {
// Since the above line triggers an exception and transfers execution to the fault handler
// this function does not return and the rest of the function is unreachable.
-#ifdef __GNUC__
- __builtin_unreachable();
-#endif
+ UNREACHABLE();
}
/**
diff --git a/src/code/fault_n64.c b/src/code/fault_n64.c
index ae8e7b8bb..7ea68abeb 100644
--- a/src/code/fault_n64.c
+++ b/src/code/fault_n64.c
@@ -822,7 +822,7 @@ void Fault_Init(void) {
osStartThread(&gFaultMgr.thread);
}
-void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2) {
+NORETURN void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2) {
gFaultMsgId = 4;
osSyncPrintf("HungUp on Thread %d", osGetThreadId(NULL));
osSyncPrintf("%s\n", exp1 != NULL ? exp1 : "(NULL)");
@@ -843,7 +843,7 @@ void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2) {
} while (true);
}
-void Fault_AddHungupAndCrash(const char* file, int line) {
+NORETURN void Fault_AddHungupAndCrash(const char* file, int line) {
char msg[256];
sprintf(msg, "HungUp %s:%d", file, line);
diff --git a/src/code/game.c b/src/code/game.c
index 8aad6bf00..bf7a4ce7c 100644
--- a/src/code/game.c
+++ b/src/code/game.c
@@ -452,8 +452,8 @@ void GameState_Realloc(GameState* gameState, size_t size) {
}
void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* gfxCtx) {
- OSTime startTime;
- OSTime endTime;
+ UNUSED_NDEBUG OSTime startTime;
+ UNUSED_NDEBUG OSTime endTime;
PRINTF(T("game コンストラクタ開始\n", "game constructor start\n"));
gameState->gfxCtx = gfxCtx;
diff --git a/src/code/sys_cfb.c b/src/code/sys_cfb.c
index c7e2933be..cbde146fa 100644
--- a/src/code/sys_cfb.c
+++ b/src/code/sys_cfb.c
@@ -8,7 +8,7 @@ uintptr_t sSysCfbEnd;
void SysCfb_Init(s32 n64dd) {
u32 screenSize;
- uintptr_t tmpFbEnd;
+ UNUSED_NDEBUG uintptr_t tmpFbEnd;
if (osMemSize >= 0x800000) {
PRINTF(T("8Mバイト以上のメモリが搭載されています\n", "8MB or more memory is installed\n"));
diff --git a/src/code/ucode_disas.c b/src/code/ucode_disas.c
index e2e782e71..ecfc7d7ac 100644
--- a/src/code/ucode_disas.c
+++ b/src/code/ucode_disas.c
@@ -1,6 +1,8 @@
#include "global.h"
#include "ucode_disas.h"
+#if DEBUG_FEATURES
+
typedef struct F3dzexConst {
/* 0x00 */ u32 value;
/* 0x04 */ const char* name;
@@ -1244,3 +1246,5 @@ void UCodeDisas_RegisterUCode(UCodeDisas* this, s32 count, UCodeInfo* ucodeArray
void UCodeDisas_SetCurUCode(UCodeDisas* this, void* ptr) {
UCodeDisas_SetCurUCodeImpl(this, ptr);
}
+
+#endif
diff --git a/src/code/z_actor.c b/src/code/z_actor.c
index b96801fc4..7c4293689 100644
--- a/src/code/z_actor.c
+++ b/src/code/z_actor.c
@@ -3204,7 +3204,7 @@ Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, PlayStat
}
Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, PlayState* play) {
- char* name;
+ UNUSED_NDEBUG char* name;
Player* player;
Actor* newHead;
ActorOverlay* overlayEntry;
@@ -4041,6 +4041,7 @@ void func_8003424C(PlayState* play, Vec3f* arg1) {
}
void Actor_SetColorFilter(Actor* actor, s16 colorFlag, s16 colorIntensityMax, s16 bufFlag, s16 duration) {
+ //! @bug This first comparison is always false as COLORFILTER_COLORFLAG_GRAY is out of range of an s16.
if ((colorFlag == COLORFILTER_COLORFLAG_GRAY) && !(colorIntensityMax & COLORFILTER_INTENSITY_FLAG)) {
Actor_PlaySfx(actor, NA_SE_EN_LIGHT_ARROW_HIT);
}
diff --git a/src/code/z_actor_dlftbls.c b/src/code/z_actor_dlftbls.c
index 65b118efd..52d8ad855 100644
--- a/src/code/z_actor_dlftbls.c
+++ b/src/code/z_actor_dlftbls.c
@@ -100,8 +100,8 @@ void ActorOverlayTable_FaultPrint(void* arg0, void* arg1) {
u32 overlaySize;
uintptr_t ramStart;
uintptr_t ramEnd;
- u32 offset;
#if PLATFORM_N64
+ u32 offset;
uintptr_t pc = gFaultFaultedThread != NULL ? gFaultFaultedThread->context.pc : 0;
uintptr_t ra = gFaultFaultedThread != NULL ? gFaultFaultedThread->context.ra : 0;
u32 i;
@@ -125,7 +125,9 @@ void ActorOverlayTable_FaultPrint(void* arg0, void* arg1) {
overlaySize = (uintptr_t)overlayEntry->vramEnd - (uintptr_t)overlayEntry->vramStart;
ramStart = (uintptr_t)overlayEntry->loadedRamAddr;
ramEnd = ramStart + overlaySize;
+#if PLATFORM_N64
offset = (uintptr_t)overlayEntry->vramStart - ramStart;
+#endif
if (ramStart != 0) {
#if PLATFORM_N64
Fault_Printf("%3d %08x-%08x %08x", i, ramStart, ramEnd, offset);
diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c
index 37d839dff..129900bdb 100644
--- a/src/code/z_bgcheck.c
+++ b/src/code/z_bgcheck.c
@@ -1541,7 +1541,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, PlayState* play, CollisionHeader
};
u32 tblMax;
u32 memSize;
- u32 lookupTblMemSize;
+ UNUSED_NDEBUG u32 lookupTblMemSize;
s32 customNodeListMax;
SSNodeList* nodeList;
u32 customMemSize;
diff --git a/src/code/z_camera.c b/src/code/z_camera.c
index aca9f4487..1ddc538dc 100644
--- a/src/code/z_camera.c
+++ b/src/code/z_camera.c
@@ -612,10 +612,10 @@ Vec3s* Camera_GetBgCamFuncData(Camera* camera) {
*/
s32 Camera_GetBgCamIndex(Camera* camera, s32* bgId, CollisionPoly* poly) {
s32 bgCamIndex;
- PosRot playerPosRot;
+ UNUSED PosRot playerPosRot;
s32 ret;
- playerPosRot = Actor_GetWorldPosShapeRot(&camera->player->actor); // unused.
+ playerPosRot = Actor_GetWorldPosShapeRot(&camera->player->actor);
bgCamIndex = SurfaceType_GetBgCamIndex(&camera->play->colCtx, poly, *bgId);
if (BgCheck_GetBgCamSettingImpl(&camera->play->colCtx, bgCamIndex, *bgId) == CAM_SET_NONE) {
@@ -947,7 +947,7 @@ void Camera_UpdateInterface(s16 interfaceField) {
Vec3f Camera_BGCheckCorner(Vec3f* linePointA, Vec3f* linePointB, CamColChk* pointAColChk, CamColChk* pointBColChk) {
Vec3f closestPoint;
- bool result;
+ UNUSED_NDEBUG bool result;
result = func_800427B4(pointAColChk->poly, pointBColChk->poly, linePointA, linePointB, &closestPoint);
#if DEBUG_FEATURES
@@ -2302,7 +2302,7 @@ s32 Camera_Parallel1(Camera* camera) {
camera->fov = Camera_LERPCeilF(roData->fovTarget, camera->fov, camera->fovUpdateRate, 1.0f);
camera->roll = Camera_LERPCeilS(0, camera->roll, 0.5, 0xA);
camera->atLERPStepScale = Camera_ClampLERPScale(camera, sp6A ? roData->unk_1C : roData->unk_14);
- //! @bug doesn't return
+ //! @bug Missing return, but the return value is not used.
}
s32 Camera_Parallel2(Camera* camera) {
@@ -2321,7 +2321,7 @@ s32 Camera_Parallel3(Camera* camera) {
if (interfaceField & PARALLEL3_FLAG_1) {
camera->stateFlags |= CAM_STATE_CAM_FUNC_FINISH;
}
- //! @bug doesn't return
+ //! @bug Missing return, but the return value is not used.
}
s32 Camera_Parallel4(Camera* camera) {
@@ -2347,7 +2347,7 @@ s32 Camera_Jump1(Camera* camera) {
VecGeo eyeDiffGeo;
VecGeo eyeDiffTarget;
PosRot* playerPosRot = &camera->playerPosRot;
- PosRot playerhead;
+ UNUSED PosRot playerhead;
s16 tangle;
Jump1ReadOnlyData* roData = &camera->paramData.jump1.roData;
Jump1ReadWriteData* rwData = &camera->paramData.jump1.rwData;
@@ -2371,7 +2371,6 @@ s32 Camera_Jump1(Camera* camera) {
CAM_DEBUG_RELOAD_PREG(camera);
- // playerhead never gets used.
playerhead = Actor_GetFocus(&camera->player->actor);
eyeAtOffset = OLib_Vec3fDiffToVecGeo(at, eye);
@@ -2490,7 +2489,7 @@ s32 Camera_Jump2(Camera* camera) {
VecGeo adjAtToEyeDir;
VecGeo bgChkPara;
VecGeo atToEyeNextDir;
- VecGeo atToEyeDir;
+ UNUSED VecGeo atToEyeDir;
f32 temp_f14;
f32 temp_f16;
f32 sp90;
@@ -3121,6 +3120,7 @@ s32 Camera_Battle1(Camera* camera) {
: 1.0f) *
(fov - ((fov * 0.05f) * distRatio)),
camera->fov, camera->fovUpdateRate, 1.0f);
+ //! @bug Missing return, but the return value is not used.
}
s32 Camera_Battle2(Camera* camera) {
@@ -3467,13 +3467,13 @@ s32 Camera_KeepOn3(Camera* camera) {
Actor* colChkActors[2];
VecGeo targetToPlayerDir;
VecGeo atToEyeAdj;
- VecGeo atToEyeDir;
+ UNUSED VecGeo atToEyeDir;
VecGeo atToEyeNextDir;
s32 i;
s32 angleCnt;
s16 sp82;
s16 sp80;
- PosRot playerPosRot;
+ UNUSED PosRot playerPosRot;
PosRot* camPlayerPosRot = &camera->playerPosRot;
KeepOn3ReadOnlyData* roData = &camera->paramData.keep3.roData;
KeepOn3ReadWriteData* rwData = &camera->paramData.keep3.rwData;
@@ -3653,7 +3653,7 @@ s32 Camera_KeepOn4(Camera* camera) {
f32 temp_f0_2;
CollisionPoly* spC0;
VecGeo spB8;
- VecGeo spB0;
+ UNUSED VecGeo spB0;
VecGeo spA8;
s16* temp_s0 = &camera->data2;
s16 spA2;
@@ -3952,6 +3952,7 @@ s32 Camera_KeepOn4(Camera* camera) {
Camera_BGCheck(camera, at, eye);
camera->fov = Camera_LERPCeilF(roData->unk_18, camera->fov, camera->fovUpdateRate, 1.0f);
camera->roll = Camera_LERPCeilS(0, camera->roll, 0.5f, 0xA);
+ //! @bug Missing return, but the return value is not used.
}
/**
@@ -4188,7 +4189,7 @@ s32 Camera_Fixed3(Camera* camera) {
Vec3f* eyeNext = &camera->eyeNext;
VecGeo atGeo;
BgCamFuncData* bgCamFuncData;
- VecGeo eyeAtOffset;
+ UNUSED VecGeo eyeAtOffset;
Fixed3ReadOnlyData* roData = &camera->paramData.fixd3.roData;
Fixed3ReadWriteData* rwData = &camera->paramData.fixd3.rwData;
s32 pad;
@@ -4346,7 +4347,7 @@ s32 Camera_Subj3(Camera* camera) {
Vec3f* at = &camera->at;
Vec3f* eyeNext = &camera->eyeNext;
Vec3f sp98;
- Vec3f sp8C;
+ UNUSED Vec3f sp8C;
VecGeo sp84;
VecGeo sp7C;
VecGeo tGeo;
@@ -4741,7 +4742,7 @@ s32 Camera_Unique1(Camera* camera) {
VecGeo eyeAtOffset;
VecGeo eyeNextAtOffset;
PosRot* playerPosRot = &camera->playerPosRot;
- PosRot playerhead;
+ UNUSED PosRot playerhead;
Unique1ReadOnlyData* roData = &camera->paramData.uniq1.roData;
Unique1ReadWriteData* rwData = &camera->paramData.uniq1.rwData;
s32 pad;
@@ -4784,7 +4785,7 @@ s32 Camera_Unique1(Camera* camera) {
camera->animState++;
}
- playerhead = Actor_GetFocus(&camera->player->actor); // unused
+ playerhead = Actor_GetFocus(&camera->player->actor);
camera->yawUpdateRateInv = Camera_LERPCeilF(100.0f, camera->yawUpdateRateInv, CAM_UPDATE_RATE_STEP_SCALE_XZ, 0.1f);
camera->pitchUpdateRateInv =
@@ -6719,7 +6720,7 @@ s32 Camera_Demo7(Camera* camera) {
camera->stateFlags |= CAM_STATE_DEMO7;
camera->animState++;
}
- //! @bug doesn't return
+ //! @bug Missing return, but the return value is not used.
}
s32 Camera_Demo8(Camera* camera) {
@@ -6975,7 +6976,7 @@ s32 Camera_Special5(Camera* camera) {
CamColChk sp7C;
VecGeo sp74;
VecGeo sp6C;
- VecGeo sp64;
+ UNUSED VecGeo sp64;
VecGeo sp5C;
PosRot* playerPosRot = &camera->playerPosRot;
Special5ReadOnlyData* roData = &camera->paramData.spec5.roData;
@@ -7177,7 +7178,7 @@ s32 Camera_Special6(Camera* camera) {
Vec3f eyePosCalc;
Vec3f eyeAnim;
Vec3f atAnim;
- VecGeo eyeAtOffset;
+ UNUSED VecGeo eyeAtOffset;
PosRot* playerPosRot = &camera->playerPosRot;
BgCamFuncData* bgCamFuncData;
Vec3s bgCamRot;
@@ -7876,7 +7877,7 @@ s32 Camera_UpdateWater(Camera* camera) {
}
Audio_SetExtraFilter(0);
}
- //! @bug: doesn't always return a value, but sometimes does.
+ //! @bug Missing return, but the return value is not used.
}
s32 Camera_UpdateHotRoom(Camera* camera) {
@@ -8617,8 +8618,7 @@ s32 Camera_RequestBgCam(Camera* camera, s32 requestedBgCamIndex) {
#endif
return 0x80000000 | requestedBgCamIndex;
}
-
- //! @note: no return here, but return is unused
+ //! @bug Missing return, but the return value is not used.
}
Vec3s Camera_GetInputDir(Camera* camera) {
diff --git a/src/code/z_jpeg.c b/src/code/z_jpeg.c
index deee31dfd..83ec5aafd 100644
--- a/src/code/z_jpeg.c
+++ b/src/code/z_jpeg.c
@@ -240,7 +240,7 @@ s32 Jpeg_Decode(void* data, void* zbuffer, void* work, u32 workSize) {
JpegDecoder decoder;
JpegDecoderState state;
JpegWork* workBuff;
- OSTime diff;
+ UNUSED_NDEBUG OSTime diff;
OSTime time;
OSTime curTime;
diff --git a/src/code/z_lights.c b/src/code/z_lights.c
index 1d04a59a8..5ee208f70 100644
--- a/src/code/z_lights.c
+++ b/src/code/z_lights.c
@@ -182,8 +182,7 @@ LightNode* Lights_FindBufSlot(void) {
return node;
}
-// return type must not be void to match
-s32 Lights_FreeNode(LightNode* light) {
+BAD_RETURN(s32) Lights_FreeNode(LightNode* light) {
if (light != NULL) {
sLightsBuffer.numOccupied--;
light->info = NULL;
diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c
index 74b0ef5ee..e6e451ee3 100644
--- a/src/code/z_parameter.c
+++ b/src/code/z_parameter.c
@@ -2211,7 +2211,7 @@ void Interface_LoadActionLabelB(PlayState* play, u16 action) {
*/
s32 Health_ChangeBy(PlayState* play, s16 amount) {
u16 heartCount;
- u16 healthLevel;
+ UNUSED_NDEBUG u16 healthLevel;
PRINTF(T("***** 増減=%d (now=%d, max=%d) ***", "***** Fluctuation=%d (now=%d, max=%d) ***"), amount,
gSaveContext.save.info.playerData.health, gSaveContext.save.info.playerData.healthCapacity);
diff --git a/src/code/z_play.c b/src/code/z_play.c
index 84c80119a..dc37ab27a 100644
--- a/src/code/z_play.c
+++ b/src/code/z_play.c
@@ -1068,6 +1068,7 @@ void Play_Update(PlayState* this) {
skip:
PLAY_LOG(3801);
+ //! @bug If frame advancing or during tile transitions, isPaused will be used uninitialized.
if (!isPaused || gDebugCamEnabled) {
s32 i;
@@ -1545,7 +1546,7 @@ void Play_InitScene(PlayState* this, s32 spawn) {
void Play_SpawnScene(PlayState* this, s32 sceneId, s32 spawn) {
SceneTableEntry* scene;
- u32 size;
+ UNUSED_NDEBUG u32 size;
#if PLATFORM_N64
if ((B_80121220 != NULL) && (B_80121220->unk_48 != NULL)) {
diff --git a/src/code/z_view.c b/src/code/z_view.c
index 5395f3855..37e8ac9b0 100644
--- a/src/code/z_view.c
+++ b/src/code/z_view.c
@@ -201,7 +201,7 @@ void View_SetDistortionScale(View* view, f32 scaleX, f32 scaleY, f32 scaleZ) {
view->distortionScale.z = scaleZ;
}
-s32 View_SetDistortionSpeed(View* view, f32 speed) {
+BAD_RETURN(s32) View_SetDistortionSpeed(View* view, f32 speed) {
view->distortionSpeed = speed;
}
diff --git a/src/code/z_vimode.c b/src/code/z_vimode.c
index a97181075..59fa5df2d 100644
--- a/src/code/z_vimode.c
+++ b/src/code/z_vimode.c
@@ -149,15 +149,15 @@ void ViMode_Configure(ViMode* viMode, s32 type, s32 tvType, s32 loRes, s32 antia
viMode->customViMode.comRegs.hSync += HSYNC(1, 4);
}
if (tvType == OS_TV_MPAL) {
- viMode->customViMode.comRegs.leap += LEAP((u16)-4, (u16)-2);
+ viMode->customViMode.comRegs.leap += LEAP(-4, -2);
}
} else {
- viMode->customViMode.fldRegs[0].vStart += START((u16)-3, (u16)-2);
+ viMode->customViMode.fldRegs[0].vStart += START(-3, -2);
if (tvType == OS_TV_MPAL) {
- viMode->customViMode.fldRegs[0].vBurst += BURST((u8)-2, (u8)-1, 12, -1);
+ viMode->customViMode.fldRegs[0].vBurst += BURST(-2, -1, 12, -1);
}
if (tvType == OS_TV_PAL) {
- viMode->customViMode.fldRegs[1].vBurst += BURST((u8)-2, (u8)-1, 2, 0);
+ viMode->customViMode.fldRegs[1].vBurst += BURST(-2, -1, 2, 0);
}
}
diff --git a/src/code/z_vismono.c b/src/code/z_vismono.c
index b169f5b02..aac4fa84f 100644
--- a/src/code/z_vismono.c
+++ b/src/code/z_vismono.c
@@ -183,7 +183,7 @@ void VisMono_Draw(VisMono* this, Gfx** gfxP) {
}
void VisMono_DrawOld(VisMono* this) {
- Gfx* dListEnd;
+ UNUSED_NDEBUG Gfx* dListEnd;
if (this->tlut == NULL) {
this->tlut = SYSTEM_ARENA_MALLOC(256 * G_IM_SIZ_16b_BYTES, "../z_vismono.c", 283);
diff --git a/src/libleo/api/cacreateleomanager.c b/src/libleo/api/cacreateleomanager.c
index 1f2caf6d9..fc3235c08 100644
--- a/src/libleo/api/cacreateleomanager.c
+++ b/src/libleo/api/cacreateleomanager.c
@@ -7,7 +7,7 @@
s32 LeoCACreateLeoManager(s32 comPri, s32 intPri, OSMesg* cmdBuf, s32 cmdMsgCnt) {
OSPiHandle* driveRomHandle;
- OSPiHandle* leoDiskHandle;
+ UNUSED OSPiHandle* leoDiskHandle;
volatile LEOCmdInquiry cmdBlockInq;
volatile LEOCmd cmdBlockID;
LEODiskID thisID;
diff --git a/src/libleo/api/cjcreateleomanager.c b/src/libleo/api/cjcreateleomanager.c
index e3a518300..26ced4f7d 100644
--- a/src/libleo/api/cjcreateleomanager.c
+++ b/src/libleo/api/cjcreateleomanager.c
@@ -7,7 +7,7 @@
s32 LeoCJCreateLeoManager(s32 comPri, s32 intPri, OSMesg* cmdBuf, s32 cmdMsgCnt) {
OSPiHandle* driveRomHandle;
- OSPiHandle* leoDiskHandle;
+ UNUSED OSPiHandle* leoDiskHandle;
volatile LEOCmdInquiry cmdBlockInq;
volatile LEOCmd cmdBlockID;
LEODiskID thisID;
diff --git a/src/libleo/leo/leomecha.c b/src/libleo/leo/leomecha.c
index 861b2970f..da141616c 100644
--- a/src/libleo/leo/leomecha.c
+++ b/src/libleo/leo/leomecha.c
@@ -52,6 +52,7 @@ u8 leoChk_asic_ready(u32 asic_cmd) {
if (asic_cmd == 0x80000) {
return 0;
}
+ FALLTHROUGH;
case 43:
if (!(asic_cur_status & 0x800000)) {
if (asic_cmd == 0x90000) {
@@ -65,6 +66,7 @@ u8 leoChk_asic_ready(u32 asic_cmd) {
return 37;
}
}
+ FALLTHROUGH;
default:
break;
@@ -72,7 +74,7 @@ u8 leoChk_asic_ready(u32 asic_cmd) {
if (asic_cmd & 1) {
break;
}
-
+ FALLTHROUGH;
case 21:
return 0;
}
@@ -265,6 +267,7 @@ u32 leoChk_err_retry(u32 sense) {
switch (sense) {
case LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED:
unit_atten |= 2;
+ FALLTHROUGH;
case LEO_SENSE_DIAGNOSTIC_FAILURE:
case LEO_SENSE_COMMAND_PHASE_ERROR:
case LEO_SENSE_WAITING_NMI:
@@ -278,8 +281,10 @@ u32 leoChk_err_retry(u32 sense) {
switch (sense) {
case LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED:
unit_atten |= 2;
+ FALLTHROUGH;
case LEO_SENSE_MEDIUM_MAY_HAVE_CHANGED:
unit_atten |= 1;
+ FALLTHROUGH;
case LEO_SENSE_DIAGNOSTIC_FAILURE:
case LEO_SENSE_COMMAND_PHASE_ERROR:
case LEO_SENSE_WAITING_NMI:
diff --git a/src/libleo/leo/leotimer.c b/src/libleo/leo/leotimer.c
index 9ac64bb2b..aadfc3b82 100644
--- a/src/libleo/leo/leotimer.c
+++ b/src/libleo/leo/leotimer.c
@@ -78,6 +78,7 @@ void leoSetTimer(void) {
LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION;
return;
}
+ FALLTHROUGH;
case 1:
// Month value cannot be 0
if (temp == 0) {
@@ -85,6 +86,7 @@ void leoSetTimer(void) {
LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION;
return;
}
+ FALLTHROUGH;
default:
// Verify max value of each time info
if (ymdupper[ymd] < temp) {
diff --git a/src/libu64/relocation_gc.c b/src/libu64/relocation_gc.c
index f178121c1..1d2f3193d 100644
--- a/src/libu64/relocation_gc.c
+++ b/src/libu64/relocation_gc.c
@@ -58,7 +58,7 @@ void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlReloc
u32 dbg;
s32 relocOffset = 0;
u32 relocatedValue = 0;
- uintptr_t unrelocatedAddress = 0;
+ UNUSED_NDEBUG uintptr_t unrelocatedAddress = 0;
uintptr_t relocatedAddress = 0;
uintptr_t vramu32 = (uintptr_t)vramStart;
diff --git a/src/libu64/stackcheck.c b/src/libu64/stackcheck.c
index 596c0b411..a8b32ffce 100644
--- a/src/libu64/stackcheck.c
+++ b/src/libu64/stackcheck.c
@@ -111,7 +111,7 @@ u32 StackCheck_Check(StackEntry* entry) {
return ret;
} else {
u32* last;
- u32 used;
+ UNUSED_NDEBUG u32 used;
u32 free;
u32 ret;
@@ -143,7 +143,7 @@ u32 StackCheck_Check(StackEntry* entry) {
u32 StackCheck_GetState(StackEntry* entry) {
u32* last;
- u32 used;
+ UNUSED_NDEBUG u32 used;
u32 free;
u32 ret;
diff --git a/src/libultra/os/settimer.c b/src/libultra/os/settimer.c
index 40e1ba83b..194f4eff7 100644
--- a/src/libultra/os/settimer.c
+++ b/src/libultra/os/settimer.c
@@ -1,7 +1,7 @@
#include "global.h"
s32 osSetTimer(OSTimer* timer, OSTime countdown, OSTime interval, OSMesgQueue* mq, OSMesg msg) {
- OSTime time;
+ UNUSED OSTime time;
#if !PLATFORM_N64
OSTimer* next;
u32 count;
diff --git a/src/overlays/actors/ovl_Boss_Va/z_boss_va.c b/src/overlays/actors/ovl_Boss_Va/z_boss_va.c
index 1d4bbd8b8..3b4d033b2 100644
--- a/src/overlays/actors/ovl_Boss_Va/z_boss_va.c
+++ b/src/overlays/actors/ovl_Boss_Va/z_boss_va.c
@@ -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;
}
diff --git a/src/overlays/actors/ovl_Demo_Gj/z_demo_gj.c b/src/overlays/actors/ovl_Demo_Gj/z_demo_gj.c
index 4182a99e1..d69f207b5 100644
--- a/src/overlays/actors/ovl_Demo_Gj/z_demo_gj.c
+++ b/src/overlays/actors/ovl_Demo_Gj/z_demo_gj.c
@@ -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[] = {
diff --git a/src/overlays/actors/ovl_En_Ko/z_en_ko.c b/src/overlays/actors/ovl_En_Ko/z_en_ko.c
index 7b17e3c0e..006a06e64 100644
--- a/src/overlays/actors/ovl_En_Ko/z_en_ko.c
+++ b/src/overlays/actors/ovl_En_Ko/z_en_ko.c
@@ -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) {
diff --git a/src/overlays/actors/ovl_En_St/z_en_st.c b/src/overlays/actors/ovl_En_St/z_en_st.c
index e6d9fd670..d1dd84467 100644
--- a/src/overlays/actors/ovl_En_St/z_en_st.c
+++ b/src/overlays/actors/ovl_En_St/z_en_st.c
@@ -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.
}
/**
diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c
index 2e1091eda..7f18de152 100644
--- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c
+++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c
@@ -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) {
diff --git a/src/overlays/actors/ovl_En_fHG/z_en_fhg.c b/src/overlays/actors/ovl_En_fHG/z_en_fhg.c
index f47520e57..c6778bd10 100644
--- a/src/overlays/actors/ovl_En_fHG/z_en_fhg.c
+++ b/src/overlays/actors/ovl_En_fHG/z_en_fhg.c
@@ -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;
diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c
index ceed64a30..3377ec68e 100644
--- a/src/overlays/actors/ovl_player_actor/z_player.c
+++ b/src/overlays/actors/ovl_player_actor/z_player.c
@@ -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;
diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_nameset.c b/src/overlays/gamestates/ovl_file_choose/z_file_nameset.c
index d78a04474..f148c1d78 100644
--- a/src/overlays/gamestates/ovl_file_choose/z_file_nameset.c
+++ b/src/overlays/gamestates/ovl_file_choose/z_file_nameset.c
@@ -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);
}