Do not assume interface numbers follow the slice indices. (#134)

Do not assume interface numbers follow the slice indices.

This is a continuation of
9ad54830f4
which tried to solve the problem of non-contiguous interface indices;
this commit modifies another code path that had the same assumption.
This commit is contained in:
Sebastian Zagrodzki
2024-09-13 20:43:01 +02:00
committed by GitHub
parent 606016adee
commit e840be9d06
4 changed files with 91 additions and 22 deletions

View File

@@ -276,9 +276,13 @@ func (d *Device) InterfaceDescription(cfgNum, intfNum, altNum int) (string, erro
if err != nil {
return "", fmt.Errorf("%s: %v", d, err)
}
alt, err := cfg.intfDesc(intfNum, altNum)
intf, err := cfg.intfDesc(intfNum)
if err != nil {
return "", fmt.Errorf("%s, configuration %d: %v", d, cfgNum, err)
return "", fmt.Errorf("%s, configuration %d interface %d: %v", d, cfgNum, intfNum, err)
}
alt, err := intf.altSetting(altNum)
if err != nil {
return "", fmt.Errorf("%s, configuration %d interface %d alternate setting %d: %v", d, cfgNum, intfNum, altNum, err)
}
return d.GetStringDescriptor(alt.iInterface)
}