From: Uwe Hermann Date: Sun, 15 Nov 2015 18:01:13 +0000 (+0100) Subject: usb.c: Fix usb_get_port_path() issue on Mac OS X. X-Git-Tag: libsigrok-0.4.0~115 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=b98b70222fd756784e7bb55a4d3356e0e3405679;p=libsigrok.git usb.c: Fix usb_get_port_path() issue on Mac OS X. Apparently (some versions of) Mac OS X have the same problem with usb_get_port_path() as FreeBSD does. Work around this in the same way. Thanks to hanyazou@gmail.com for the patch! This fixes bug #673. --- diff --git a/src/usb.c b/src/usb.c index a084f322..ba56e864 100644 --- a/src/usb.c +++ b/src/usb.c @@ -484,19 +484,20 @@ SR_PRIV int usb_get_port_path(libusb_device *dev, char *path, int path_len) /* * FreeBSD requires that devices prior to calling libusb_get_port_numbers() * have been opened with libusb_open(). + * This apparently also applies to some Mac OS X versions. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__APPLE__) struct libusb_device_handle *devh; if (libusb_open(dev, &devh) != 0) return SR_ERR; #endif n = libusb_get_port_numbers(dev, port_numbers, sizeof(port_numbers)); -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__APPLE__) libusb_close(devh); #endif -/* Workaround FreeBSD libusb_get_port_numbers() returning 0. */ -#ifdef __FreeBSD__ +/* Workaround FreeBSD / Mac OS X libusb_get_port_numbers() returning 0. */ +#if defined(__FreeBSD__) || defined(__APPLE__) if (n == 0) { port_numbers[0] = libusb_get_device_address(dev); n = 1;