From 22ffa034df6ebbacbc597890bad3edeac47e2321 Mon Sep 17 00:00:00 2001 From: Ian Bishop <151477169+ianb-mp@users.noreply.github.com> Date: Wed, 4 Sep 2024 13:03:36 +1000 Subject: [PATCH] Fix parsing of PCI domains longer than 4 digits Signed-off-by: Ian Bishop <151477169+ianb-mp@users.noreply.github.com> --- pkg/pci/address/address.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/pci/address/address.go b/pkg/pci/address/address.go index 6a8a4e45..65e8cca5 100644 --- a/pkg/pci/address/address.go +++ b/pkg/pci/address/address.go @@ -13,7 +13,7 @@ import ( var ( regexAddress *regexp.Regexp = regexp.MustCompile( - `^(([0-9a-f]{0,4}):)?([0-9a-f]{2}):([0-9a-f]{2})\.([0-9a-f]{1})$`, + `^(([0-9a-f]{0,8}):)?([0-9a-f]{2}):([0-9a-f]{2})\.([0-9a-f]{1})$`, ) ) @@ -30,12 +30,11 @@ func (addr *Address) String() string { return addr.Domain + ":" + addr.Bus + ":" + addr.Device + "." + addr.Function } -// FromString returns an Address struct from an ddress string in either -// $BUS:$DEVICE.$FUNCTION (BDF) format or it can be a full PCI address that -// includes the 4-digit $DOMAIN information as well: -// $DOMAIN:$BUS:$DEVICE.$FUNCTION. +// FromString returns [Address] from an address string in either +// $BUS:$DEVICE.$FUNCTION (BDF) format or a full PCI address that +// includes the $DOMAIN: $DOMAIN:$BUS:$DEVICE.$FUNCTION. // -// Returns "" if the address string wasn't a valid PCI address. +// If the address string isn't a valid PCI address, then nil is returned. func FromString(address string) *Address { addrLowered := strings.ToLower(address) matches := regexAddress.FindStringSubmatch(addrLowered)