From owner-svn-src-all@FreeBSD.ORG Sat Dec 3 16:30:48 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5A2B8106566B; Sat, 3 Dec 2011 16:30:48 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 49F088FC0A; Sat, 3 Dec 2011 16:30:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB3GUm7p047483; Sat, 3 Dec 2011 16:30:48 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB3GUmu1047481; Sat, 3 Dec 2011 16:30:48 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201112031630.pB3GUmu1047481@svn.freebsd.org> From: Hans Petter Selasky Date: Sat, 3 Dec 2011 16:30:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228236 - head/lib/libusb X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Dec 2011 16:30:48 -0000 Author: hselasky Date: Sat Dec 3 16:30:47 2011 New Revision: 228236 URL: http://svn.freebsd.org/changeset/base/228236 Log: Simplify libusb_open_device_with_vid_pid(): Only set pdev to non-NULL on success instead of unconditonally setting it and maybe resetting it later. Submitted by: Christoph Mallon MFC after: 3 days Modified: head/lib/libusb/libusb10.c Modified: head/lib/libusb/libusb10.c ============================================================================== --- head/lib/libusb/libusb10.c Sat Dec 3 16:19:07 2011 (r228235) +++ head/lib/libusb/libusb10.c Sat Dec 3 16:30:47 2011 (r228236) @@ -417,9 +417,12 @@ 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); + struct libusb20_device *tdev; + + tdev = devs[j]->os_priv; + pdesc = libusb20_dev_get_device_desc(tdev); /* * NOTE: The USB library will automatically swap the * fields in the device descriptor to be of host @@ -431,8 +434,6 @@ 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");