Skip to content

Extract shared BSD hardware classes (NetBSD/OpenBSD dedup) - #3381

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:extract-bsd-usbdevice-common
Jun 12, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:extract-bsd-usbdevice-common

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Jun 12, 2026 •

Copy link
Copy Markdown
Member

Summary

Merge identical NetBSD and OpenBSD implementations into shared classes in the oshi.hardware.common.platform.unix package:

  • BsdUsbDevice — shared usbdevs -v parsing
  • BsdGraphicsCard — shared pcidump -v parsing
  • BsdSoundCard — shared dmesg audio/pci pattern parsing
  • BsdSensors — shared systat sensor queries

Eliminates ~280 duplicated lines across 8 removed files.

Test plan

  • All pre-commit checks pass locally (spotless, checkstyle, forbiddenapis, javadoc)
  • Unix CI green: NetBSD, FreeBSD, OpenBSD, DragonFly BSD, OpenIndiana

Summary by CodeRabbit

Release Notes

  • Refactor
    • Reorganized hardware detection implementations to consolidate shared code across BSD platforms (NetBSD and OpenBSD). Graphics card discovery, thermal sensor monitoring, USB device enumeration, and sound card detection now utilize unified code modules, improving consistency and maintainability while reducing platform-specific duplication. All existing functionality preserved.

Merge identical NetBSD/OpenBSD implementations into shared classes
in the unix hardware package:
- BsdUsbDevice (usbdevs -v parsing)
- BsdGraphicsCard (pcidump -v parsing)
- BsdSoundCard (dmesg audio/pci parsing)
- BsdSensors (systat sensor queries)

Eliminates ~280 duplicated lines across 8 removed files.
@coderabbitai

coderabbitai Bot commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0d2b38d4-6ed4-4bbd-a82a-c4bc14a22823

📥 Commits

Reviewing files that changed from the base of the PR and between c96b9f9 and 96ef470.

📒 Files selected for processing (11)
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdGraphicsCard.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdSensors.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdSoundCard.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdUsbDevice.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdGraphicsCard.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdHardwareAbstractionLayer.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdSensors.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdSoundCard.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdUsbDevice.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/openbsd/OpenBsdHardwareAbstractionLayerFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/openbsd/OpenBsdHardwareAbstractionLayerJNA.java
💤 Files with no reviewable changes (4)
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdUsbDevice.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdGraphicsCard.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdSensors.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdSoundCard.java
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
  • GitHub Check: JMH Benchmarks, windows-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 26, windows-latest
  • GitHub Check: Test JDK 26, macos-latest
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Analyze (java)
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: JMH Benchmarks, ubuntu-latest
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2026-04-06T04:45:47.644Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:47.644Z
Learning: In the oshi/oshi project, only interfaces and classes in the root packages `oshi`, `oshi.hardware`, and `oshi.software.os` are considered the public API. Code in subpackages that represent specific implementations/platforms (e.g., `oshi.software.os.linux`, `oshi.hardware.platform.linux`, and similar subpackages) is implementation detail. When reviewing, do not treat changes to classes in these platform-specific subpackages as public API breaks (for example: making `LinuxOperatingSystem` abstract, narrowing constructor visibility, or adding/removing abstract methods should not be flagged as breaking public API).

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/unix/openbsd/OpenBsdHardwareAbstractionLayerJNA.java
📚 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/hardware/common/platform/unix/netbsd/NetBsdHardwareAbstractionLayer.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdSensors.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdSoundCard.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdUsbDevice.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdGraphicsCard.java
🔇 Additional comments (7)
oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdGraphicsCard.java (1)

5-5: LGTM!

Also applies to: 20-23, 28-29, 33-36, 52-54, 84-86

oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdSensors.java (1)

5-5: LGTM!

Also applies to: 18-23

oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdSoundCard.java (1)

5-5: LGTM!

Also applies to: 23-27, 32-33, 37-38, 71-73

oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdUsbDevice.java (1)

5-5: LGTM!

Also applies to: 20-26, 33-36, 106-108, 118-120

oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdHardwareAbstractionLayer.java (1)

23-27: LGTM!

Also applies to: 54-55, 79-80, 84-85, 89-90

oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/openbsd/OpenBsdHardwareAbstractionLayerFFM.java (1)

23-28: LGTM!

Also applies to: 52-53, 77-78, 82-83, 87-88

oshi-core/src/main/java/oshi/hardware/platform/unix/openbsd/OpenBsdHardwareAbstractionLayerJNA.java (1)

23-28: LGTM!

Also applies to: 55-56, 80-81, 85-86, 90-91


📝 Walkthrough

Walkthrough

This PR consolidates BSD hardware support by moving OpenBSD-specific device implementations to a shared BSD package, renaming them from OpenBsd* to Bsd* classes marked public final. NetBSD-specific implementations are removed. Platform hardware abstraction layers for NetBSD and OpenBSD are rewired to use the unified Bsd* classes.

Changes

BSD Hardware Support Consolidation

Layer / File(s) Summary
Shared BSD device implementation classes
oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdGraphicsCard.java, BsdSensors.java, BsdSoundCard.java, BsdUsbDevice.java
OpenBsd* graphics card, sensors, sound card, and USB device implementations are relocated from the openbsd subpackage to the shared unix package, renamed to Bsd*, and marked public final to become the canonical BSD implementations. Each class updates internal instantiation sites to use the new class names.
Platform hardware abstraction layer wiring
oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdHardwareAbstractionLayer.java, oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/openbsd/OpenBsdHardwareAbstractionLayerFFM.java, oshi-core/src/main/java/oshi/hardware/platform/unix/openbsd/OpenBsdHardwareAbstractionLayerJNA.java
NetBsdHardwareAbstractionLayer, OpenBsdHardwareAbstractionLayerFFM, and OpenBsdHardwareAbstractionLayerJNA update imports and method delegations to use the consolidated Bsd* classes instead of platform-specific variants, unifying hardware discovery across BSD platforms.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • oshi/oshi#3363: Main PR that created the consolidated Bsd* classes in oshi-common and renames OpenBsd* implementations; this PR updates dependent OpenBSD/NetBSD platform layers to import and use those consolidated classes.

Poem

🐰 Hops through BSD lands, unifying the way,
OpenBSD here, NetBSD there, now they all play!
Shared Bsd classes keep the code so clean,*
From graphics to sensors—one family's seen.
Platform layers dancing to a unified tune,
Consolidation magic 'neath the June moon! 🌙

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main objective: consolidating duplicate NetBSD and OpenBSD hardware implementations into shared BSD classes.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@codecov

codecov Bot commented Jun 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.04%. Comparing base (c96b9f9) to head (96ef470).

Files with missing lines Patch % Lines
...hardware/common/platform/unix/BsdGraphicsCard.java 0.00% 1 Missing and 1 partial ⚠️
...hi/hardware/common/platform/unix/BsdSoundCard.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3381      +/-   ##
============================================
+ Coverage     75.02%   75.04%   +0.01%     
  Complexity       76       76              
============================================
  Files           573      573              
  Lines         21773    21773              
  Branches       3607     3607              
============================================
+ Hits          16336    16340       +4     
+ Misses         3394     3391       -3     
+ Partials       2043     2042       -1     
Flag Coverage Δ
freebsd 26.13% <0.00%> (+<0.01%) ⬆️
linux 30.42% <0.00%> (ø)
macos 30.97% <0.00%> (ø)
openbsd 25.84% <71.42%> (+0.01%) ⬆️
solaris 27.50% <0.00%> (+<0.01%) ⬆️
windows 39.07% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dbwiddis
dbwiddis merged commit 121f162 into oshi:master Jun 12, 2026
21 of 22 checks passed
@dbwiddis
dbwiddis deleted the extract-bsd-usbdevice-common branch June 12, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant