1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-08 00:44:42 +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

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

View file

@ -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();
}
/**

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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