Fix sign-extension of short/byte arguments when passing to libusb, which expects int (???).

Update Linux 64bit build to new code and support glibc >=2.14.
This commit is contained in:
Luca Longinotti 2013-07-18 22:57:55 +02:00
parent ce5294c22d
commit f2836772a0
3 changed files with 7 additions and 6 deletions

View File

@ -1420,13 +1420,13 @@ static int LIBUSB_CALL hotplugCallback(libusb_context *context,
}
/**
* int hotplugRegisterCallbackNative(Context, int, int, short, short, byte,
* int hotplugRegisterCallbackNative(Context, int, int, int, int, int,
* HotplugCallbackHandle, long)
*/
JNIEXPORT jint JNICALL METHOD_NAME(LibUsb, hotplugRegisterCallbackNative)
(
JNIEnv *env, jclass class, jobject context, jint events, jint flags,
jshort vendorId, jshort productId, jbyte deviceClass,
jint vendorId, jint productId, jint deviceClass,
jobject callbackHandle, jlong hotplugId
)
{

View File

@ -2621,9 +2621,10 @@ public final class LibUsb
throw new IllegalArgumentException("callback must not be null");
}
// Mask the values for conversion to int in libusb API.
final int result = hotplugRegisterCallbackNative(context, events,
flags, vendorId, productId, deviceClass, callbackHandle,
globalHotplugId);
flags, (vendorId & 0xFFFF), (productId & 0xFFFF),
(deviceClass & 0xFF), callbackHandle, globalHotplugId);
if (result == LibUsb.SUCCESS)
{
@ -2638,8 +2639,8 @@ public final class LibUsb
}
static native int hotplugRegisterCallbackNative(final Context context,
final int events, final int flags, final short vendorId,
final short productId, final byte deviceClass,
final int events, final int flags, final int vendorId,
final int productId, final int deviceClass,
final HotplugCallbackHandle callbackHandle, final long hotplugId);
/**