[Spice-devel] [PATCH 3/6] usbclerk: add logging to driver removal

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


---
 usbclerk.cpp |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/usbclerk.cpp b/usbclerk.cpp
index 9100811..e01489b 100644
--- a/usbclerk.cpp
+++ b/usbclerk.cpp
@@ -470,17 +470,31 @@ bool USBClerk::remove_dev(HDEVINFO devs, PSP_DEVINFO_DATA dev_info)
     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));
+    if (!SetupDiSetClassInstallParams(devs, dev_info,
+            &rmd_params.ClassInstallHeader, sizeof(rmd_params))) {
+        vd_printf("Failed setting class remove params: %u", GetLastError());
+        return false;
+    }
+    if (!SetupDiCallClassInstaller(DIF_REMOVE, devs, dev_info)) {
+        vd_printf("Class remove failed: %u", GetLastError());
+        return false;
+    }
+    return true;
 }
 
 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);
+    if (CM_Locate_DevNode_Ex(&dev_root, NULL, CM_LOCATE_DEVNODE_NORMAL, NULL) != CR_SUCCESS) {
+        vd_printf("Device node cannot be located: %u", GetLastError());
+        return false;
+    }
+    if (CM_Reenumerate_DevNode_Ex(dev_root, 0, NULL) != CR_SUCCESS) {
+        vd_printf("Device node enumeration failed: %u", GetLastError());
+        return false;
+    }
+    return true;
 }
 
 int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
-- 
1.7.4.1



More information about the Spice-devel mailing list