Repository navigation
refactor(wwlib): Copy CPUID registers into the CPU vendor and name strings instead of an unsigned cast - #3636
CryoTheRenegade wants to merge 3 commits into
Conversation
…ssor strings Init_Processor_Manufacturer and Init_Processor_String passed character array elements as unsigned references to CPUDetectClass::CPUID, so the register values were written through an unrelated type. Receive the registers in unsigned variables and copy their bytes into the same string positions. When CPUID fails nothing is written, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Checked CPUID result copying Core/Libraries/Source/WWVegas/WWLib/cpudetect.cpp |
Init_Processor_Manufacturer copies vendor registers in EBX, EDX, ECX order after a successful CPUID call. Copy_CPUID_String copies successful CPUID results to the processor string. Init_Processor_String uses the helper for leaves 0x80000002 through 0x80000004. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Refactor
Suggested reviewers: xezon
Merge Risk: 
Minimal · up to af354
-
No merge-blocking issue was found in the CPUID string initialization changes. Mergeable after normal checks.
Pre-merge checks: 
4
-
Full details: Title check
-
Explanation
The title names the main change: the CPUID register copies in cpudetect.cpp now write into the CPU vendor and name strings through copies instead of an unsigned cast. The raw summary confirms Init_Processor_Manufacturer and Init_Processor_String were changed to do this, with a Copy_CPUID_String helper added. The title is specific and matches the changeset. It uses the conventional refactor(scope) prefix and is a little long at 102 characters, which does not change the verdict.
Full details: Description check
-
Explanation
The description matches the changeset. It explains that cpudetect.cpp passed char array elements as unsigned& to CPUDetectClass::CPUID, and that the change adds memcpy copies to Init_Processor_Manufacturer and a Copy_CPUID_String helper to Init_Processor_String. It also covers the CPUID-unavailable path and gives disassembly evidence. The description is detailed and on topic.
-
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.
Comment @coderabbitai help to get the list of available commands.
[Low impact] The PR appears safe to merge.
|
| if (CPUID(max_cpuid, ebx, ecx, edx, 0)) | ||
| { | ||
| // The vendor string is stored in EBX, EDX, ECX order | ||
| memcpy(&VendorID[0], &ebx, sizeof(ebx)); |
There was a problem hiding this comment.
is unsigned guaranteed to be 4 bytes?
There was a problem hiding this comment.
on an x86 system it is, unsigned is just an alias for unsigned int.
i prefer to state the type as well instead of leaving it to be inffered as int
There was a problem hiding this comment.
Changed to unsigned int for clarity
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follow-up to #3580, #3635.
cpudetect.cppfills the CPU vendor and processor name strings by passingchararray elements toCPUDetectClass::CPUIDasunsigned&. Writing anunsignedthrough a reference into achararray is undefined behavior, the same problem as #3521.Init_Processor_Manufacturer: receives EBX, ECX and EDX inunsignedlocals and copies them intoVendorIDwithmemcpy, in the same EBX, EDX, ECX order as before.Init_Processor_String: the three brand string calls (0x80000002to0x80000004) go through a newCopy_CPUID_Stringhelper. It receives the four registers in anunsignedarray and copies all 16 bytes intoProcessorString.CPUIDreturns false without writing anything when the CPU has no CPUID instruction. Both sites copy only when it returns true, so the strings are left as they were in that case, the same as before.Evidence
cpudetect.objagainst a build ofmain. No other function changed.Init_Processor_Stringis identical. InInit_Processor_Manufacturer, two of the threeVendorIDstores swapped order. Each register still goes to the same offset.Init_Processor_Manufacturer, two registers swapped roles. Each value still goes to the sameVendorIDoffset. InInit_Processor_String, main inlined the three brand stringCPUIDcalls. The branch callsCPUDetectClass::CPUIDinstead and stores the same four registers to the sameProcessorStringoffsets. The function also no longer needs an EBP frame. The fallback branch that composes the name for older CPUs makes one more call toStringClass::operator+=instead of inlining it.AI Disclosure
Claude Opus 5.5 was used to aid in implementation and to compare the disassembly.