Uffe Jakobsen wrote:
> +++ b/src/usb.c
> @@ -276,10 +276,30 @@ 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().
> +#ifdef __FreeBSD__
> +     struct libusb_device_handle* devh;
> +     libusb_open(dev, &devh);

This needs error checking. The open can fail.

> +#endif
>       n = libusb_get_port_numbers(dev, port_numbers, sizeof(port_numbers));
> +#ifdef __FreeBSD__
> +     libusb_close(devh);
> +#endif

Maybe make the above unconditional. The device will need to be open
later anyway. Yes, unneccessary to open it twice, but...


Do you know why FreeBSD decided to have different semantics?


> +// Workaround FreeBSD libusb_get_port_numbers() returning 0
>       if (n < 1)
> +#ifdef __FreeBSD__
> +     {
> +             if (n == 0) {
> +                     port_numbers[0] = libusb_get_device_address(dev);
> +             } else {
> +#endif
>               return SR_ERR;
> +#ifdef __FreeBSD__
> +             }
> +     }
> +#endif

Ouch, that looks really ugly. Maybe:

+#ifdef __FreeBSD__
+       if (0 == n) {
+               port_numbers[0] = libusb_get_device_address(dev);
+               n = 1;
+       }
+#endif
        if (n < 1) {
...


//Peter

------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to