From 0450ab1b72b8f3f2e8fa9e99ab7a98fbb5dd9046 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sun, 18 Oct 2026 02:43:06 +0200 Subject: [PATCH] fix: cite primehack's Realtek loader at its pin A comment named the Bluetooth directory twice, a path no revision holds, and every firmware ref sat ten lines above the case it meant. Each now cites its case and return at the pinned commit. The schema check reads profiles as text and refuses a citation that repeats its own directories. --- emulators/primehack.yml | 32 +++++++++++++++--------------- scripts/validate_schemas.py | 22 +++++++++++++++++++++ tests/test_audit_regressions.py | 35 +++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 16 deletions(-) diff --git a/emulators/primehack.yml b/emulators/primehack.yml index 33ae0178..618ac3b6 100644 --- a/emulators/primehack.yml +++ b/emulators/primehack.yml @@ -201,97 +201,97 @@ files: # Required for real Wiimote connectivity via USB Bluetooth adapters with Realtek chipsets. # PrimeHack can auto-download these from gitlab.com/kernel-firmware/linux-firmware. # Placed in Load/Firmware/rtl_bt/. - # ref: Source/Core/Core/IOS/USB/Bluetooth/Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:373-416 + # ref: Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:383-426,434 - name: "rtl8723a_fw.bin" path: "Load/Firmware/rtl_bt/rtl8723a_fw.bin" required: false note: "Realtek 8723A BT firmware for Wiimote passthrough" - source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:379" + source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:388-389" - name: "rtl8723b_fw.bin" path: "Load/Firmware/rtl_bt/rtl8723b_fw.bin" required: false note: "Realtek 8723B BT firmware for Wiimote passthrough" - source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:516-519" + source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:390-391, 516-519" - name: "rtl8723d_fw.bin" path: "Load/Firmware/rtl_bt/rtl8723d_fw.bin" required: false note: "Realtek 8723D BT firmware for Wiimote passthrough" - source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:383" + source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:392-393" - name: "rtl8761a_fw.bin" path: "Load/Firmware/rtl_bt/rtl8761a_fw.bin" required: false note: "Realtek 8761A BT firmware for Wiimote passthrough" - source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:385" + source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:394-395" - name: "rtl8761bu_fw.bin" path: "Load/Firmware/rtl_bt/rtl8761bu_fw.bin" required: false note: "Realtek 8761BU BT firmware for Wiimote passthrough" - source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:387" + source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:396-397" - name: "rtl8821a_fw.bin" path: "Load/Firmware/rtl_bt/rtl8821a_fw.bin" required: false note: "Realtek 8821A BT firmware for Wiimote passthrough" - source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:389" + source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:398-399" - name: "rtl8821c_fw.bin" path: "Load/Firmware/rtl_bt/rtl8821c_fw.bin" required: false note: "Realtek 8821C BT firmware for Wiimote passthrough" - source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:391" + source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:400-401" - name: "rtl8822b_fw.bin" path: "Load/Firmware/rtl_bt/rtl8822b_fw.bin" required: false note: "Realtek 8822B BT firmware for Wiimote passthrough" - source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:395" + source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:404-405" - name: "rtl8822cu_fw.bin" path: "Load/Firmware/rtl_bt/rtl8822cu_fw.bin" required: false note: "Realtek 8822CU BT firmware for Wiimote passthrough" - source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:393" + source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:402-403" - name: "rtl8851bu_fw.bin" path: "Load/Firmware/rtl_bt/rtl8851bu_fw.bin" required: false note: "Realtek 8851BU BT firmware for Wiimote passthrough" - source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:397" + source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:406-407" - name: "rtl8852au_fw.bin" path: "Load/Firmware/rtl_bt/rtl8852au_fw.bin" required: false note: "Realtek 8852AU BT firmware for Wiimote passthrough" - source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:399" + source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:408-409" - name: "rtl8852bu_fw.bin" path: "Load/Firmware/rtl_bt/rtl8852bu_fw.bin" required: false note: "Realtek 8852BU BT firmware for Wiimote passthrough" - source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:401" + source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:410-411" - name: "rtl8852cu_fw.bin" path: "Load/Firmware/rtl_bt/rtl8852cu_fw.bin" required: false note: "Realtek 8852CU BT firmware for Wiimote passthrough" - source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:403" + source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:412-413" - name: "rtl8852btu_fw.bin" path: "Load/Firmware/rtl_bt/rtl8852btu_fw.bin" required: false note: "Realtek 8852BT/8852BE-VT BT firmware for Wiimote passthrough" - source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:405" + source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:414-415" - name: "rtl8922au_fw.bin" path: "Load/Firmware/rtl_bt/rtl8922au_fw.bin" required: false note: "Realtek 8922AU BT firmware for Wiimote passthrough" - source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:407" + source_ref: "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:416-417" notes: hle_available: true diff --git a/scripts/validate_schemas.py b/scripts/validate_schemas.py index 1c2f1644..87f9f397 100644 --- a/scripts/validate_schemas.py +++ b/scripts/validate_schemas.py @@ -59,6 +59,7 @@ def _validate_yaml_directory( out.extend(_unreachable_citations(path, data)) if schema_name == "emulator.schema.json": out.extend(_checks_without_values(path, data)) + out.extend(_doubled_paths(path)) return out @@ -202,6 +203,27 @@ def _unreachable_citations(path: Path, document: object) -> list[str]: return out +_DOUBLED_PATH = re.compile(r"((?:[\w.-]+/){2,})\1") + + +def _doubled_paths(path: Path) -> list[str]: + """A citation whose directory is written twice in a row. + + Read from the raw text, comments included: primehack's note on the + Realtek loader cited Source/Core/Core/IOS/USB/Bluetooth/ twice over, a + path no revision holds, in a comment the parsed document never shows. + """ + out: list[str] = [] + for number, line in enumerate(path.read_text(encoding="utf-8").splitlines(), 1): + match = _DOUBLED_PATH.search(line) + if match: + out.append( + f"{path.relative_to(ROOT)}:{number}: citation repeats its " + f"directory: {match.group(1)}" + ) + return out + + def _unknown_data_dir_refs() -> list[str]: """data_directories refs the registry does not define. diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index e7686ccb..c3c4d57b 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -310,6 +310,41 @@ class UnreachableCitationRegressions(unittest.TestCase): self.assertEqual(errors, []) +class DoubledCitationPaths(unittest.TestCase): + """primehack cited Source/Core/Core/IOS/USB/Bluetooth/ twice in a row in a + comment: no revision holds that path, and the parsed document never + showed it to the citation checks.""" + + def _hits(self, text: str) -> bool: + import validate_schemas + + return bool(validate_schemas._DOUBLED_PATH.search(text)) + + def test_a_repeated_directory_is_rejected(self): + self.assertTrue(self._hits( + "# ref: Source/Core/Core/IOS/USB/Bluetooth/Source/Core/Core/IOS/USB/" + "Bluetooth/RealtekFirmwareLoader.cpp:373-416" + )) + + def test_a_directory_named_once_passes(self): + for good in ( + "Source/Core/Core/IOS/USB/Bluetooth/RealtekFirmwareLoader.cpp:383", + "src/src/main.c:10", + "a/b/c/a/b.c:1", + ): + with self.subTest(citation=good): + self.assertFalse(self._hits(good)) + + @unittest.skipUnless(HAS_JSONSCHEMA, "validating a schema needs jsonschema") + def test_the_corpus_carries_none(self): + import validate_schemas + + errors = [] + for path in sorted((ROOT / "emulators").glob("*.yml")): + errors.extend(validate_schemas._doubled_paths(path)) + self.assertEqual(errors, []) + + class FaqRegressions(unittest.TestCase): """The FAQ states facts the code owns; these tie it back to the source.