diff --git a/hidtest/test.c b/hidtest/test.c index a694b8e64..bbea421e3 100644 --- a/hidtest/test.c +++ b/hidtest/test.c @@ -7,7 +7,7 @@ 8/22/2009 Copyright 2009 - + This contents of this file may be used by anyone for any reason without any conditions and may be used as a starting point for your own applications @@ -29,6 +29,9 @@ int main(int argc, char* argv[]) { + (void)argc; + (void)argv; + int res; unsigned char buf[256]; #define MAX_STR 255 @@ -36,11 +39,6 @@ int main(int argc, char* argv[]) hid_device *handle; int i; -#ifdef WIN32 - UNREFERENCED_PARAMETER(argc); - UNREFERENCED_PARAMETER(argv); -#endif - struct hid_device_info *devs, *cur_dev; printf("hidapi test/example tool. Compiled with hidapi version %s, runtime version %s.\n", HID_API_VERSION_STR, hid_version_str()); @@ -55,7 +53,7 @@ int main(int argc, char* argv[]) return -1; devs = hid_enumerate(0x0, 0x0); - cur_dev = devs; + cur_dev = devs; while (cur_dev) { printf("Device Found\n type: %04hx %04hx\n path: %s\n serial_number: %ls", cur_dev->vendor_id, cur_dev->product_id, cur_dev->path, cur_dev->serial_number); printf("\n"); @@ -73,7 +71,7 @@ int main(int argc, char* argv[]) memset(buf,0x00,sizeof(buf)); buf[0] = 0x01; buf[1] = 0x81; - + // Open the device using the VID, PID, // and optionally the Serial number. @@ -115,7 +113,7 @@ int main(int argc, char* argv[]) // Set the hid_read() function to be non-blocking. hid_set_nonblocking(handle, 1); - + // Try to read from the device. There should be no // data here, but execution should not block. res = hid_read(handle, buf, 17); @@ -158,7 +156,7 @@ int main(int argc, char* argv[]) printf("Unable to write()\n"); printf("Error: %ls\n", hid_error(handle)); } - + // Request state (cmd 0x81). The first byte is the report number (0x1). buf[0] = 0x1; diff --git a/libusb/hid.c b/libusb/hid.c index a82f9cca4..0b8aa1e7f 100644 --- a/libusb/hid.c +++ b/libusb/hid.c @@ -1098,18 +1098,21 @@ static void cleanup_mutex(void *param) int HID_API_EXPORT hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds) { - int bytes_read = -1; - #if 0 int transferred; int res = libusb_interrupt_transfer(dev->device_handle, dev->input_endpoint, data, length, &transferred, 5000); LOG("transferred: %d\n", transferred); return transferred; #endif + /* by initialising this variable right here, GCC gives a compilation warning/error: */ + /* error: variable ‘bytes_read’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered] */ + int bytes_read; /* = -1; */ pthread_mutex_lock(&dev->mutex); pthread_cleanup_push(&cleanup_mutex, dev); + bytes_read = -1; + /* There's an input report queued up. Return it. */ if (dev->input_reports) { /* Return the first one */ @@ -1359,6 +1362,7 @@ int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *dev, int string_index HID_API_EXPORT const wchar_t * HID_API_CALL hid_error(hid_device *dev) { + (void)dev; return L"hid_error is not implemented yet"; } diff --git a/linux/hid.c b/linux/hid.c index 15428c331..718541e5c 100644 --- a/linux/hid.c +++ b/linux/hid.c @@ -412,7 +412,7 @@ static int get_hid_report_descriptor_from_sysfs(const char *sysfs_path, struct h * strings pointed to by serial_number_utf8 and product_name_utf8 after use. */ static int -parse_uevent_info(const char *uevent, int *bus_type, +parse_uevent_info(const char *uevent, unsigned *bus_type, unsigned short *vendor_id, unsigned short *product_id, char **serial_number_utf8, char **product_name_utf8) { @@ -471,8 +471,8 @@ static int get_device_string(hid_device *dev, enum device_string_id key, wchar_t struct udev_device *udev_dev, *parent, *hid_dev; struct stat s; int ret = -1; - char *serial_number_utf8 = NULL; - char *product_name_utf8 = NULL; + char *serial_number_utf8 = NULL; + char *product_name_utf8 = NULL; /* Create the udev object */ udev = udev_new(); @@ -495,7 +495,7 @@ static int get_device_string(hid_device *dev, enum device_string_id key, wchar_t if (hid_dev) { unsigned short dev_vid; unsigned short dev_pid; - int bus_type; + unsigned bus_type; size_t retm; ret = parse_uevent_info( @@ -567,8 +567,8 @@ static int get_device_string(hid_device *dev, enum device_string_id key, wchar_t } end: - free(serial_number_utf8); - free(product_name_utf8); + free(serial_number_utf8); + free(product_name_utf8); udev_device_unref(udev_dev); /* parent and hid_dev don't need to be (and can't be) unref'd. @@ -647,7 +647,7 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id, unsigned short dev_pid; char *serial_number_utf8 = NULL; char *product_name_utf8 = NULL; - int bus_type; + unsigned bus_type; int result; struct hidraw_report_descriptor report_desc; @@ -1046,6 +1046,9 @@ int HID_API_EXPORT hid_get_feature_report(hid_device *dev, unsigned char *data, // Not supported by Linux HidRaw yet int HID_API_EXPORT HID_API_CALL hid_get_input_report(hid_device *dev, unsigned char *data, size_t length) { + (void)dev; + (void)data; + (void)length; return -1; } @@ -1082,6 +1085,10 @@ int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *dev, wchar_t *s int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *dev, int string_index, wchar_t *string, size_t maxlen) { + (void)dev; + (void)string_index; + (void)string; + (void)maxlen; return -1; }