[USETUP] Simplify code.
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Mon, 28 Aug 2017 13:51:25 +0000 (13:51 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 27 Oct 2018 16:13:44 +0000 (18:13 +0200)
svn path=/branches/setup_improvements/; revision=75698

base/setup/usetup/settings.c

index b7482ad..2866c53 100644 (file)
@@ -337,6 +337,8 @@ CreateComputerTypeList(
 
     do
     {
 
     do
     {
+        BOOLEAN FoundId;
+
         if (!INF_GetDataField(&Context, 1, &KeyValue))
         {
             /* FIXME: Handle error! */
         if (!INF_GetDataField(&Context, 1, &KeyValue))
         {
             /* FIXME: Handle error! */
@@ -345,21 +347,22 @@ CreateComputerTypeList(
         }
 
         DPRINT("KeyValue: %S\n", KeyValue);
         }
 
         DPRINT("KeyValue: %S\n", KeyValue);
-        if (wcsstr(ComputerIdentifier, KeyValue))
-        {
-            INF_FreeData(KeyValue);
-            if (!INF_GetDataField(&Context, 0, &KeyName))
-            {
-                /* FIXME: Handle error! */
-                DPRINT("INF_GetDataField() failed\n");
-                return NULL;
-            }
+        FoundId = !!wcsstr(ComputerIdentifier, KeyValue);
+        INF_FreeData(KeyValue);
 
 
-            DPRINT("Computer key: %S\n", KeyName);
-            wcscpy(ComputerKey, KeyName);
-            INF_FreeData(KeyName);
+        if (!FoundId)
+            continue;
+
+        if (!INF_GetDataField(&Context, 0, &KeyName))
+        {
+            /* FIXME: Handle error! */
+            DPRINT("INF_GetDataField() failed\n");
+            return NULL;
         }
         }
-        INF_FreeData(KeyValue);
+
+        DPRINT("Computer key: %S\n", KeyName);
+        wcscpy(ComputerKey, KeyName);
+        INF_FreeData(KeyName);
     } while (SetupFindNextLine(&Context, &Context));
 
     List = CreateGenericList();
     } while (SetupFindNextLine(&Context, &Context));
 
     List = CreateGenericList();
@@ -594,6 +597,8 @@ CreateDisplayDriverList(
 
     do
     {
 
     do
     {
+        BOOLEAN FoundId;
+
         if (!INF_GetDataField(&Context, 1, &KeyValue))
         {
             /* FIXME: Handle error! */
         if (!INF_GetDataField(&Context, 1, &KeyValue))
         {
             /* FIXME: Handle error! */
@@ -602,21 +607,22 @@ CreateDisplayDriverList(
         }
 
         DPRINT("KeyValue: %S\n", KeyValue);
         }
 
         DPRINT("KeyValue: %S\n", KeyValue);
-        if (wcsstr(DisplayIdentifier, KeyValue))
-        {
-            INF_FreeData(KeyValue);
-            if (!INF_GetDataField(&Context, 0, &KeyName))
-            {
-                /* FIXME: Handle error! */
-                DPRINT("INF_GetDataField() failed\n");
-                return NULL;
-            }
+        FoundId = !!wcsstr(DisplayIdentifier, KeyValue);
+        INF_FreeData(KeyValue);
 
 
-            DPRINT("Display key: %S\n", KeyName);
-            wcscpy(DisplayKey, KeyName);
-            INF_FreeData(KeyName);
+        if (!FoundId)
+            continue;
+
+        if (!INF_GetDataField(&Context, 0, &KeyName))
+        {
+            /* FIXME: Handle error! */
+            DPRINT("INF_GetDataField() failed\n");
+            return NULL;
         }
         }
-        INF_FreeData(KeyValue);
+
+        DPRINT("Display key: %S\n", KeyName);
+        wcscpy(DisplayKey, KeyName);
+        INF_FreeData(KeyName);
     } while (SetupFindNextLine(&Context, &Context));
 
     List = CreateGenericList();
     } while (SetupFindNextLine(&Context, &Context));
 
     List = CreateGenericList();