Skip to content

Commit a1e9ea0

Browse files
JoeMattclaude
andcommitted
fix: test_hle_bios + clang-tidy noise from PR #126 first-run
CI on PR #126 (the m68k_done / GPUDone leak fix) surfaced two issues: 1. ASAN sanitizers job still reported the same 1.5MB + 256B leak the PR set out to fix. Root cause: test/test_hle_bios.c calls p_retro_load_game twice (NTSC then PAL) but only calls p_retro_unload_game ONCE (between the two loads). The PAL load never gets unloaded -- so JaguarDone() (which now does m68k_done() + GPUDone()) is never called for the second load. Added the missing p_retro_unload_game() before the final p_retro_deinit() at the end of main. 2. clang-tidy fired NEW pre-existing findings on src/core/jaguar.c and test/test_hle_bios.c because both are in this PR's diff (the workflow runs clang-tidy on changed files, not changed lines): - bugprone-incorrect-roundings on USEC_TO_RISC_CYCLES / USEC_TO_M68K_CYCLES in src/core/event.h. Idiom is `(double + 0.5)` integer cast; lround() is C99 and we're C89/GNU89. - bugprone-multi-level-implicit-pointer-conversion on test_hle_bios.c's dlsym() patterns. Both added to the disabled list in .clang-tidy with documented rationale. Co-Authored-By: Claude Opus 4.7 <[email protected]>
1 parent 6476059 commit a1e9ea0

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

.clang-tidy

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Checks: >
2424
-bugprone-suspicious-include,
2525
-bugprone-switch-missing-default-case,
2626
-bugprone-branch-clone,
27+
-bugprone-incorrect-roundings,
28+
-bugprone-multi-level-implicit-pointer-conversion,
2729
-clang-analyzer-deadcode.DeadStores,
2830
-clang-analyzer-optin.portability.UnixAPI,
2931
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
@@ -49,6 +51,13 @@ FormatStyle: none
4951
# - suspicious-include: project includes .c files in a couple of dispatch headers.
5052
# - switch-missing-default-case: cosmetic; switches on bit-field decode patterns
5153
# commonly omit default because all valid bit values are handled.
54+
# - incorrect-roundings: src/core/event.h's USEC_TO_RISC_CYCLES /
55+
# USEC_TO_M68K_CYCLES use the (double + 0.5) integer-cast idiom for
56+
# cycle conversion. lround() is C99 (we're C89/GNU89), and the
57+
# inputs are non-negative so the idiom is correct here.
58+
# - multi-level-implicit-pointer-conversion: dlsym() returns void*
59+
# that test harnesses cast directly to function pointers / data
60+
# pointer-to-pointer; canonical idiom in the libretro dlsym pattern.
5261
# - branch-clone: register-decode if-chains in src/cd/cdrom.c and src/tom/tom.c
5362
# intentionally write the same value for several adjacent register addresses
5463
# to make the address->effect mapping legible. Real bug clones are caught

test/test_hle_bios.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3172,6 +3172,7 @@ int main(int argc, char *argv[])
31723172

31733173
printf("\n=== Results: %d passed, %d failed ===\n", passes, fails);
31743174

3175+
p_retro_unload_game(); /* matches the second p_retro_load_game above; without this, JaguarDone() never runs and ASAN reports table68k + branch_condition_table as leaks */
31753176
p_retro_deinit();
31763177
dlclose(handle);
31773178
free(dummy_rom);

0 commit comments

Comments
 (0)