From b0e2fb8d357660e67211aabb82b4a78bdab325a2 Mon Sep 17 00:00:00 2001 From: "Justin R. Cutler" Date: Wed, 7 Mar 2012 11:44:40 -0500 Subject: [PATCH] libusb/mac: gcc -pedantic warning fixes --- libusb/hid.c | 10 +++++----- mac/hid.c | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/libusb/hid.c b/libusb/hid.c index ae30b3e..9b8ab28 100644 --- a/libusb/hid.c +++ b/libusb/hid.c @@ -783,18 +783,17 @@ hid_device * HID_API_EXPORT hid_open_path(const char *path) { hid_device *dev = NULL; - dev = new_hid_device(); - libusb_device **devs; libusb_device *usb_dev; - ssize_t num_devs; int res; int d = 0; int good_open = 0; + dev = new_hid_device(); + hid_init(); - num_devs = libusb_get_device_list(usb_context, &devs); + libusb_get_device_list(usb_context, &devs); while ((usb_dev = devs[d++]) != NULL) { struct libusb_device_descriptor desc; struct libusb_config_descriptor *conf_desc = NULL; @@ -1363,6 +1362,7 @@ uint16_t get_usb_code_for_current_locale(void) char *locale; char search_string[64]; char *ptr; + struct lang_map_entry *lang; /* Get the current locale. */ locale = setlocale(0, NULL); @@ -1385,7 +1385,7 @@ uint16_t get_usb_code_for_current_locale(void) } /* Find the entry which matches the string code of our locale. */ - struct lang_map_entry *lang = lang_map; + lang = lang_map; while (lang->string_code) { if (!strcmp(lang->string_code, search_string)) { return lang->usb_code; diff --git a/mac/hid.c b/mac/hid.c index faa4af9..c89a3a5 100644 --- a/mac/hid.c +++ b/mac/hid.c @@ -234,14 +234,15 @@ static int get_string_property(IOHIDDeviceRef device, CFStringRef prop, wchar_t buf[0] = 0; if (str) { - len --; - CFIndex str_len = CFStringGetLength(str); CFRange range; - range.location = 0; - range.length = (str_len > len)? len: str_len; CFIndex used_buf_len; CFIndex chars_copied; + + len --; + + range.location = 0; + range.length = ((size_t)str_len > len)? len: (size_t)str_len; chars_copied = CFStringGetBytes(str, range, kCFStringEncodingUTF32LE, @@ -618,6 +619,7 @@ static void perform_signal_callback(void *context) static void *read_thread(void *param) { hid_device *dev = param; + SInt32 code; /* Move the device's run loop to this thread. */ IOHIDDeviceScheduleWithRunLoop(dev->device_handle, CFRunLoopGetCurrent(), dev->run_loop_mode); @@ -641,7 +643,6 @@ static void *read_thread(void *param) /* Run the Event Loop. CFRunLoopRunInMode() will dispatch HID input reports into the hid_report_callback(). */ - SInt32 code; while (!dev->shutdown_thread && !dev->disconnected) { code = CFRunLoopRunInMode(dev->run_loop_mode, 1000/*sec*/, FALSE); /* Return if the device has been disconnected */