Skip to content

Add Cppcheck stub headers for PS2SDK includes#82

Merged
NathanNeurotic merged 4 commits into
mainfrom
codex/audit-include-statements-for-missing-system-includes
Jan 7, 2026
Merged

Add Cppcheck stub headers for PS2SDK includes#82
NathanNeurotic merged 4 commits into
mainfrom
codex/audit-include-statements-for-missing-system-includes

Conversation

@NathanNeurotic

Copy link
Copy Markdown
Owner

Motivation

  • Cppcheck/Codacy cannot be given PS2SDK include paths, so the analyzer needs local stub headers to parse the code.
  • Provide minimal definitions (typedefs, prototypes, macros) so static analysis can run without pulling the full PS2SDK.
  • Include stubs only when running Cppcheck to avoid changing real build behavior.

Description

  • Add a new directory include/cppcheck_stubs/ and create lightweight stub headers such as tamtypes.h, libcdvd.h, and fileXio_rpc.h that contain the minimal types, macros, and function prototypes used by the repo.
  • Wrap PS2SDK system includes with #ifdef __CPPCHECK__ / #include "cppcheck_stubs/<header>" / #else / #include <header> / #endif so Cppcheck uses stubs while normal builds use the system headers.
  • Update key files to use the guarded includes, including include/main.h, include/debugprintf.h, and multiple src/*.c files (e.g., src/OSDInit.c, src/ps1.c, src/ps2.c, src/elf.c, src/timer.c).
  • Stubs use #pragma once, include a comment noting they are for static analysis only, and provide only what is necessary to compile under Cppcheck.

Testing

  • Ran a repo-wide search with rg --line-number "#include <(kernel.h|libcdvd.h|osd_config.h|libmc.h|sifrpc.h|sio.h|sifcmd.h|tamtypes.h|elf-loader.h|loadfile.h|libpad.h|debug.h|SIOCookie.h|usbhdfsd-common.h|iopcontrol.h|iopheap.h|sbv_patches.h|ps2sdkapi.h|iopcontrol_special.h|hdd-ioctl.h|io_common.h|libpwroff.h|fileXio_rpc.h)>" src include to validate include placements and wrapper usage, which completed successfully.
  • Inspected several stub headers (include/cppcheck_stubs/tamtypes.h, include/cppcheck_stubs/libcdvd.h, include/cppcheck_stubs/fileXio_rpc.h) to confirm minimal required definitions were provided.
  • Committed the changes with commit message Add Cppcheck stub headers for PS2SDK includes and verified the working tree is clean with git status --short.

Codex Task

@codacy-production

codacy-production Bot commented Jan 7, 2026

Copy link
Copy Markdown

Codacy's Analysis Summary

0 new issue (≤ 0 issue)
0 new security issue
0 complexity
0 duplications

Review Pull Request in Codacy →

AI Reviewer available: add the codacy-review label to get contextual insights without leaving GitHub.

@NathanNeurotic NathanNeurotic merged commit 909d147 into main Jan 7, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant