From 8dc3f8c5154d8110cabe88c5fbc81ce6490944ef Mon Sep 17 00:00:00 2001 From: spandi Date: Sat, 11 Aug 2007 12:54:13 +0000 Subject: [PATCH] device handle check fixed (check for 0 and not <0 as this may be a valid address) git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@252 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c --- java/src/ch/ntb/usb/Device.java | 20 ++++++++++---------- java/version.properties | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/java/src/ch/ntb/usb/Device.java b/java/src/ch/ntb/usb/Device.java index 0f26b8f..6d56536 100644 --- a/java/src/ch/ntb/usb/Device.java +++ b/java/src/ch/ntb/usb/Device.java @@ -174,7 +174,7 @@ public class Device { this.dev_interface = interface_; this.dev_altinterface = altinterface; - if (usbDevHandle > 0) { + if (usbDevHandle != 0) { throw new USBException("device opened, close or reset first"); } @@ -191,7 +191,7 @@ public class Device { usbDevHandle = res; } - if (dev == null || usbDevHandle <= 0) { + if (dev == null || usbDevHandle == 0) { throw new USBException("USB device with idVendor 0x" + Integer.toHexString(idVendor & 0xFFFF) + " and idProduct 0x" @@ -217,7 +217,7 @@ public class Device { * @throws USBException */ public void close() throws USBException { - if (usbDevHandle <= 0) { + if (usbDevHandle == 0) { throw new USBException("invalid device handle"); } release_interface(usbDevHandle, dev_interface); @@ -239,7 +239,7 @@ public class Device { * @throws USBException */ public void reset() throws USBException { - if (usbDevHandle <= 0) { + if (usbDevHandle == 0) { throw new USBException("invalid device handle"); } release_interface(usbDevHandle, dev_interface); @@ -272,7 +272,7 @@ public class Device { */ public int writeBulk(int out_ep_address, byte[] data, int size, int timeout, boolean reopenOnTimeout) throws USBException { - if (usbDevHandle <= 0) { + if (usbDevHandle == 0) { throw new USBException("invalid device handle"); } if (data == null) { @@ -332,7 +332,7 @@ public class Device { */ public int readBulk(int in_ep_address, byte[] data, int size, int timeout, boolean reopenOnTimeout) throws USBException { - if (usbDevHandle <= 0) { + if (usbDevHandle == 0) { throw new USBException("invalid device handle"); } if (data == null) { @@ -392,7 +392,7 @@ public class Device { */ public int writeInterrupt(int out_ep_address, byte[] data, int size, int timeout, boolean reopenOnTimeout) throws USBException { - if (usbDevHandle <= 0) { + if (usbDevHandle == 0) { throw new USBException("invalid device handle"); } if (data == null) { @@ -453,7 +453,7 @@ public class Device { */ public int readInterrupt(int in_ep_address, byte[] data, int size, int timeout, boolean reopenOnTimeout) throws USBException { - if (usbDevHandle <= 0) { + if (usbDevHandle == 0) { throw new USBException("invalid device handle"); } if (data == null) { @@ -529,7 +529,7 @@ public class Device { public int controlMsg(int requestType, int request, int value, int index, byte[] data, int size, int timeout, boolean reopenOnTimeout) throws USBException { - if (usbDevHandle <= 0) { + if (usbDevHandle == 0) { throw new USBException("invalid device handle"); } if (data == null) { @@ -705,7 +705,7 @@ public class Device { * @return true if the device is open */ public boolean isOpen() { - return usbDevHandle > 0; + return usbDevHandle != 0; } /** diff --git a/java/version.properties b/java/version.properties index f1e1f3b..c9e5c87 100644 --- a/java/version.properties +++ b/java/version.properties @@ -1,4 +1,4 @@ #Thu Aug 24 14:28:28 CEST 2006 version.major=0 version.minor=5 -version.release=3 +version.release=4