diff --git a/service/usbip/client.go b/service/usbip/client.go index 75a442a31..f28424514 100644 --- a/service/usbip/client.go +++ b/service/usbip/client.go @@ -196,10 +196,10 @@ func (c *ClientService) attemptAttach(ctx context.Context, busid string) (Attach return nil, E.Cause(err, "read OP_REP_IMPORT header") } if header.Version != ProtocolVersion { - return nil, E.New(fmt.Sprintf("unexpected reply version 0x%04x", header.Version)) + return nil, E.New("unexpected reply version ", fmt.Sprintf("0x%04x", header.Version)) } if header.Code != expectedReply { - return nil, E.New(fmt.Sprintf("unexpected reply code 0x%04x", header.Code)) + return nil, E.New("unexpected reply code ", fmt.Sprintf("0x%04x", header.Code)) } if header.Status != OpStatusOK { return nil, E.New("remote rejected import (status=", header.Status, ")") diff --git a/service/usbip/client_shared.go b/service/usbip/client_shared.go index 715c283c4..cfcc8eabe 100644 --- a/service/usbip/client_shared.go +++ b/service/usbip/client_shared.go @@ -502,10 +502,10 @@ func (c *ClientService) fetchDevList(ctx context.Context) ([]DeviceEntry, error) return nil, E.Cause(err, "read OP_REP_DEVLIST header") } if header.Version != ProtocolVersion { - return nil, E.New(fmt.Sprintf("unexpected reply version 0x%04x", header.Version)) + return nil, E.New("unexpected reply version ", fmt.Sprintf("0x%04x", header.Version)) } if header.Code != OpRepDevList || header.Status != OpStatusOK { - return nil, E.New(fmt.Sprintf("OP_REP_DEVLIST status=%d code=0x%04x", header.Status, header.Code)) + return nil, E.New("OP_REP_DEVLIST status=", header.Status, " code=", fmt.Sprintf("0x%04x", header.Code)) } return ReadOpRepDevListBody(conn) } diff --git a/service/usbip/host_darwin.go b/service/usbip/host_darwin.go index a019e9097..bccb5fa04 100644 --- a/service/usbip/host_darwin.go +++ b/service/usbip/host_darwin.go @@ -534,7 +534,7 @@ func (s *darwinServerDataSession) serve() error { return err } default: - return E.New(fmt.Sprintf("unexpected USB/IP command 0x%08x", header.Command)) + return E.New("unexpected USB/IP command ", fmt.Sprintf("0x%08x", header.Command)) } } } diff --git a/service/usbip/sysfs_linux.go b/service/usbip/sysfs_linux.go index 69f67041b..7595f654e 100644 --- a/service/usbip/sysfs_linux.go +++ b/service/usbip/sysfs_linux.go @@ -107,11 +107,13 @@ func readSysfsDevice(busid, path string) (sysfsDevice, error) { d.VendorID = vendor d.ProductID, _ = readHexU16(path, "idProduct") d.BCDDevice, _ = readHexU16(path, "bcdDevice") - if v, err := readDecU32(path, "busnum"); err == nil { - d.BusNum = v + busNum, err := readDecU32(path, "busnum") + if err == nil { + d.BusNum = busNum } - if v, err := readDecU32(path, "devnum"); err == nil { - d.DevNum = v + devNum, err := readDecU32(path, "devnum") + if err == nil { + d.DevNum = devNum } d.Speed = speedCodeFromString(readString(path, "speed")) d.DeviceClass, _ = readHexU8(path, "bDeviceClass") @@ -334,13 +336,14 @@ func ensureKernelPath(path string, module string, description string) error { } func findModprobePath() (string, error) { - if path, err := exec.LookPath("modprobe"); err == nil { - return path, nil + modprobePath, err := exec.LookPath("modprobe") + if err == nil { + return modprobePath, nil } - for _, path := range []string{"/usr/sbin/modprobe", "/sbin/modprobe", "/usr/bin/modprobe", "/bin/modprobe"} { - info, err := os.Stat(path) - if err == nil && info.Mode().IsRegular() && info.Mode()&0o111 != 0 { - return path, nil + for _, candidate := range []string{"/usr/sbin/modprobe", "/sbin/modprobe", "/usr/bin/modprobe", "/bin/modprobe"} { + info, statErr := os.Stat(candidate) + if statErr == nil && info.Mode().IsRegular() && info.Mode()&0o111 != 0 { + return candidate, nil } } return "", E.New("modprobe executable not found") diff --git a/service/usbip/usbip_peer.go b/service/usbip/usbip_peer.go index db3793f46..d48746580 100644 --- a/service/usbip/usbip_peer.go +++ b/service/usbip/usbip_peer.go @@ -270,7 +270,7 @@ func (p *UsbIpPeer) readLoop() { } transaction.finalize(SubmitResponse{}, ErrCanceled) default: - p.setReadError(E.New(fmt.Sprintf("unexpected USB/IP response 0x%08x", header.Command))) + p.setReadError(E.New("unexpected USB/IP response ", fmt.Sprintf("0x%08x", header.Command))) return } }