From owner-p4-projects@FreeBSD.ORG Fri May 1 10:21:38 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 887921065674; Fri, 1 May 2009 10:21:37 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 490C91065670 for ; Fri, 1 May 2009 10:21:37 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe02.swip.net [212.247.154.33]) by mx1.freebsd.org (Postfix) with ESMTP id D1E3C8FC0A for ; Fri, 1 May 2009 10:21:32 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.0 c=1 a=nJ8RngWisuYA:10 a=YSopyyvdw4kFG0grp-oA:9 a=QeqC3veWj5eUCJjHAGeiwhFjSI8A:4 a=GXQn7cbzq85hs8EI:21 a=Ej_22SmNaHwNo8uz:21 Received: from [193.217.167.6] (account mc467741@c2i.net HELO [10.0.0.64]) by mailfe02.swip.net (CommuniGate Pro SMTP 5.2.13) with ESMTPA id 1238236470; Fri, 01 May 2009 12:21:31 +0200 From: Hans Petter Selasky To: Sylvestre Gallon Date: Fri, 1 May 2009 12:24:03 +0200 User-Agent: KMail/1.9.7 References: <200905010921.n419LL8L097778@repoman.freebsd.org> In-Reply-To: <200905010921.n419LL8L097778@repoman.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200905011224.03899.hselasky@c2i.net> Cc: Perforce Change Reviews Subject: Re: PERFORCE change 161423 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 May 2009 10:21:38 -0000 > 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