Skip to content

Commit 22ffa03

Browse files
committed
Fix parsing of PCI domains longer than 4 digits
Signed-off-by: Ian Bishop <[email protected]>
1 parent 7e3f410 commit 22ffa03

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

pkg/pci/address/address.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
var (
1515
regexAddress *regexp.Regexp = regexp.MustCompile(
16-
`^(([0-9a-f]{0,4}):)?([0-9a-f]{2}):([0-9a-f]{2})\.([0-9a-f]{1})$`,
16+
`^(([0-9a-f]{0,8}):)?([0-9a-f]{2}):([0-9a-f]{2})\.([0-9a-f]{1})$`,
1717
)
1818
)
1919

@@ -30,12 +30,11 @@ func (addr *Address) String() string {
3030
return addr.Domain + ":" + addr.Bus + ":" + addr.Device + "." + addr.Function
3131
}
3232

33-
// FromString returns an Address struct from an ddress string in either
34-
// $BUS:$DEVICE.$FUNCTION (BDF) format or it can be a full PCI address that
35-
// includes the 4-digit $DOMAIN information as well:
36-
// $DOMAIN:$BUS:$DEVICE.$FUNCTION.
33+
// FromString returns [Address] from an address string in either
34+
// $BUS:$DEVICE.$FUNCTION (BDF) format or a full PCI address that
35+
// includes the $DOMAIN: $DOMAIN:$BUS:$DEVICE.$FUNCTION.
3736
//
38-
// Returns "" if the address string wasn't a valid PCI address.
37+
// If the address string isn't a valid PCI address, then nil is returned.
3938
func FromString(address string) *Address {
4039
addrLowered := strings.ToLower(address)
4140
matches := regexAddress.FindStringSubmatch(addrLowered)

0 commit comments

Comments
 (0)