Handle empty as full empty and fix discarding of previous results

This commit is contained in:
Alex D. 2024-06-25 13:21:30 +00:00
parent ecbda0ce3a
commit b98771012d
Signed by: caskd
GPG Key ID: E5AE8A47B8EFC7ED
1 changed files with 9 additions and 4 deletions

13
loc.go
View File

@ -36,8 +36,8 @@ func (i *iface) ProcLoc() (err error) {
}
var (
pci, usb string
procmode int
pci, usb, tmp string
procmode int
)
for _, v := range strings.Split(devpath, "/") {
if strings.HasPrefix(v, "pci") {
@ -51,18 +51,23 @@ func (i *iface) ProcLoc() (err error) {
switch procmode {
case PathProcPCI:
{
if pci, err = i.ProcPCI(v); err != nil {
if tmp, err = i.ProcPCI(v); err != nil {
continue
}
pci = tmp
}
case PathProcUSB:
{
if usb, err = i.ProcUSB(v); err != nil {
if tmp, err = i.ProcUSB(v); err != nil {
continue
}
usb = tmp
}
}
}
if pci == "" && usb == "" {
return
}
i.names[IfNameLoc] = strings.Join([]string{i.pfx, pci, usb}, "")
return