If there's no USB handle, bail out from all functions immediately.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1280 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
b363c7b710
commit
3977713be0
15
usb_libusb.c
15
usb_libusb.c
|
@ -319,6 +319,9 @@ static void usbdev_close(union filedescriptor *fd)
|
|||
{
|
||||
usb_dev_handle *udev = (usb_dev_handle *)fd->usb.handle;
|
||||
|
||||
if (udev == NULL)
|
||||
return -1;
|
||||
|
||||
(void)usb_release_interface(udev, usb_interface);
|
||||
|
||||
#if defined(__linux__)
|
||||
|
@ -342,6 +345,9 @@ static int usbdev_send(union filedescriptor *fd, unsigned char *bp, size_t mlen)
|
|||
unsigned char * p = bp;
|
||||
int tx_size;
|
||||
|
||||
if (udev == NULL)
|
||||
return -1;
|
||||
|
||||
/*
|
||||
* Split the frame into multiple packets. It's important to make
|
||||
* sure we finish with a short packet, or else the device won't know
|
||||
|
@ -425,6 +431,9 @@ static int usbdev_recv(union filedescriptor *fd, unsigned char *buf, size_t nbyt
|
|||
int i, amnt;
|
||||
unsigned char * p = buf;
|
||||
|
||||
if (udev == NULL)
|
||||
return -1;
|
||||
|
||||
for (i = 0; nbytes > 0;)
|
||||
{
|
||||
if (buflen <= bufptr)
|
||||
|
@ -478,6 +487,9 @@ static int usbdev_recv_frame(union filedescriptor *fd, unsigned char *buf, size_
|
|||
int i;
|
||||
unsigned char * p = buf;
|
||||
|
||||
if (udev == NULL)
|
||||
return -1;
|
||||
|
||||
/* If there's an event EP, and it has data pending, return it first. */
|
||||
if (fd->usb.eep != 0)
|
||||
{
|
||||
|
@ -558,6 +570,9 @@ static int usbdev_drain(union filedescriptor *fd, int display)
|
|||
usb_dev_handle *udev = (usb_dev_handle *)fd->usb.handle;
|
||||
int rv;
|
||||
|
||||
if (udev == NULL)
|
||||
return -1;
|
||||
|
||||
do {
|
||||
if (fd->usb.use_interrupt_xfer)
|
||||
rv = usb_interrupt_read(udev, fd->usb.rep, usbbuf, fd->usb.max_xfer, 100);
|
||||
|
|
Loading…
Reference in New Issue