Fix a bug where EndpointInfo would always be picked from the last

alternative setting.

When looking up matching EndpointInfo and InterfaceSetting for
an endpoint, a reference to range variable is stored. If range is
allowed to continue, the value of this variable will be updated.
It's a trick to allow use of "nil" pointer as a "found" variable, but it
requires a careful management of the range iterations.
This commit is contained in:
Sebastian Zagrodzki
2017-04-10 03:16:59 +02:00
parent b0d5519c67
commit 9cecdec977

View File

@@ -132,6 +132,7 @@ func (d *Device) openEndpoint(cfgNum, ifNum, setNum, epAddr uint8) (*endpoint, e
setAlternate = i != 0
debug.Printf("found setup: %+v [default: %v]\n", s, !setAlternate)
ifs = &s
break
}
}
if ifs == nil {
@@ -143,6 +144,7 @@ func (d *Device) openEndpoint(cfgNum, ifNum, setNum, epAddr uint8) (*endpoint, e
if endpointAddr(e.Number, e.Direction) == epAddr {
debug.Printf("found ep #%d %s in %+v\n", e.Number, e.Direction, *ifs)
ep = &e
break
}
}
if ep == nil {