Correctly catch attempts to do isochronous OUT transfers and fix a warning

from upstream.
This commit is contained in:
mpi 2012-04-08 13:14:54 +00:00
parent 589e02ed65
commit 7790e61292
2 changed files with 14 additions and 5 deletions

View File

@ -1,11 +1,11 @@
# $OpenBSD: Makefile,v 1.6 2012/02/01 13:26:20 mpi Exp $ # $OpenBSD: Makefile,v 1.7 2012/04/08 13:14:54 mpi Exp $
COMMENT = library for USB device access from userspace COMMENT = library for USB device access from userspace
VERSION = 1.0.8 VERSION = 1.0.8
DISTNAME = libusb-${VERSION} DISTNAME = libusb-${VERSION}
PKGNAME = libusb1-${VERSION} PKGNAME = libusb1-${VERSION}
REVISION = 3 REVISION = 4
SHARED_LIBS += usb-1.0 0.0 # 0.0 SHARED_LIBS += usb-1.0 0.0 # 0.0
CATEGORIES = devel CATEGORIES = devel

View File

@ -1,4 +1,4 @@
/* $OpenBSD: openbsd_ugen.c,v 1.5 2012/02/01 13:26:20 mpi Exp $ */ /* $OpenBSD: openbsd_ugen.c,v 1.6 2012/04/08 13:14:54 mpi Exp $ */
/* /*
* Copyright (c) 2011 Martin Pieuchot <mpi@openbsd.org> * Copyright (c) 2011 Martin Pieuchot <mpi@openbsd.org>
* *
@ -432,7 +432,7 @@ ugen_submit_transfer(struct usbi_transfer *itransfer)
err = _sync_control_transfer(itransfer); err = _sync_control_transfer(itransfer);
break; break;
case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS: case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
if (transfer->endpoint & LIBUSB_ENDPOINT_OUT) { if (0 == transfer->endpoint & LIBUSB_ENDPOINT_IN) {
/* Isochronous write is not supported */ /* Isochronous write is not supported */
err = LIBUSB_ERROR_NOT_SUPPORTED; err = LIBUSB_ERROR_NOT_SUPPORTED;
break; break;
@ -474,7 +474,7 @@ ugen_handle_events(struct libusb_context *ctx, struct pollfd *fds, nfds_t nfds,
int num_ready) int num_ready)
{ {
struct libusb_device_handle *handle; struct libusb_device_handle *handle;
struct handle_priv *hpriv; struct handle_priv *hpriv = NULL;
struct usbi_transfer *itransfer; struct usbi_transfer *itransfer;
struct pollfd *pollfd; struct pollfd *pollfd;
int i, err = 0; int i, err = 0;
@ -488,12 +488,21 @@ ugen_handle_events(struct libusb_context *ctx, struct pollfd *fds, nfds_t nfds,
if (!pollfd->revents) if (!pollfd->revents)
continue; continue;
hpriv = NULL;
num_ready--; num_ready--;
list_for_each_entry(handle, &ctx->open_devs, list) { list_for_each_entry(handle, &ctx->open_devs, list) {
hpriv = (struct handle_priv *)handle->os_priv; hpriv = (struct handle_priv *)handle->os_priv;
if (hpriv->pipe[0] == pollfd->fd) if (hpriv->pipe[0] == pollfd->fd)
break; break;
hpriv = NULL;
}
if (NULL == hpriv) {
usbi_dbg("fd %d is not an event pipe!", pollfd->fd);
err = ENOENT;
break;
} }
if (pollfd->revents & POLLERR) { if (pollfd->revents & POLLERR) {