From owner-p4-projects@FreeBSD.ORG Mon Jun 1 18:25:59 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 431F21065689; Mon, 1 Jun 2009 18:25:59 +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 0048D1065687 for ; Mon, 1 Jun 2009 18:25:58 +0000 (UTC) (envelope-from syl@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id C83988FC15 for ; Mon, 1 Jun 2009 18:25:58 +0000 (UTC) (envelope-from syl@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n51IPwX3024830 for ; Mon, 1 Jun 2009 18:25:58 GMT (envelope-from syl@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n51IPwWV024828 for perforce@freebsd.org; Mon, 1 Jun 2009 18:25:58 GMT (envelope-from syl@FreeBSD.org) Date: Mon, 1 Jun 2009 18:25:58 GMT Message-Id: <200906011825.n51IPwWV024828@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to syl@FreeBSD.org using -f From: Sylvestre Gallon To: Perforce Change Reviews Cc: Subject: PERFORCE change 163288 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: Mon, 01 Jun 2009 18:26:00 -0000 http://perforce.freebsd.org/chv.cgi?CH=163288 Change 163288 by syl@syl_rincewind on 2009/06/01 18:25:54 - Fix libusb_open and libusb_open_device_with_vid_pid prototypes in libusb.3. - Fix a segfault in libusb_open_device_with_vid_pid(). - Fix a typo in libusb_open_device_with_vid_pid() prototype. - Implement test2 that dump string descriptor for a device opened with libusb_open_device_with_vid_pid(). Affected files ... .. //depot/projects/soc2009/syl_usb/libusb-tests/Makefile#2 edit .. //depot/projects/soc2009/syl_usb/libusb-tests/basic/Makefile#1 add .. //depot/projects/soc2009/syl_usb/libusb-tests/basic/test2/Makefile#1 add .. //depot/projects/soc2009/syl_usb/libusb-tests/basic/test2/test2.c#1 add .. //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.3#4 edit .. //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.c#25 edit Differences ... ==== //depot/projects/soc2009/syl_usb/libusb-tests/Makefile#2 (text+ko) ==== @@ -1,4 +1,5 @@ -SUBDIR=descriptors +SUBDIR= descriptors \ + basic test: .for dir in ${SUBDIR} ==== //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.3#4 (text+ko) ==== @@ -129,7 +129,7 @@ .Pp . .Ft int -.Fn libusb_open "libusb_device *dev" "libusb_device_handle *devh" +.Fn libusb_open "libusb_device *dev" "libusb_device_handle **devh" Open a device and obtain a device_handle. Return 0 on success, LIBUSB_ERROR_NO_MEM on memory allocation problem, LIBUSB_ERROR_ACCESS on permission problem, LIBUSB_ERROR_NO_DEVICE if the device has been @@ -138,7 +138,7 @@ .Pp . .Ft libusb_device_handle * -.Fn libusb_device_open_with_vid_pid "libusb_context *ctx" "uint16_t vid" "uint16_t pid" +.Fn libusb_open_device_with_vid_pid "libusb_context *ctx" "uint16_t vid" "uint16_t pid" Conveniance function to open a device with is .Fa vid and ==== //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.c#25 (text+ko) ==== @@ -374,7 +374,7 @@ } libusb_device_handle * -lib_usb_open_device_with_vid_pid(libusb_context * ctx, uint16_t vendor_id, +libusb_open_device_with_vid_pid(libusb_context * ctx, uint16_t vendor_id, uint16_t product_id) { struct libusb_device **devs; @@ -383,17 +383,20 @@ struct LIBUSB20_DEVICE_DESC_DECODED *pdesc; int i, j, k; + devh = NULL; + if ((i = libusb_get_device_list(ctx, &devs)) < 0) return (NULL); for (j = 0; j < i; j++) { - pdev = (struct libusb20_device *)devs[i]->os_priv; + pdev = (struct libusb20_device *)devs[j]->os_priv; pdesc = libusb20_dev_get_device_desc(pdev); if (pdesc->idVendor == vendor_id && pdesc->idProduct == product_id) - if ((k = libusb_open(devs[i], &devh)) < 0) + if ((k = libusb_open(devs[j], &devh)) < 0) devh = NULL; } + libusb_free_device_list(devs, 1); return (devh); }