display "Unknown" as status when querying the device status failed
[reactos.git] / reactos / lib / devmgr / misc.c
index 8da0f0f..94f1859 100644 (file)
@@ -426,6 +426,7 @@ GetDeviceStatusString(IN DEVINST DevInst,
 {
     CONFIGRET cr;
     ULONG Status, ProblemNumber;
+    UINT MessageId = IDS_UNKNOWN;
     BOOL Ret = FALSE;
 
     if (hMachine != NULL)
@@ -446,23 +447,13 @@ GetDeviceStatusString(IN DEVINST DevInst,
 
     if (cr == CR_SUCCESS)
     {
-        UINT MessageId;
-
         if (ProblemNumber < sizeof(ProblemStringId) / sizeof(ProblemStringId[0]))
             MessageId = ProblemStringId[ProblemNumber];
-        else
-            MessageId = IDS_UNKNOWN;
 
         szBuffer[0] = L'\0';
         if (ProblemNumber == 0)
         {
-            if (LoadString(hDllInstance,
-                           MessageId,
-                           szBuffer,
-                           BufferSize))
-            {
-                Ret = TRUE;
-            }
+            goto UnknownProblem;
         }
         else
         {
@@ -485,6 +476,17 @@ GetDeviceStatusString(IN DEVINST DevInst,
             }
         }
     }
+    else
+    {
+UnknownProblem:
+        if (LoadString(hDllInstance,
+                       MessageId,
+                       szBuffer,
+                       BufferSize))
+        {
+            Ret = TRUE;
+        }
+    }
 
     return Ret;
 }