https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9b9065df522be35a5b00a1d34e5425fc37a858b9

commit 9b9065df522be35a5b00a1d34e5425fc37a858b9
Author:     Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org>
AuthorDate: Sat Dec 16 12:52:39 2023 +0100
Commit:     Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org>
CommitDate: Mon Aug 12 12:04:39 2024 +0200

    [SETUPLIB] Move the initialization of other default values into 
InitializeSetup()
---
 base/setup/lib/setuplib.c | 54 ++++++++++++++++++++++-------------------------
 1 file changed, 25 insertions(+), 29 deletions(-)

diff --git a/base/setup/lib/setuplib.c b/base/setup/lib/setuplib.c
index 94f43cac05f..c8767c09375 100644
--- a/base/setup/lib/setuplib.c
+++ b/base/setup/lib/setuplib.c
@@ -104,7 +104,7 @@ CheckUnattendedSetup(
 
     INF_FreeData(Value);
 
-    /* Search for 'DestinationDiskNumber' in the 'Unattend' section */
+    /* Search for 'DestinationDiskNumber' */
     if (!SpInfFindFirstLine(UnattendInf, L"Unattend", 
L"DestinationDiskNumber", &Context))
     {
         DPRINT("SpInfFindFirstLine() failed for key 
'DestinationDiskNumber'\n");
@@ -119,7 +119,7 @@ CheckUnattendedSetup(
 
     pSetupData->DestinationDiskNumber = (LONG)IntValue;
 
-    /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
+    /* Search for 'DestinationPartitionNumber' */
     if (!SpInfFindFirstLine(UnattendInf, L"Unattend", 
L"DestinationPartitionNumber", &Context))
     {
         DPRINT("SpInfFindFirstLine() failed for key 
'DestinationPartitionNumber'\n");
@@ -134,56 +134,47 @@ CheckUnattendedSetup(
 
     pSetupData->DestinationPartitionNumber = (LONG)IntValue;
 
-    /* Search for 'InstallationDirectory' in the 'Unattend' section (optional) 
*/
+    /* Search for 'InstallationDirectory' (optional) */
     if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"InstallationDirectory", 
&Context))
     {
-        /* Get pointer 'InstallationDirectory' key */
-        if (!INF_GetData(&Context, NULL, &Value))
+        if (INF_GetData(&Context, NULL, &Value))
+        {
+            RtlStringCchCopyW(pSetupData->InstallationDirectory,
+                              ARRAYSIZE(pSetupData->InstallationDirectory),
+                              Value);
+            INF_FreeData(Value);
+        }
+        else
         {
             DPRINT("INF_GetData() failed for key 'InstallationDirectory'\n");
-            goto Quit;
         }
-
-        RtlStringCchCopyW(pSetupData->InstallationDirectory,
-                          ARRAYSIZE(pSetupData->InstallationDirectory),
-                          Value);
-
-        INF_FreeData(Value);
     }
 
     IsUnattendedSetup = TRUE;
     DPRINT("Running unattended setup\n");
 
-    /* Search for 'BootLoaderLocation' in the 'Unattend' section */
-    pSetupData->BootLoaderLocation = 2; // Default to "system partition"
+    /* Search for 'BootLoaderLocation' (optional) */
     if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"BootLoaderLocation", 
&Context))
     {
         if (SpInfGetIntField(&Context, 1, &IntValue))
-        {
             pSetupData->BootLoaderLocation = IntValue;
-        }
     }
 
-    /* Search for 'FormatPartition' in the 'Unattend' section */
-    pSetupData->FormatPartition = 0;
+    /* Search for 'FormatPartition' (optional) */
     if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"FormatPartition", 
&Context))
     {
         if (SpInfGetIntField(&Context, 1, &IntValue))
-        {
             pSetupData->FormatPartition = IntValue;
-        }
     }
 
-    pSetupData->AutoPartition = 0;
+    /* Search for 'AutoPartition' (optional) */
     if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"AutoPartition", 
&Context))
     {
         if (SpInfGetIntField(&Context, 1, &IntValue))
-        {
             pSetupData->AutoPartition = IntValue;
-        }
     }
 
-    /* Search for LocaleID in the 'Unattend' section */
+    /* Search for 'LocaleID' (optional) */
     if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"LocaleID", &Context))
     {
         if (INF_GetData(&Context, NULL, &Value))
@@ -193,17 +184,14 @@ CheckUnattendedSetup(
                                 ARRAYSIZE(pSetupData->LocaleID),
                                 L"%08lx", Id);
             INF_FreeData(Value);
-       }
+        }
     }
 
-    /* Search for FsType in the 'Unattend' section */
-    pSetupData->FsType = 0;
+    /* Search for 'FsType' (optional) */
     if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"FsType", &Context))
     {
         if (SpInfGetIntField(&Context, 1, &IntValue))
-        {
             pSetupData->FsType = IntValue;
-        }
     }
 
 Quit:
@@ -1021,6 +1009,14 @@ InitializeSetup(
         DPRINT1("SourceRootPath (1): '%wZ'\n", &pSetupData->SourceRootPath);
         DPRINT1("SourceRootDir (1): '%wZ'\n", &pSetupData->SourceRootDir);
 
+        /* Set up default values */
+        pSetupData->DestinationDiskNumber = 0;
+        pSetupData->DestinationPartitionNumber = 1;
+        pSetupData->BootLoaderLocation = 2; // Default to "System partition"
+        pSetupData->FormatPartition = 0;
+        pSetupData->AutoPartition = 0;
+        pSetupData->FsType = 0;
+
         /* Load 'txtsetup.sif' from the installation media */
         Error = LoadSetupInf(pSetupData);
         if (Error != ERROR_SUCCESS)

Reply via email to