hidapi, linux: merged a minor warning + code style fix from mainstream.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
diff --git a/src/hidapi/linux/hid.c b/src/hidapi/linux/hid.c
index 5fa2db4..6a0ae9f 100644
--- a/src/hidapi/linux/hid.c
+++ b/src/hidapi/linux/hid.c
@@ -215,7 +215,7 @@ static int uses_numbered_reports(__u8 *report_descriptor, __u32 size) {
* 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)
{
@@ -298,7 +298,7 @@ static int is_BLE(hid_device *dev)
if (hid_dev) {
unsigned short dev_vid = 0;
unsigned short dev_pid = 0;
- int bus_type = 0;
+ unsigned bus_type = 0;
char *serial_number_utf8 = NULL;
char *product_name_utf8 = NULL;
@@ -336,8 +336,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;
char *tmp;
/* Create the udev object */
@@ -363,7 +363,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(
@@ -431,8 +431,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.
@@ -501,7 +501,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;
/* Get the filename of the /sys entry for the device
@@ -849,24 +849,25 @@ int HID_API_EXPORT hid_send_feature_report(hid_device *dev, const unsigned char
int HID_API_EXPORT hid_get_feature_report(hid_device *dev, unsigned char *data, size_t length)
{
int res;
- unsigned char report = data[0];
-
- res = ioctl(dev->device_handle, HIDIOCGFEATURE(length), data);
- if (res < 0)
- perror("ioctl (GFEATURE)");
- else if (dev->needs_ble_hack) {
- /* Versions of BlueZ before 5.56 don't include the report in the data, and versions of BlueZ >= 5.56 include 2 copies of the report.
- * We'll fix it so that there is a single copy of the report in both cases
- */
- if (data[0] == report && data[1] == report) {
- memmove(&data[0], &data[1], res);
- } else if (data[0] != report) {
- memmove(&data[1], &data[0], res);
- data[0] = report;
- ++res;
- }
- }
- return res;
+ unsigned char report = data[0];
+
+ res = ioctl(dev->device_handle, HIDIOCGFEATURE(length), data);
+ if (res < 0)
+ perror("ioctl (GFEATURE)");
+ else if (dev->needs_ble_hack) {
+ /* Versions of BlueZ before 5.56 don't include the report in the data,
+ * and versions of BlueZ >= 5.56 include 2 copies of the report.
+ * We'll fix it so that there is a single copy of the report in both cases
+ */
+ if (data[0] == report && data[1] == report) {
+ memmove(&data[0], &data[1], res);
+ } else if (data[0] != report) {
+ memmove(&data[1], &data[0], res);
+ data[0] = report;
+ ++res;
+ }
+ }
+ return res;
}
@@ -896,6 +897,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;
}