Windows: Constify variables that aren't supposed to change
authorChris Dickens <christopher.a.dickens@gmail.com>
Thu, 4 Jan 2018 07:12:50 +0000 (23:12 -0800)
committerChris Dickens <christopher.a.dickens@gmail.com>
Thu, 4 Jan 2018 07:27:33 +0000 (23:27 -0800)
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
libusb/os/windows_winusb.c
libusb/os/windows_winusb.h
libusb/version_nano.h

index 8965512..7edb8e6 100644 (file)
@@ -126,12 +126,12 @@ static bool api_hid_available = false;
        } while (0)
 
 #if defined(ENABLE_LOGGING)
-static char *guid_to_string(const GUID *guid)
+static const char *guid_to_string(const GUID *guid)
 {
        static char guid_string[MAX_GUID_STRING_LENGTH];
 
        if (guid == NULL)
-               return NULL;
+               return "";
 
        sprintf(guid_string, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
                (unsigned int)guid->Data1, guid->Data2, guid->Data3,
@@ -1348,9 +1348,8 @@ static int windows_get_device_list(struct libusb_context *ctx, struct discovered
        for (pass = 0; ((pass < nb_guids) && (r == LIBUSB_SUCCESS)); pass++) {
 //#define ENUM_DEBUG
 #if defined(ENABLE_LOGGING) && defined(ENUM_DEBUG)
-               const char *passname[] = { "HCD", "HUB", "GEN", "DEV", "HID", "EXT" };
-               usbi_dbg("#### PROCESSING %ss %s", passname[MIN(pass, EXT_PASS)],
-                       (pass != GEN_PASS) ? guid_to_string(guid_list[pass]) : "");
+               const char * const passname[] = {"HCD", "HUB", "GEN", "DEV", "HID", "EXT"};
+               usbi_dbg("#### PROCESSING %ss %s", passname[MIN(pass, EXT_PASS)], guid_to_string(guid_list[pass]));
 #endif
                if ((pass == HID_PASS) && (guid_list[HID_PASS] == NULL))
                        continue;
@@ -2206,9 +2205,9 @@ const struct usbi_os_backend usbi_backend = {
  * USB API backends
  */
 
-static const char *composite_driver_names[] = {"USBCCGP"};
-static const char *winusbx_driver_names[] = {"libusbK", "libusb0", "WinUSB"};
-static const char *hid_driver_names[] = {"HIDUSB", "MOUHID", "KBDHID"};
+static const char * const composite_driver_names[] = {"USBCCGP"};
+static const char * const winusbx_driver_names[] = {"libusbK", "libusb0", "WinUSB"};
+static const char * const hid_driver_names[] = {"HIDUSB", "MOUHID", "KBDHID"};
 const struct windows_usb_api_backend usb_api_backend[USB_API_MAX] = {
        {
                USB_API_UNSUPPORTED,
@@ -3476,7 +3475,7 @@ static int hid_open(int sub_api, struct libusb_device_handle *dev_handle)
        ULONG size[3];
        int nb_ids[2]; // zero and nonzero report IDs
 #if defined(ENABLE_LOGGING)
-       const char *type[3] = {"input", "output", "feature"};
+       const char * const type[3] = {"input", "output", "feature"};
 #endif
 
        CHECK_HID_AVAILABLE;
index 6a7a909..6d9c3cd 100644 (file)
@@ -94,8 +94,8 @@ const GUID GUID_DEVINTERFACE_LIBUSB0_FILTER = {0xF9F3FF14, 0xAE21, 0x48A0, {0x8A
 
 struct windows_usb_api_backend {
        const uint8_t id;
-       const char *designation;
-       const char **driver_name_list; // Driver name, without .sys, e.g. "usbccgp"
+       const char * const designation;
+       const char * const * const driver_name_list; // Driver name, without .sys, e.g. "usbccgp"
        const uint8_t nb_driver_names;
        int (*init)(struct libusb_context *ctx);
        void (*exit)(void);
index 0ab5a51..3dadd03 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11249
+#define LIBUSB_NANO 11250