[Spice-devel] [PATCH 1/6] usbclerk: dos2unix

Arnon Gilboa agilboa at redhat.com
Mon Jul 23 02:23:03 PDT 2012


---
 usbclerk.cpp |   72 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/usbclerk.cpp b/usbclerk.cpp
index 792f544..441f4a1 100644
--- a/usbclerk.cpp
+++ b/usbclerk.cpp
@@ -1,6 +1,6 @@
 #include <windows.h>
 #include <setupapi.h>
-#include <cfgmgr32.h>
+#include <cfgmgr32.h>
 #include <stdio.h>
 #include <string.h>
 #include <tchar.h>
@@ -37,8 +37,8 @@ private:
     bool dispatch_message(CHAR *buffer, DWORD bytes, USBClerkReply *reply);
     bool install_winusb_driver(int vid, int pid);
     bool remove_winusb_driver(int vid, int pid);
-    bool remove_dev(HDEVINFO devs, PSP_DEVINFO_DATA dev_info);
-    bool rescan();
+    bool remove_dev(HDEVINFO devs, PSP_DEVINFO_DATA dev_info);
+    bool rescan();
     static DWORD WINAPI control_handler(DWORD control, DWORD event_type,
                                         LPVOID event_data, LPVOID context);
     static VOID WINAPI main(DWORD argc, TCHAR * argv[]);
@@ -289,7 +289,7 @@ bool USBClerk::execute()
         if (!ConnectNamedPipe(_pipe, NULL) && GetLastError() != ERROR_PIPE_CONNECTED) {
             vd_printf("ConnectNamedPipe() failed: %u", GetLastError());
             break;
-        }
+        }
         if (!ReadFile(_pipe, &buffer, sizeof(buffer), &bytes, NULL)) {
             vd_printf("ReadFile() failed: %d", GetLastError());
             goto disconnect;
@@ -433,52 +433,52 @@ cleanup:
 bool USBClerk::remove_winusb_driver(int vid, int pid)
 {
     HDEVINFO devs;
-    DWORD dev_index;
-    SP_DEVINFO_DATA dev_info;
+    DWORD dev_index;
+    SP_DEVINFO_DATA dev_info;
     TCHAR dev_prefix[MAX_DEVICE_ID_LEN];
-    TCHAR dev_id[MAX_DEVICE_ID_LEN];
-    bool ret = false;
+    TCHAR dev_id[MAX_DEVICE_ID_LEN];
+    bool ret = false;
 
-    devs = SetupDiGetClassDevs(NULL, L"USB", NULL, DIGCF_ALLCLASSES);
+    devs = SetupDiGetClassDevs(NULL, L"USB", NULL, DIGCF_ALLCLASSES);
     if (devs == INVALID_HANDLE_VALUE) {
         vd_printf("SetupDiGetClassDevsEx failed: %u", GetLastError());
         return false;
     }
 
     swprintf(dev_prefix, MAX_DEVICE_ID_LEN, L"USB\\VID_%04x&PID_%04x", vid, pid);
-    dev_info.cbSize = sizeof(dev_info);
-    for (dev_index = 0; SetupDiEnumDeviceInfo(devs, dev_index, &dev_info); dev_index++) {
-        if (SetupDiGetDeviceInstanceId(devs, &dev_info, dev_id, MAX_DEVICE_ID_LEN, NULL) &&
-                wcsstr(dev_id, dev_prefix)) {
-            vd_printf("Removing %S", dev_id);
-            ret = remove_dev(devs, &dev_info);
-            break;
-        }
-    }
+    dev_info.cbSize = sizeof(dev_info);
+    for (dev_index = 0; SetupDiEnumDeviceInfo(devs, dev_index, &dev_info); dev_index++) {
+        if (SetupDiGetDeviceInstanceId(devs, &dev_info, dev_id, MAX_DEVICE_ID_LEN, NULL) &&
+                wcsstr(dev_id, dev_prefix)) {
+            vd_printf("Removing %S", dev_id);
+            ret = remove_dev(devs, &dev_info);
+            break;
+        }
+    }
     SetupDiDestroyDeviceInfoList(devs);
-    ret = ret && rescan();
+    ret = ret && rescan();
     return ret;
 }
 
-bool USBClerk::remove_dev(HDEVINFO devs, PSP_DEVINFO_DATA dev_info)
-{
-    SP_REMOVEDEVICE_PARAMS rmd_params;
-
-    rmd_params.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER);
-    rmd_params.ClassInstallHeader.InstallFunction = DIF_REMOVE;
-    rmd_params.Scope = DI_REMOVEDEVICE_GLOBAL;
-    rmd_params.HwProfile = 0;
-    return (SetupDiSetClassInstallParams(devs, dev_info,
-                &rmd_params.ClassInstallHeader, sizeof(rmd_params)) &&
-            SetupDiCallClassInstaller(DIF_REMOVE, devs, dev_info));
+bool USBClerk::remove_dev(HDEVINFO devs, PSP_DEVINFO_DATA dev_info)
+{
+    SP_REMOVEDEVICE_PARAMS rmd_params;
+
+    rmd_params.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER);
+    rmd_params.ClassInstallHeader.InstallFunction = DIF_REMOVE;
+    rmd_params.Scope = DI_REMOVEDEVICE_GLOBAL;
+    rmd_params.HwProfile = 0;
+    return (SetupDiSetClassInstallParams(devs, dev_info,
+                &rmd_params.ClassInstallHeader, sizeof(rmd_params)) &&
+            SetupDiCallClassInstaller(DIF_REMOVE, devs, dev_info));
 }
 
-bool USBClerk::rescan()
-{
-    DEVINST dev_root;
-
-    return (CM_Locate_DevNode_Ex(&dev_root, NULL, CM_LOCATE_DEVNODE_NORMAL, NULL) == CR_SUCCESS &&
-            CM_Reenumerate_DevNode_Ex(dev_root, 0, NULL) == CR_SUCCESS);
+bool USBClerk::rescan()
+{
+    DEVINST dev_root;
+
+    return (CM_Locate_DevNode_Ex(&dev_root, NULL, CM_LOCATE_DEVNODE_NORMAL, NULL) == CR_SUCCESS &&
+            CM_Reenumerate_DevNode_Ex(dev_root, 0, NULL) == CR_SUCCESS);
 }
 
 int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
-- 
1.7.4.1



More information about the Spice-devel mailing list