From e31e35658dd08e9f983eef8aef0e239ecd603333 Mon Sep 17 00:00:00 2001 From: louist103 <35883445+louist103@users.noreply.github.com> Date: Sun, 12 Sep 2021 07:02:45 -0400 Subject: [PATCH] Fix return UB (#958) * Ydan_SP * func_8002D7EC * Gameplay_ChangeCameraStatus * Graph_InitTHGA * CollisioCheck_LineOC * Fix more in camera and jpeg * revert comment in player --- include/functions.h | 4 ++-- src/code/graph.c | 2 +- src/code/z_actor.c | 2 +- src/code/z_camera.c | 3 ++- src/code/z_collision_check.c | 4 ++-- src/code/z_jpeg.c | 2 +- src/code/z_play.c | 2 +- src/overlays/actors/ovl_Bg_Ydan_Sp/z_bg_ydan_sp.c | 2 +- src/overlays/actors/ovl_En_St/z_en_st.c | 2 +- 9 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/functions.h b/include/functions.h index 775f8eab0e..bd467f3bae 100644 --- a/include/functions.h +++ b/include/functions.h @@ -381,7 +381,7 @@ void Actor_Kill(Actor* actor); void Actor_SetFocus(Actor* actor, f32 offset); void Actor_SetScale(Actor* actor, f32 scale); void Actor_SetObjectDependency(GlobalContext* globalCtx, Actor* actor); -s16 func_8002D7EC(Actor* actor); +void func_8002D7EC(Actor* actor); void func_8002D868(Actor* actor); void Actor_MoveForward(Actor* actor); void func_8002D908(Actor* actor); @@ -1614,7 +1614,7 @@ void GameAlloc_Init(GameAlloc* this); void Graph_FaultClient(); void Graph_DisassembleUCode(Gfx* workBuf); void Graph_UCodeFaultClient(Gfx* workBuf); -void* Graph_InitTHGA(GraphicsContext* gfxCtx); +void Graph_InitTHGA(GraphicsContext* gfxCtx); GameStateOverlay* Graph_GetNextGameState(GameState* gameState); void Graph_Init(GraphicsContext* gfxCtx); void Graph_Destroy(GraphicsContext* gfxCtx); diff --git a/src/code/graph.c b/src/code/graph.c index d11b2e22eb..ad960cf063 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -79,7 +79,7 @@ void Graph_UCodeFaultClient(Gfx* workBuf) { UCodeDisas_Destroy(&disassembler); } -void* Graph_InitTHGA(GraphicsContext* gfxCtx) { +void Graph_InitTHGA(GraphicsContext* gfxCtx) { GfxPool* pool = &gGfxPools[gfxCtx->gfxPoolIdx & 1]; pool->headMagic = GFXPOOL_HEAD_MAGIC; diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 1cbb2027d7..a0dc3d7886 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -845,7 +845,7 @@ void Actor_Destroy(Actor* actor, GlobalContext* globalCtx) { } } -s16 func_8002D7EC(Actor* actor) { +void func_8002D7EC(Actor* actor) { f32 speedRate = R_UPDATE_RATE * 0.5f; actor->world.pos.x += (actor->velocity.x * speedRate) + actor->colChkInfo.displacement.x; diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 473c096c57..77197662e8 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -2125,6 +2125,7 @@ s32 Camera_Parallel1(Camera* camera) { camera->fov = Camera_LERPCeilF(para1->fovTarget, camera->fov, camera->fovUpdateRate, 1.0f); camera->roll = Camera_LERPCeilS(0, camera->roll, 0.5, 0xA); camera->atLERPStepScale = Camera_ClampLERPScale(camera, sp6A ? para1->unk_1C : para1->unk_14); + //! @bug No return } s32 Camera_Parallel2(Camera* camera) { @@ -2929,7 +2930,7 @@ s32 Camera_Battle2(Camera* camera) { } s32 Camera_Battle3(Camera* camera) { - Camera_Noop(camera); + return Camera_Noop(camera); } /** diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index 0368803829..7088730ae1 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -3175,7 +3175,7 @@ s32 CollisionCheck_LineOC(GlobalContext* globalCtx, CollisionCheckContext* colCh * otherwise. Unused. */ s32 CollisionCheck_LineOCCheckAll(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b) { - CollisionCheck_LineOC(globalCtx, colChkCtx, a, b, NULL, 0); + return CollisionCheck_LineOC(globalCtx, colChkCtx, a, b, NULL, 0); } /** @@ -3184,7 +3184,7 @@ s32 CollisionCheck_LineOCCheckAll(GlobalContext* globalCtx, CollisionCheckContex */ s32 CollisionCheck_LineOCCheck(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b, Actor** exclusions, s32 numExclusions) { - CollisionCheck_LineOC(globalCtx, colChkCtx, a, b, exclusions, numExclusions); + return CollisionCheck_LineOC(globalCtx, colChkCtx, a, b, exclusions, numExclusions); } /** diff --git a/src/code/z_jpeg.c b/src/code/z_jpeg.c index 4f12984f0e..8dd991a157 100644 --- a/src/code/z_jpeg.c +++ b/src/code/z_jpeg.c @@ -17,7 +17,7 @@ /** * Configures and schedules a JPEG decoder task and waits for it to finish. */ -u32 Jpeg_ScheduleDecoderTask(JpegContext* ctx) { +void Jpeg_ScheduleDecoderTask(JpegContext* ctx) { static OSTask_t sJpegTask = { M_NJPEGTASK, // type 0, // flags diff --git a/src/code/z_play.c b/src/code/z_play.c index 8b13322274..52f72c83da 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -1533,7 +1533,7 @@ s16 Gameplay_ChangeCameraStatus(GlobalContext* globalCtx, s16 camId, s16 status) globalCtx->activeCamera = camIdx; } - Camera_ChangeStatus(globalCtx->cameraPtrs[camIdx], status); + return Camera_ChangeStatus(globalCtx->cameraPtrs[camIdx], status); } void Gameplay_ClearCamera(GlobalContext* globalCtx, s16 camId) { diff --git a/src/overlays/actors/ovl_Bg_Ydan_Sp/z_bg_ydan_sp.c b/src/overlays/actors/ovl_Bg_Ydan_Sp/z_bg_ydan_sp.c index 3c1974cd9d..2c056d7229 100644 --- a/src/overlays/actors/ovl_Bg_Ydan_Sp/z_bg_ydan_sp.c +++ b/src/overlays/actors/ovl_Bg_Ydan_Sp/z_bg_ydan_sp.c @@ -153,7 +153,7 @@ void BgYdanSp_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyTris(globalCtx, &this->trisCollider); } -void* BgYdanSp_UpdateFloorWebCollision(BgYdanSp* this) { +void BgYdanSp_UpdateFloorWebCollision(BgYdanSp* this) { s16 newY; CollisionHeader* colHeader; 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 e87a972572..0ff03cb6f1 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -566,7 +566,7 @@ 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 but v0 ends up being stunTimer before decrement } /**