Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 12 Dec 2009 00:24:30 +0000 (UTC)
From:      Sean Farley <scf@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r200424 - head/lib/libusb
Message-ID:  <200912120024.nBC0OUej024954@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: scf
Date: Sat Dec 12 00:24:30 2009
New Revision: 200424
URL: http://svn.freebsd.org/changeset/base/200424

Log:
  Fix libusb_open_device_with_vid_pid() to return a NULL if no device is
  found instead of the last device in its search list.
  
  Reviewed by:	thompsa
  MFC after:	5 days

Modified:
  head/lib/libusb/libusb10.c

Modified: head/lib/libusb/libusb10.c
==============================================================================
--- head/lib/libusb/libusb10.c	Sat Dec 12 00:11:40 2009	(r200423)
+++ head/lib/libusb/libusb10.c	Sat Dec 12 00:24:30 2009	(r200424)
@@ -379,8 +379,6 @@ libusb_open_device_with_vid_pid(libusb_c
 	if ((i = libusb_get_device_list(ctx, &devs)) < 0)
 		return (NULL);
 
-	pdev = NULL;
-
 	for (j = 0; j < i; j++) {
 		pdev = devs[j]->os_priv;
 		pdesc = libusb20_dev_get_device_desc(pdev);
@@ -396,6 +394,8 @@ libusb_open_device_with_vid_pid(libusb_c
 			break;
 		}
 	}
+	if (j == i)
+		pdev = NULL;
 
 	libusb_free_device_list(devs, 1);
 	DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_width_vid_pid leave");



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