Repository navigation
Add numeric setSerialNo overload and guard setPreferredResolution - #3416
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📜 Recent review details⏰ Context from checks skipped due to timeout. (15)
📝 WalkthroughWalkthrough
ChangesEdidUtil enhancements
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@oshi-common/src/main/java/oshi/util/EdidUtil.java`:
- Around line 387-390: Reject out-of-range serial values in
EdidUtil.setSerialNo(byte[], long) instead of silently truncating them. Add a
bounds check at the start of setSerialNo to ensure the long fits in an unsigned
32-bit range (0..0xFFFF_FFFFL), and throw an appropriate exception for invalid
values before writing bytes into the EDID array. Keep the byte-packing logic
unchanged for valid inputs.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 004ece7c-4823-428b-a2a8-b077c12e759b
📒 Files selected for processing (2)
oshi-common/src/main/java/oshi/util/EdidUtil.javaoshi-common/src/test/java/oshi/util/EdidUtilTest.java
📜 Review details
⏰ Context from checks skipped due to timeout. (15)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 21, ubuntu-latest
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 26, macos-latest
- GitHub Check: Test JDK 26, ubuntu-latest
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
- GitHub Check: Test JDK 21, windows-latest
- GitHub Check: Test JDK 26, windows-latest
- GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
- GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
- GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-04-12T19:22:09.716Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:22:09.716Z
Learning: When reviewing OSHI hardware platform code that uses or implements `CentralProcessor`/`PhysicalProcessor.getEfficiency()`, remember the API’s counterintuitive semantics: a *higher* efficiency-class value indicates *greater performance* (lower efficiency). P-cores/“performance cores” should therefore have higher values (e.g., 1) than E-cores/“efficiency cores” (e.g., 0), as documented in the `CentralProcessor` Javadoc. Do not flag code as incorrect solely because ARM_P_CORES or Intel P-cores are assigned higher efficiency values.
Applied to files:
oshi-common/src/main/java/oshi/util/EdidUtil.java
🔇 Additional comments (2)
oshi-common/src/main/java/oshi/util/EdidUtil.java (1)
475-482: LGTM!oshi-common/src/test/java/oshi/util/EdidUtilTest.java (1)
263-269: LGTM!Also applies to: 271-280
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3416 +/- ##
============================================
- Coverage 75.19% 75.12% -0.08%
Complexity 76 76
============================================
Files 580 580
Lines 21581 21588 +7
Branches 3580 3582 +2
============================================
- Hits 16228 16217 -11
- Misses 3328 3340 +12
- Partials 2025 2031 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Two small refinements to the EdidUtil encoders for the synthetic-EDID use case (e.g. building an EDID from macOS DisplayAttributes): - Add setSerialNo(byte[], long) writing the raw 32-bit ID serial little-endian into bytes 12-15, so a numeric serial that the string form can't represent (it only accepts values that round-trip through getSerialNo) can still be set. The value is validated to fit an unsigned 32-bit range, matching the other numeric setters, rather than silently truncating. - setPreferredResolution now returns without modifying the descriptor when the string has no 'x' separator, instead of throwing StringIndexOutOfBoundsException.
d0213ed to
5481e44
Compare
Two small refinements to the
EdidUtilencoders added in #3415, prompted by sketching the macOS Apple Silicon synthesis path for #3404 (building an EDID fromDisplayAttributes/ProductAttributes):setSerialNo(byte[], long)— writes the raw 32-bit ID serial number little-endian into bytes 12-15. The existing string overload only accepts values that round-trip throughgetSerialNo(8 uppercase hex digits whose bytes are non-alphanumeric, or 4 alphanumeric characters), so an arbitrary numeric serial could not be set; this overload covers that case.setPreferredResolutionnow returns without modifying the descriptor when the string has no'x'separator, instead of throwingStringIndexOutOfBoundsException. A synthesizer that has no resolution to supply can pass an empty string safely.Both are additive/bugfix changes to
EdidUtil(not part of the@PublicApisurface). Tests added for the numeric serial round-trip and the no-separator no-op.Summary by CodeRabbit
New Features
Bug Fixes
xseparator.Tests