Hi,

thanks for the patch -- I'll give it a try with a bunch of devices on
FreeBSD soonish.

Please convert the code to the usual coding-style though in the mean
time, at least using one tab for indentation. Thanks!


> +static char* sp_strrspn(const char* s, const char* charset)
> +static int sp_strend(const char* str, const char* pattern)

Not sure about these, isn't there some other way to do the same with
commonly available (portable) functions from libc? If so, I'd rather
avoid having this kind of mini-helper.


> +  int rc;
> +  struct libusb20_backend *p_be;
> +  struct libusb20_device *p_dev, *p_dev_last;

Don't prefix pointer names with p_ please, just use normal, readable
variable names without Hungarian notation.


> +              {
> +                int sub_inst;
> +                // handle multiple subinstances of serial ports in the same 
> driver instance
> +                for (sub_inst = 0; sub_inst < ttyport_cnt; sub_inst++) {
> +                  if (ttyport_cnt == 1) {
> +                    snprintf(tbuf, sizeof(tbuf)-1, "%s", p_ttyname);
> +                  } else {
> +                    snprintf(tbuf, sizeof(tbuf)-1, "%s.%d", p_ttyname, 
> sub_inst);
> +                  }
> +                  if (strcmp(p_cua_sfx, tbuf) == 0) {
> +                    DBG("MATCH: '%s' == '%s'\n", p_cua_sfx, tbuf);
> +                    // populate port structure
> +                    struct LIBUSB20_DEVICE_DESC_DECODED* p_dev_desc = 
> libusb20_dev_get_device_desc(p_dev);
> +                    if (p_dev_desc) {
> +                      port->transport = SP_TRANSPORT_USB;
> +                      port->usb_vid = p_dev_desc->idVendor;
> +                      port->usb_pid = p_dev_desc->idProduct;
> +                      port->usb_bus = libusb20_dev_get_bus_number(p_dev);
> +                      port->usb_address = libusb20_dev_get_address(p_dev);
> +                      if (libusb20_dev_req_string_simple_sync(p_dev, 
> p_dev_desc->iManufacturer, tbuf, sizeof(tbuf)) == 0) {
> +                        port->usb_manufacturer = strdup(tbuf);
> +                      }
> +                      if (libusb20_dev_req_string_simple_sync(p_dev, 
> p_dev_desc->iProduct, tbuf, sizeof(tbuf)) == 0) {
> +                        port->usb_product = strdup(tbuf);
> +                      }
> +                      if (libusb20_dev_req_string_simple_sync(p_dev, 
> p_dev_desc->iSerialNumber, tbuf, sizeof(tbuf)) == 0) {
> +                        port->usb_serial = strdup(tbuf);
> +                      }

The code is getting pretty highly indented here, this might be a good
place to factor out some code into a helper function.


> +
> +                      // if present - add serial to description for better 
> identification
> +                      tbuf[0] = '\0';
> +                      if (port->usb_product && port->usb_product[0]) {
> +                        strncat(tbuf, port->usb_product, sizeof(tbuf)-1);
> +                      } else {
> +                        strncat(tbuf, libusb20_dev_get_desc(p_dev), 
> sizeof(tbuf)-1);
> +                      }
> +                      if (port->usb_serial && port->usb_serial[0]) {
> +                        strncat(tbuf, " ", sizeof(tbuf)-1);
> +                        strncat(tbuf, port->usb_serial, sizeof(tbuf)-1);
> +                      }
> +                      port->description = strdup(tbuf);
> +                      port->bluetooth_address = NULL;
> +                    }
> +                    cua_dev_found = 1;
> +                    break;
> +                  }
> +                }
> +              }
> +
> +              if (p_ttyname) {
> +                free(p_ttyname);
> +              }
> +              if (p_dev_drv_str) {
> +                free(p_dev_drv_str);
> +              }
> +              if (p_drv_name_str) {
> +                free(p_drv_name_str);
> +              }
> +              if (p_drv_inst_str) {
> +                free(p_drv_inst_str);
> +              }
> +            }
> +          }
> +        }
> +      }


Uwe.
-- 
http://hermann-uwe.de | http://randomprojects.org | http://sigrok.org

------------------------------------------------------------------------------
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