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:

committed by
GitHub

parent
606016adee
commit
e840be9d06
11
interface.go
11
interface.go
@@ -29,6 +29,17 @@ type InterfaceDesc struct {
|
||||
AltSettings []InterfaceSetting
|
||||
}
|
||||
|
||||
func (i *InterfaceDesc) altSetting(alt int) (*InterfaceSetting, error) {
|
||||
alts := make([]int, len(i.AltSettings))
|
||||
for a, s := range i.AltSettings {
|
||||
if s.Alternate == alt {
|
||||
return &s, nil
|
||||
}
|
||||
alts[a] = s.Alternate
|
||||
}
|
||||
return nil, fmt.Errorf("alternate setting %d not found for %s, available alt settings: %v", alt, i, alts)
|
||||
}
|
||||
|
||||
// String returns a human-readable description of the interface descriptor and
|
||||
// its alternate settings.
|
||||
func (i InterfaceDesc) String() string {
|
||||
|
Reference in New Issue
Block a user