2012/5/11 Pete Batard <p...@akeo.ie>: > +/** \ingroup dev > + * Get the list of all port numbers from root for the specified device > + * \param dev a device > + * \param path the array that should contain the port numbers > + * \param path_len the maximum length of the array
I propose to document that a "correct" value for path_len is 7. Maybe explicitly reference the array name "path" in the documentation. * \param path_len the maximum length of the path array > + * \returns the number of elements filled > + * \returns LIBUSB_ERROR_OVERFLOW if the array is too small > + */ > +int API_EXPORTED libusb_get_port_path(libusb_context *ctx, libusb_device > *dev, uint8_t* path, uint8_t path_len) I prefer to use "uint8_t path[]" instead of "uint8_t* path" for an array. It is equivalent for the C compiler but more explicit for the human. > +{ > + int i = path_len; > + ssize_t r; > + struct libusb_device **devs; > + > + /* The device needs to be open, else the parents may have been > destroyed */ > + r = libusb_get_device_list(ctx, &devs); > + if (r < 0) > + return (int)r; > + > + while(dev) { > + // HCDs can be listed as devices and would have port #0 > + // TODO: see how the other backends want to implement HCDs > as parents > + if (dev->port_number == 0) > + break; > + if (--i<0) { I don't like when affectation and test are on the same line. I propose to use something like: i--; if (i < 0) { The compiler will optimize the code in any case. > index e6e514e..4554b5f 100644 > --- a/libusb/os/darwin_usb.c > +++ b/libusb/os/darwin_usb.c > @@ -185,11 +185,26 @@ static int usb_setup_device_iterator (io_iterator_t > *deviceIterator, long locati > return IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDict, > deviceIterator); > } > > -static usb_device_t **usb_get_next_device (io_iterator_t deviceIterator, > UInt32 *locationp) { > +int get_ioregistry_value_number (io_service_t service, CFStringRef > property, CFNumberType type, void *p) { I get a compiler warning: os/darwin_usb.c:188: warning: no previous prototype for ‘get_ioregistry_value_number’ Declare the function static for internal functions: static int get_ioregistry_value_number (io_service_t service, CFStringRef ... Bye -- Dr. Ludovic Rousseau ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ libusbx-devel mailing list libusbx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libusbx-devel