]> xenbits.xensource.com Git - people/pauldu/xennet.git/commitdiff
Fix problem of adding device without alias
authorPaul Durrant <paul.durrant@citrix.com>
Mon, 23 Dec 2013 17:13:11 +0000 (17:13 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Mon, 23 Dec 2013 17:13:11 +0000 (17:13 +0000)
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
src/coinst/coinst.c

index 2ce8e3363cb5b8c2d2c45b6e4755a652e0719e73..16ee42bf2455af61c9d73f50f71d294a62aa54c2 100644 (file)
@@ -747,6 +747,8 @@ FindAliasSoftwareKeyName(
     DWORD                   NameLength;
     HRESULT                 Result;
 
+    Log("====>");
+
     Success = GetNetLuid(Address, &NetLuid);
     if (!Success)
         goto fail1;
@@ -884,9 +886,11 @@ found:
         goto fail8;
     }
 
-    Log("%s", *Name);
-
 done:
+    Log("%s", (*Name == NULL) ? "[NONE]" : *Name);
+
+    Log("<====");
+
     return TRUE;
 
 fail8:
@@ -985,8 +989,6 @@ WalkSubKeys(
             goto fail3;
         }
 
-        Log("Checking %s", *SubKeyName);
-        
         if (Match(Key, *SubKeyName, Argument))
             goto done;
     }
@@ -1022,20 +1024,28 @@ fail1:
     return FALSE;
 }
 
+typedef struct _DEVICE_WALK {
+    PTCHAR  Driver;
+    PTCHAR  Device;
+    PTCHAR  Instance;
+} DEVICE_WALK, *PDEVICE_WALK;
+
 static BOOLEAN
 IsInstance(
-    IN  HKEY    Key,
-    IN  PTCHAR  SubKeyName,
-    IN  PVOID   Argument
+    IN  HKEY        Key,
+    IN  PTCHAR      SubKeyName,
+    IN  PVOID       Argument
     )
 {
-    PTCHAR      Name = Argument;
-    HKEY        SubKey;
-    HRESULT     Error;
-    DWORD       MaxValueLength;
-    DWORD       DriverLength;
-    PTCHAR      Driver;
-    DWORD       Type;
+    PDEVICE_WALK    Walk = Argument;
+    HKEY            SubKey;
+    HRESULT         Error;
+    DWORD           MaxValueLength;
+    DWORD           DriverLength;
+    PTCHAR          Driver;
+    DWORD           Type;
+
+    Log("====> (%s)", SubKeyName);
 
     Error = RegOpenKeyEx(Key,
                          SubKeyName,
@@ -1086,13 +1096,15 @@ IsInstance(
         goto fail5;
     }
 
-    if (strncmp(Driver, Name, DriverLength) != 0) {
+    if (strncmp(Driver, Walk->Driver, DriverLength) != 0) {
         SetLastError(ERROR_FILE_NOT_FOUND);
         goto fail6;
     }
 
     free(Driver);
 
+    Log("<====");
+
     return TRUE;
 
 fail6:
@@ -1127,12 +1139,6 @@ fail1:
     return FALSE;
 }
 
-typedef struct _DEVICE_WALK {
-    PTCHAR  Driver;
-    PTCHAR  Device;
-    PTCHAR  Instance;
-} DEVICE_WALK, *PDEVICE_WALK;
-
 static BOOLEAN
 IsDevice(
     IN  HKEY        Key,
@@ -1144,6 +1150,8 @@ IsDevice(
     HRESULT         Error;
     HKEY            SubKey;
 
+    Log("====> (%s)", SubKeyName);
+
     Error = RegOpenKeyEx(Key,
                          SubKeyName,
                          0,
@@ -1156,12 +1164,14 @@ IsDevice(
 
     if (!WalkSubKeys(SubKey,
                      IsInstance,
-                     Walk->Driver,
+                     Walk,
                      &Walk->Instance)) {
         SetLastError(ERROR_FILE_NOT_FOUND);
         goto fail2;
     }
 
+    Log("<====");
+
     return TRUE;
 
 fail2:
@@ -1251,6 +1261,11 @@ FindAliasHardwareKeyName(
     if (!FindAliasSoftwareKeyName(Address, &SoftwareKeyName))
         goto fail1;
 
+    *Name = NULL;
+
+    if (SoftwareKeyName == NULL)
+        goto done;
+
     Walk.Driver = SoftwareKeyName;
 
     Success = OpenEnumKey("PCI", &PciKey);
@@ -1293,7 +1308,8 @@ FindAliasHardwareKeyName(
 
     free(SoftwareKeyName);
 
-    Log("%s", *Name);
+done:
+    Log("%s", (*Name == NULL) ? "[NONE]" : *Name);
 
     Log("<====");