Windows: Clean up unnecessary variable initialization
authorChris Dickens <christopher.a.dickens@gmail.com>
Thu, 12 Jan 2017 22:29:32 +0000 (14:29 -0800)
committerChris Dickens <christopher.a.dickens@gmail.com>
Thu, 12 Jan 2017 23:26:40 +0000 (15:26 -0800)
Don't zero out variables that already are zero (calloc'ed) and
don't set variables that aren't read before being set again.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
libusb/os/windows_nt_common.c
libusb/os/windows_winusb.c
libusb/os/windows_winusb.h
libusb/version_nano.h

index bbb61fcf65057d783e858ca153f2e45f818d8463..d935394a65b29a6aa7ac45e57e605cfc3cd1073a 100644 (file)
@@ -519,7 +519,7 @@ void windows_handle_callback(struct usbi_transfer *itransfer, uint32_t io_result
 
 int windows_handle_events(struct libusb_context *ctx, struct pollfd *fds, POLL_NFDS_TYPE nfds, int num_ready)
 {
-       POLL_NFDS_TYPE i = 0;
+       POLL_NFDS_TYPE i;
        bool found = false;
        struct usbi_transfer *transfer;
        struct winfd *pollable_fd = NULL;
index eea1221ef861374c627220a115c645757c79f47d..70cf598aa6c4b0042e47225c62d9a7f2e91e2766 100644 (file)
@@ -295,7 +295,7 @@ static SP_DEVICE_INTERFACE_DETAIL_DATA_A *get_interface_details(struct libusb_co
        HDEVINFO *dev_info, SP_DEVINFO_DATA *dev_info_data, const GUID *guid, unsigned _index)
 {
        SP_DEVICE_INTERFACE_DATA dev_interface_data;
-       SP_DEVICE_INTERFACE_DETAIL_DATA_A *dev_interface_details = NULL;
+       SP_DEVICE_INTERFACE_DETAIL_DATA_A *dev_interface_details;
        DWORD size;
 
        if (_index <= 0)
@@ -364,7 +364,7 @@ static SP_DEVICE_INTERFACE_DETAIL_DATA_A *get_interface_details_filter(struct li
        HDEVINFO *dev_info, SP_DEVINFO_DATA *dev_info_data, const GUID *guid, unsigned _index, char *filter_path)
 {
        SP_DEVICE_INTERFACE_DATA dev_interface_data;
-       SP_DEVICE_INTERFACE_DETAIL_DATA_A *dev_interface_details = NULL;
+       SP_DEVICE_INTERFACE_DETAIL_DATA_A *dev_interface_details;
        DWORD size;
 
        if (_index <= 0)
@@ -458,8 +458,8 @@ err_exit:
 static unsigned long get_ancestor_session_id(DWORD devinst, unsigned level)
 {
        DWORD parent_devinst;
-       unsigned long session_id = 0;
-       char *sanitized_path = NULL;
+       unsigned long session_id;
+       char *sanitized_path;
        char path[MAX_PATH_LENGTH];
        unsigned i;
 
index 7e00f93a8a323709bde525aaee5cdab857034adb..b7b9cd919a98ec648efbc609c53bcf2a549b2213 100644 (file)
@@ -228,22 +228,11 @@ static inline struct windows_device_priv *windows_device_priv_init(struct libusb
        struct windows_device_priv *p = _device_priv(dev);
        int i;
 
-       p->depth = 0;
-       p->port = 0;
-       p->path = NULL;
        p->apib = &usb_api_backend[USB_API_UNSUPPORTED];
        p->sub_api = SUB_API_NOTSET;
-       p->hid = NULL;
-       p->active_config = 0;
-       p->config_descriptor = NULL;
-       memset(&p->dev_descriptor, 0, sizeof(USB_DEVICE_DESCRIPTOR));
        for (i = 0; i < USB_MAXINTERFACES; i++) {
-               p->usb_interface[i].path = NULL;
                p->usb_interface[i].apib = &usb_api_backend[USB_API_UNSUPPORTED];
                p->usb_interface[i].sub_api = SUB_API_NOTSET;
-               p->usb_interface[i].nb_endpoints = 0;
-               p->usb_interface[i].endpoint = NULL;
-               p->usb_interface[i].restricted_functionality = false;
        }
 
        return p;
index 2e3f9e491844abee518efd5635b94401e5a0b0dc..80fc0dfb2377793eb7637d81076cacfe7df43674 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11175
+#define LIBUSB_NANO 11176