From 0a1a8e43cd56fb9a779bc5f56fccf91a80be3e5c Mon Sep 17 00:00:00 2001 From: vincentserpoul Date: Fri, 17 Feb 2017 01:33:51 +0800 Subject: [PATCH] error handling and bool handling --- usb/device.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usb/device.go b/usb/device.go index e588c85..b5c3d3e 100644 --- a/usb/device.go +++ b/usb/device.go @@ -228,15 +228,15 @@ func (d *Device) SetAutoDetach(autodetach bool) error { autodetachInt = 1 } - errno := C.libusb_set_auto_detach_kernel_driver( + err := C.libusb_set_auto_detach_kernel_driver( d.handle, - C.int(autodetach), + C.int(autodetachInt), ) // TODO LIBUSB_ERROR_NOT_SUPPORTED (-12) handling // if any errors occur - if errno < 0 { - return fmt.Errorf("usb: setautodetach: %s", usbError(errno)) + if err != C.int(SUCCESS) { + return fmt.Errorf("usb: setautodetach: %s", usbError(err)) } return nil }