Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 May 2009 12:24:03 +0200
From:      Hans Petter Selasky <hselasky@c2i.net>
To:        Sylvestre Gallon <syl@freebsd.org>
Cc:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   Re: PERFORCE change 161423 for review
Message-ID:  <200905011224.03899.hselasky@c2i.net>
In-Reply-To: <200905010921.n419LL8L097778@repoman.freebsd.org>
References:  <200905010921.n419LL8L097778@repoman.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
>  int
>  libusb_get_string_descriptor_ascii(libusb_device_handle * dev,
>      uint8_t desc_index, unsigned char *data, int length)
> @@ -207,6 +208,8 @@
>  		return (LIBUSB20_ERROR_NO_MEM);
>
>  	pdev = dev->os_priv;
> -	return (libusb20_dev_req_string_simple_sync(pdev, desc_index,
> -	    data, length));
> +	if (libusb20_dev_req_string_simple_sync(pdev, desc_index,
> +	    data, length) == 0)
> +		return (length);
> +	return (LIBUSB_ERROR_OTHER);
>  }

I think the correct here is to return strlen(data) in the successful case, 
because it is quite common that the software will pass in a fixed size 
buffer, while the actual string will be shorter.

In other words you will get a short terminated control request on the USB.

--HPS





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905011224.03899.hselasky>