Skip to content

Use registry to remove wmi from cpu package - #1929

Merged
shirou merged 6 commits into
shirou:masterfrom
OrbintSoft:use-registry-remove-wmi
Oct 16, 2025
Merged

Use registry to remove wmi from cpu package#1929
shirou merged 6 commits into
shirou:masterfrom
OrbintSoft:use-registry-remove-wmi

Conversation

@OrbintSoft

@OrbintSoft OrbintSoft commented Sep 28, 2025

Copy link
Copy Markdown
Contributor

Implemented registry to get model name and vendorId.
Removed wmi from cpu package

@OrbintSoft

Copy link
Copy Markdown
Contributor Author

@shirou when you have time can you test with your AMD cpu?

Comment thread cpu/cpu_test.go Outdated
assert.NotEmptyf(t, vv.ModelName, "could not get CPU Info: %v", vv)
if runtime.GOOS == "windows" {
assert.NotEmptyf(t, vv.VendorID, "could not get Vendor ID: %v", vv)
assert.NotEmptyf(t, vv.VendorID, "could not get CPU Family: %v", vv)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert.NotEmptyf(t, vv.VendorID, "could not get CPU Family: %v", vv)
assert.NotEmptyf(t, vv.Family, "could not get CPU Family: %v", vv)
Comment thread cpu/cpu_windows.go Outdated
Comment on lines +223 to +225
defer key.Close()
model = getRegistryStringValueIfUnset(key, "ProcessorNameString", model)
vendorId = getRegistryStringValueIfUnset(key, "VendorIdentifier", vendorId)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defer will not execute until this function returns, but I think we don’t need to wait for that.

Suggested change
defer key.Close()
model = getRegistryStringValueIfUnset(key, "ProcessorNameString", model)
vendorId = getRegistryStringValueIfUnset(key, "VendorIdentifier", vendorId)
model = getRegistryStringValueIfUnset(key, "ProcessorNameString", model)
vendorId = getRegistryStringValueIfUnset(key, "VendorIdentifier", vendorId)
key.Close()
@OrbintSoft
OrbintSoft requested a review from shirou October 12, 2025 17:29

@shirou shirou left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I really appreciate your series of contributions!

@shirou
shirou merged commit 6d3d593 into shirou:master Oct 16, 2025
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants