From cbddf7146dd4b747f9aedfc601ce972c2319e541 Mon Sep 17 00:00:00 2001 From: fig02 Date: Fri, 11 Feb 2022 20:38:22 -0500 Subject: [PATCH] avoid_ub in DmaMgr_GetFileNameImpl --- src/boot/z_std_dma.c | 3 +++ src/code/z_player_lib.c | 12 ++++++------ src/overlays/actors/ovl_En_Zf/z_en_zf.c | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/boot/z_std_dma.c b/src/boot/z_std_dma.c index 6a9d546ce8..7b9300e7d7 100644 --- a/src/boot/z_std_dma.c +++ b/src/boot/z_std_dma.c @@ -210,6 +210,9 @@ const char* DmaMgr_GetFileNameImpl(u32 vrom) { } //! @bug Since there is no return, in case the file isn't found, the return value will be a pointer to the end // of gDmaDataTable +#ifdef AVOID_UB + return (const char*)iter; +#endif } const char* DmaMgr_GetFileName(u32 vrom) { diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 094c72faec..961c000e67 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -712,21 +712,21 @@ void func_8008F470(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, eyeIndex = sEyeMouthIndexes[face][0]; } - #ifdef AVOID_UB +#ifdef AVOID_UB gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[gSaveContext.linkAge][eyeIndex])); - #else +#else gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[eyeIndex])); - #endif +#endif if (mouthIndex < 0) { mouthIndex = sEyeMouthIndexes[face][1]; } - #ifdef AVOID_UB +#ifdef AVOID_UB gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[gSaveContext.linkAge][mouthIndex])); - #else +#else gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[mouthIndex])); - #endif +#endif color = &sTunicColors[tunic]; gDPSetEnvColor(POLY_OPA_DISP++, color->r, color->g, color->b, 0); diff --git a/src/overlays/actors/ovl_En_Zf/z_en_zf.c b/src/overlays/actors/ovl_En_Zf/z_en_zf.c index 38f3034cb0..fa2962b9f3 100644 --- a/src/overlays/actors/ovl_En_Zf/z_en_zf.c +++ b/src/overlays/actors/ovl_En_Zf/z_en_zf.c @@ -457,10 +457,10 @@ s16 EnZf_FindNextPlatformAwayFromPlayer(Vec3f* pos, s16 curPlatform, s16 arg2, G //! is section padding between .text and .data, so 0 gets read as a float. //! Other compilers can shift things and result in a crash. Defining `AVOID_UB` will remove these function calls //! entirely as they are dead code and do not have any effect. - #ifndef AVOID_UB +#ifndef AVOID_UB Math_Vec3f_DistXYZ(&player->actor.world.pos, &sPlatformPositions[nextPlatform]); Math_Vec3f_DistXYZ(&player->actor.world.pos, &sPlatformPositions[altNextPlatform]); - #endif +#endif if (altNextPlatform > 0) { s16 nextPlatformToPlayerYaw =