diff options
| author | quarrel07 <178681861+quarrel07@users.noreply.github.com> | 2026-08-01 23:29:56 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-01 22:29:56 -0600 |
| commit | 8629bec3205b35b6f052a5f0a0164b8132ac1304 (patch) | |
| tree | 45594c74a153377f618426ef62d77cb3a3db5a48 /src/menu_items.c | |
| parent | aa6c9c10caf3630ca37cb45bafc0485b76605445 (diff) | |
Fix the warning-flagged real bugs across the codebase (#691, 1 of 3) (#725)
* menu_items: fix the real-bug-tier compiler warnings (#691 batch 1)
Six fixes, all in menu_items.c, all verified by menu playtest on macOS:
- BSWAP16(*color0++) advanced the pointer twice per pixel on little-endian
builds (the macro evaluates its argument twice) and mixed bytes from two
different pixels. Read first, increment separately. Note: this function
(func_8009A9FC) currently has no callers, so the corruption was latent,
not live.
- func_8009B9D0 fell off the end on a lookup miss, returning garbage (the
existing code comment already suspected this). The miss path now returns
the display list head unchanged, i.e. draws nothing.
- update_ok_menu_item read an uninitialized stack slot for unknown menu
item types; now selects an explicit no-animation value, matching what
the garbage read did in practice.
- pause_menu_item_box_cursor: removed the three empty 'if (x2);' matching
artifacts. The x/y/z spin state itself is untouched.
- func_800A1FB0: initialized var_s4/var_s5 against the guarded-but-warned
switch default.
- func_800A54EC: initialized the pause cursor position pointer against its
unreachable mode-switch default (would have been a null-deref class bug
if mode values ever grew).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* collision: define the G_ENDDL opcode shifts, return 0 when no tyre surface found
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* replays: cast staff-ghost pointer comparisons, return 0 for empty ghost buffer
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* update_objects: return 0 from conditional step helpers, fix TLUT pointer comparison, init train draw distances
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* render_player: remove the impossible lamp range (vanilla bug, never glowed on N64 either)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* math_util_2: return the vector, not the address of the parameter slot
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Crab: remove inner declaration shadowing the initialized objectIndex
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* editor: honor InverseMatrix failure (bool was compared against 2, always true)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Track.h: drop dead null checks on array members
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* shells: drop always-true angle and surface gates (behavior unchanged, s16 made them tautological)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* particles: make the no-return particle setters void
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* effects/stubs/skybox/main: align signatures with functions that return nothing
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* menus/save: type the pak status variable as s32, return BAD_READ on the fall-off path
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* audio: remove uninitialized-read matching artifacts, init isSound
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* code_80005FD0/code_80086E70: init dead bomb kart pointer and the no_init variable
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* port/engine UI: fix printf-style format types and non-literal format string
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* render_objects: feed the unused texture param to the uninitialized img walker
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Format the changed lines per .clang-format
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Address review: strip explanatory comments, drop vec3f pointer returns
Comments moved to the PR record; the one flagged worth keeping stays.
vec3f_set_xyz/normalize/cross_product return void now since the out
argument is the interface and nothing used the pointer.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Update actors_extended.c
* Add checkbox for 'Shells Shoot Straight' option
* Update render_player.c
* Update PortMenu.cpp
* Update render_player.c
* Update actors_extended.c
* Update render_player.c
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: MegaMech <MegaMech@users.noreply.github.com>
Diffstat (limited to 'src/menu_items.c')
| -rw-r--r-- | src/menu_items.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/menu_items.c b/src/menu_items.c index 243f1aab0..ea90b1e20 100644 --- a/src/menu_items.c +++ b/src/menu_items.c @@ -4314,7 +4314,8 @@ void func_8009A9FC(s32 arg0, s32 arg1, u32 arg2, s32 arg3) { color0 = LOAD_ASSET(sMenuTextureList[sMenuTextureMap[arg0].offset]); color1 = LOAD_ASSET(sMenuTextureList[sMenuTextureMap[arg1].offset]); for (size_t i = 0; i < arg2; i++) { - temp_a0 = BSWAP16(*color0++); + temp_a0 = BSWAP16(*color0); + color0++; red = (temp_a0 & 0xF800) >> 0xB; green = (temp_a0 & 0x7C0) >> 6; blue = (temp_a0 & 0x3E) >> 1; @@ -4529,8 +4530,9 @@ Gfx* func_8009B9D0(Gfx* displayListHead, MenuTexture* textures) { } if (found) { gSPDisplayList(displayListHead++, displayList); - return displayListHead; } + // Texture not found: draw nothing. + return displayListHead; } Gfx* render_menu_textures(Gfx* arg0, MenuTexture* arg1, s32 column, s32 row) { @@ -7388,8 +7390,8 @@ void func_800A1F30(UNUSED MenuItem* unused) { void func_800A1FB0(MenuItem* arg0) { Unk_D_800E70A0 spE0 = { 0 }; s32 i; - s32 var_s5; - s32 var_s4; + s32 var_s5 = SUB_MENU_COPY_PAK_FROM_GHOST_MIN; + s32 var_s4 = 0; char spB8[3]; s32 var_s1; char spA8[3]; @@ -8441,7 +8443,8 @@ void render_pause_battle(MenuItem* arg0) { void func_800A54EC(void) { Unk_D_800E70A0 sp50; - Unk_D_800E70A0* var_v1; + // Initialized against the (unreachable) default of the mode switch below. + Unk_D_800E70A0* var_v1 = &D_800E8538[0]; MenuItem* sp48; s32 whyTheSequel; s32 why; @@ -8768,12 +8771,6 @@ void pause_menu_item_box_cursor(MenuItem* arg0, Unk_D_800E70A0* arg1) { y2 += y1; z2 += z1; - // clang-format off - if (x2); - if (y2); - if (z2); - // clang-format on - guScale(mtx, 1.2f, 1.2f, 1.2f); guRotate(mtx2, y2, 0.0f, 1.0f, 0.0f); guMtxCatL(mtx, mtx2, mtx); @@ -10074,12 +10071,13 @@ const s8 D_800F0CA0[] = { }; void update_ok_menu_item(MenuItem* arg0) { - s32 sp4; s32 var_v0; switch (arg0->type) { default: - var_v0 = sp4; // wut? + // Was an uninitialized read; -1 hits no animation case below, + // which is what the garbage value did in practice. + var_v0 = -1; break; case MENU_ITEM_UI_OK: var_v0 = D_800F0CA0[gMainMenuSelection - 1]; |
