usbd: return an empty device list from sceUsbdGetDeviceList (Gran Turismo 7) #1831

Manually merged
github merged 1 commit from gh-pr/1831/head into gh-pr/1831/base 2026-11-26 10:06:49 +00:00
Owner

@⁠NevesHenry on GitHub · 2026-10-22 14:06 UTC · original
NevesHenry:usbd/empty-device-list → main · +15 −0 · 1 files · 1 commits · merged 2026-10-22 14:18 UTC

Game: Gran Turismo 7 (PPSA01317, 1.710), #1451 (also reported in #1614 and #1706)

GT7 calls sceUsbdGetDeviceList (8qB9Ar4P5nc) and sceUsbdFreeDeviceList (EQ6SCLMqzkM) about 8 times a second. Neither is registered in libUsbd, so every call goes through the unresolved-import stub. That stub returns 0 without writing the list pointer, and the game then passes that pointer to FreeDeviceList.

Evidence from the attached logs:

  • #1451 (build dad900c): 961 of the 1024 "Unresolved import stub called" lines are these two (481 + 480).
  • #1706 (build e5f0ee7): 962 of 1024 (481 + 481).
  • The 1024-line cap is reached about a minute into the session, so missing imports hit later are never logged.

This registers both functions:

  • sceUsbdGetDeviceList returns 0 devices with a static NULL-terminated list.
  • A null list pointer returns 0x80240002 (INVALID_ARG).
  • sceUsbdFreeDeviceList does nothing, because the list is static and holds no device.

Testing: a new usbd_tests fails on main (both NIDs missing) and passes with this change. libUsbd.cpp also builds inside the emulator target.

What this doesn't do: it doesn't fix the crash in #1451 when a car is rendered. It stops GT7 from going through the stub with an uninitialized list, and keeps the stub log free for that crash. I don't own the game, so it was not run with GT7.

AI disclosure: the change, the unit test and this description were written with Claude Code. Testing was the unit test and build above.

**@⁠NevesHenry** on GitHub · 2026-10-22 14:06 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1831) `NevesHenry:usbd/empty-device-list` → `main` · +15 −0 · 1 files · 1 commits · merged 2026-10-22 14:18 UTC Game: Gran Turismo 7 (PPSA01317, 1.710), #1451 (also reported in #1614 and #1706) GT7 calls `sceUsbdGetDeviceList` (`8qB9Ar4P5nc`) and `sceUsbdFreeDeviceList` (`EQ6SCLMqzkM`) about 8 times a second. Neither is registered in libUsbd, so every call goes through the unresolved-import stub. That stub returns 0 without writing the list pointer, and the game then passes that pointer to FreeDeviceList. Evidence from the attached logs: - #1451 (build dad900c): 961 of the 1024 "Unresolved import stub called" lines are these two (481 + 480). - #1706 (build e5f0ee7): 962 of 1024 (481 + 481). - The 1024-line cap is reached about a minute into the session, so missing imports hit later are never logged. This registers both functions: - `sceUsbdGetDeviceList` returns 0 devices with a static NULL-terminated list. - A null list pointer returns `0x80240002` (INVALID_ARG). - `sceUsbdFreeDeviceList` does nothing, because the list is static and holds no device. Testing: a new `usbd_tests` fails on main (both NIDs missing) and passes with this change. libUsbd.cpp also builds inside the emulator target. What this doesn't do: it doesn't fix the crash in #1451 when a car is rendered. It stops GT7 from going through the stub with an uninitialized list, and keeps the stub log free for that crash. I don't own the game, so it was not run with GT7. AI disclosure: the change, the unit test and this description were written with Claude Code. Testing was the unit test and build above.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:06:47 +00:00
github manually merged commit af160fdcee into gh-pr/1831/base 2026-11-26 10:06:49 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-22 14:10 UTC · original

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between c5016d9455 and 26fa417036865315b713bc696e61e367fe3f903f.

📒 Files selected for processing: 3
  • CMakeLists.txt
  • src/libs/libUsbd.cpp
  • tests/UsbdTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

Adds and registers UsbdGetDeviceList and UsbdFreeDeviceList. Retrieval returns a static empty list or an invalid-argument error for a null output pointer. Freeing the static list is a no-op. Adds tests for these behaviors and registers the test executable with CTest and the aggregate test target.

Suggested reviewers: defektu

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 26fa4

The device-list behavior and its test registration are in place. No identified issue blocks merging after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 2 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description clearly explains the registration of the two USBD functions, their behavior, the GT7 issue, and the test coverage.
Title check Passed The title clearly identifies the USBD function and the main behavior change: returning an empty device list for Gran Turismo 7.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 2 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-22 14:10 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1831#issuecomment-6342840636) <!-- coderabbit-ai-generated:v1 --> <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1831?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary><strong>ℹ️ Recent review info</strong></summary> <dl> <dd> <details> <summary><strong>⚙️ Run configuration</strong></summary> <dl> <dd> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/c5016d9455fe52bdd090cef7d80beb15fad6a3a5/.coderabbit.yaml>) - **Commit**: [c5016d9](<https://github.com/KytyPS5/KytyPS5/commit/c5016d9455fe52bdd090cef7d80beb15fad6a3a5>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `12f8836e-7001-436a-b0c9-65fea5aa3926` </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between c5016d9455fe52bdd090cef7d80beb15fad6a3a5 and 26fa417036865315b713bc696e61e367fe3f903f. </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing: 3</strong></summary> <dl> <dd> * `CMakeLists.txt` * `src/libs/libUsbd.cpp` * `tests/UsbdTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </dd> </dl> </details> <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> Adds and registers `UsbdGetDeviceList` and `UsbdFreeDeviceList`. Retrieval returns a static empty list or an invalid-argument error for a null output pointer. Freeing the static list is a no-op. Adds tests for these behaviors and registers the test executable with CTest and the aggregate test target. **Suggested reviewers:** `defektu` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"26fa417036865315b713bc696e61e367fe3f903f" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>⚪ Minimal</strong> · up to <code>26fa4</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `26fa4` --> <!-- final_review_risk_coverage:{"sourceCommitId":"26fa417036865315b713bc696e61e367fe3f903f","coveredCommitId":"26fa417036865315b713bc696e61e367fe3f903f","kind":"reviewed"} --> The device-list behavior and its test registration are in place. No identified issue blocks merging after normal checks. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 warning</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 2 files. (1 skipped: 1… | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------- | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description clearly explains the registration of the two USBD functions, their behavior, the GT7 issue, and the test coverage. | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly identifies the USBD function and the main behavior change: returning an empty device list for Gran Turismo 7. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> **Explanation** Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 2 files. (1 skipped: 1 unsupported.) **Resolution** Write docstrings for the functions missing them to satisfy the coverage threshold. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1831)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
This discussion has been locked. Commenting is limited to contributors.
No description provided.