From 221c63e659988b7f37df82bd4897dc08fa70e82a Mon Sep 17 00:00:00 2001 From: a Date: Tue, 24 Jun 2025 23:49:02 -0400 Subject: [PATCH] Fix C23 introduced warnings --- Makefile | 2 +- src/audio/us_jp/effects.c | 7 +++-- src/game/behaviors/spawn_star.inc.c | 9 ++++--- src/game/behaviors/unagi.inc.c | 1 + src/game/camera.c | 1 + src/game/mario_actions_moving.c | 2 +- src/goddard/dynlist_proc.c | 41 ----------------------------- src/init/crash_screen.c | 2 +- 8 files changed, 14 insertions(+), 51 deletions(-) diff --git a/Makefile b/Makefile index 9510c054..551198a7 100644 --- a/Makefile +++ b/Makefile @@ -304,7 +304,7 @@ endif # C compiler options CFLAGS = -G 0 $(TARGET_CFLAGS) $(DEF_INC_CFLAGS) $(foreach i,$(INCLUDE_DIRS),--embed-dir=$(i)) CFLAGS += -std=gnu23 -Wno-unused-variable -mno-shared -march=vr4300 -mfix4300 -mabi=32 -mhard-float -mdivide-breaks -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-PIC -mno-abicalls -fno-strict-aliasing -fno-inline-functions -ffreestanding -fwrapv -Wall -Wextra -CFLAGS += -Wno-missing-braces +CFLAGS += -Wno-missing-braces -Wno-maybe-uninitialized ASFLAGS := -march=vr4300 -mabi=32 $(foreach i,$(INCLUDE_DIRS),-I$(i)) $(foreach d,$(DEFINES),--defsym $(d)) ASMFLAGS := -G 0 $(OPT_FLAGS) $(TARGET_CFLAGS) -mips3 $(DEF_INC_CFLAGS) -mno-shared -march=vr4300 -mfix4300 -mabi=32 -mhard-float -mdivide-breaks -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-PIC -mno-abicalls -fno-strict-aliasing -fno-inline-functions -ffreestanding -fwrapv -Wall -Wextra diff --git a/src/audio/us_jp/effects.c b/src/audio/us_jp/effects.c index 2ff50a2e..4bbddc90 100644 --- a/src/audio/us_jp/effects.c +++ b/src/audio/us_jp/effects.c @@ -102,10 +102,9 @@ s8 get_vibrato_pitch_change(struct VibratoState *vib) { switch (index & 0x30) { case 0x10: index = 31 - index; - + // fall through case 0x00: return vib->curve[index]; - case 0x20: index -= 0x20; break; @@ -239,15 +238,15 @@ s32 adsr_update(struct AdsrState *adsr) { adsr->state = ADSR_STATE_HANG; break; } - // fallthrough } + // fallthrough case ADSR_STATE_START_LOOP: adsr->envIndex = 0; adsr->currentHiRes = adsr->current << 0x10; adsr->state = ADSR_STATE_LOOP; - // fallthrough + // fallthrough case ADSR_STATE_LOOP: adsr->delay = BSWAP16(adsr->envelope[adsr->envIndex].delay); switch (adsr->delay) { diff --git a/src/game/behaviors/spawn_star.inc.c b/src/game/behaviors/spawn_star.inc.c index 9a0ee301..595c33fa 100644 --- a/src/game/behaviors/spawn_star.inc.c +++ b/src/game/behaviors/spawn_star.inc.c @@ -124,17 +124,20 @@ struct Object *spawn_star(struct Object *star, f32 homeX, f32 homeY, f32 homeZ) } void spawn_default_star(f32 homeX, f32 homeY, f32 homeZ) { - struct Object *star = spawn_star(star, homeX, homeY, homeZ); + struct Object *star = NULL; + spawn_star(star, homeX, homeY, homeZ); star->oBhvParams2ndByte = 0; } void spawn_red_coin_cutscene_star(f32 homeX, f32 homeY, f32 homeZ) { - struct Object *star = spawn_star(star, homeX, homeY, homeZ); + struct Object *star = NULL; + spawn_star(star, homeX, homeY, homeZ); star->oBhvParams2ndByte = 1; } void spawn_no_exit_star(f32 homeX, f32 homeY, f32 homeZ) { - struct Object *star = spawn_star(star, homeX, homeY, homeZ); + struct Object *star = NULL; + spawn_star(star, homeX, homeY, homeZ); star->oBhvParams2ndByte = 1; star->oInteractionSubtype |= INT_SUBTYPE_NO_EXIT; } diff --git a/src/game/behaviors/unagi.inc.c b/src/game/behaviors/unagi.inc.c index 51235502..d80fe928 100644 --- a/src/game/behaviors/unagi.inc.c +++ b/src/game/behaviors/unagi.inc.c @@ -161,6 +161,7 @@ void bhv_unagi_loop(void) { break; case 2: unagi_act_2(); + // fall through case 3: unagi_act_3(); break; diff --git a/src/game/camera.c b/src/game/camera.c index 77264817..21126ddb 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -1605,6 +1605,7 @@ s32 update_boss_fight_camera(struct Camera *c, Vec3f focus, Vec3f pos) { case AREA_BOB: pos[1] += 125.f; //! fall through, makes the BoB boss fight camera move up twice as high as it should + // fall through case AREA_WF: pos[1] += 125.f; } diff --git a/src/game/mario_actions_moving.c b/src/game/mario_actions_moving.c index 9d7d5b3f..888ddd29 100644 --- a/src/game/mario_actions_moving.c +++ b/src/game/mario_actions_moving.c @@ -1285,7 +1285,7 @@ s32 act_crawling(struct MarioState *m) { mario_set_forward_vel(m, 10.0f); } //! Possibly unintended missing break - + // fall through case GROUND_STEP_NONE: align_with_floor(m); break; diff --git a/src/goddard/dynlist_proc.c b/src/goddard/dynlist_proc.c index f999c5a6..5c95705b 100644 --- a/src/goddard/dynlist_proc.c +++ b/src/goddard/dynlist_proc.c @@ -1895,47 +1895,6 @@ void d_set_att_offset(const struct GdVec3f *off) { } } -/** - * An incorrectly-coded recursive function that was presumably supposed to - * set the offset of an attached object. Now, it will only call itself - * until it encounters a NULL pointer, which will trigger a `fatal_printf()` - * call. - * - * @note Not called - */ -void d_set_att_to_offset(UNUSED u32 a) { - struct GdObj *dynobj; // sp3c - UNUSED u8 filler[24]; - - if (sDynListCurObj == NULL) { - fatal_printf("proc_dynlist(): No current object"); - } - - dynobj = sDynListCurObj; - d_stash_dynobj(); - switch (sDynListCurObj->type) { - case OBJ_TYPE_JOINTS: - set_cur_dynobj(((struct ObjJoint *) dynobj)->attachedToObj); - break; - case OBJ_TYPE_NETS: - set_cur_dynobj(((struct ObjNet *) dynobj)->attachedToObj); - break; - case OBJ_TYPE_PARTICLES: - set_cur_dynobj(((struct ObjParticle *) dynobj)->attachedToObj); - break; - default: - fatal_printf("%s: Object '%s'(%x) does not support this function.", "dSetAttToOffset()", - sDynListCurInfo->name, sDynListCurObj->type); - } - - if (sDynListCurObj == NULL) { - fatal_printf("dSetAttOffset(): Object '%s' isnt attached to anything", - sStashedDynObjInfo->name); - } - d_set_att_to_offset(a); - d_unstash_dynobj(); -} - /** * Store the offset of the attached object into `dst`. * diff --git a/src/init/crash_screen.c b/src/init/crash_screen.c index 2459a6b0..342b683f 100644 --- a/src/init/crash_screen.c +++ b/src/init/crash_screen.c @@ -17,7 +17,7 @@ u8 gCrashScreenCharToGlyph[128] = { }; // A height of seven pixels for each Character * nine rows of characters + one row unused. -u32 gCrashScreenFont[7 * 9 + 1] = { +u32 gCrashScreenFont[] = { #embed "textures/crash_screen/crash_screen_font.ia1.bin" };