machine/usb/descriptor: avoid bytes package

We can't use the bytes package in Go 1.24 since it would result in an
import cycle. Therefore, use bytealg.Index instead.

(I'm not sure this code is correct - just searching for a range of bytes
seems brittle. But at least this commit shouldn't change the code).
This commit is contained in:
Ayke van Laethem
2025-02-16 15:29:55 +01:00
committed by Ron Evans
parent 52b9fcd57f
commit a1be8cd9fe
+2 -2
View File
@@ -1,9 +1,9 @@
package descriptor
import (
"bytes"
"errors"
"internal/binary"
"internal/bytealg"
)
var configurationCDCHID = [configurationTypeLen]byte{
@@ -87,7 +87,7 @@ func FindClassHIDType(des, class []byte) (ClassHIDType, error) {
// search only for ClassHIDType without the ClassLength,
// in case it has already been set.
idx := bytes.Index(des, class[:ClassHIDTypeLen-2])
idx := bytealg.Index(des, class[:ClassHIDTypeLen-2])
if idx == -1 {
return ClassHIDType{}, errNoClassHIDFound
}