Skip to content

Fix device.Decode() return type#23

Merged
jpm-canonical merged 1 commit into
mainfrom
fix/device-decode-type
Jun 30, 2026
Merged

Fix device.Decode() return type#23
jpm-canonical merged 1 commit into
mainfrom
fix/device-decode-type

Conversation

@jpm-canonical

@jpm-canonical jpm-canonical commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

The bus.Devices() function returns a value, not a pointer, making the machine info []any a slice of values. The Decode() functions returned pointers, making the devices an array of pointers.

This PR changes the decode functions to also return values, instead of pointers.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aligns the per-bus device JSON decoding APIs with how devices are produced elsewhere in the codebase (as concrete struct values in []any), by changing Decode() functions to return values instead of pointers.

Changes:

  • Updated usb.Decode, pci.Decode, and fastrpc.Decode to return Device values (and Device{} on error) instead of *Device.
  • Updated device and machine decode tests to assert against pci.Device/usb.Device values instead of pointers.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/machine/device/usb/usb.go Change Decode() to return usb.Device by value.
pkg/machine/device/pci/pci.go Change Decode() to return pci.Device by value.
pkg/machine/device/fastrpc/fastrpc.go Change Decode() to return fastrpc.Device by value.
pkg/machine/device/decode_test.go Update type assertions to expect value types from device.Decode.
pkg/machine/decode_test.go Update type assertions to expect value types in MachineInfo.Devices.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/machine/device/usb/usb.go
@jpm-canonical jpm-canonical requested a review from farshidtz June 29, 2026 13:57
@jpm-canonical jpm-canonical marked this pull request as ready for review June 29, 2026 13:57
@jpm-canonical jpm-canonical merged commit b934524 into main Jun 30, 2026
5 checks passed
@jpm-canonical jpm-canonical deleted the fix/device-decode-type branch June 30, 2026 07:59
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.

3 participants