[FREELDR] Minor code formatting; constify some non-mutable data.
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 6 Jan 2019 17:34:49 +0000 (18:34 +0100)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 6 Jan 2019 17:42:01 +0000 (18:42 +0100)
boot/freeldr/freeldr/arch/i386/hwdisk.c
boot/freeldr/freeldr/arch/i386/i386bug.c
boot/freeldr/freeldr/arch/powerpc/mach.c
boot/freeldr/freeldr/arch/realmode/amd64.S
boot/freeldr/freeldr/arch/realmode/i386.S
boot/freeldr/freeldr/bootmgr.c
boot/freeldr/freeldr/custom.c
boot/freeldr/freeldr/include/ver.h
boot/freeldr/freeldr/ntldr/wlmemory.c
boot/freeldr/freeldr/options.c
boot/freeldr/freeldr/version.c

index 6123fc1..a254aee 100644 (file)
@@ -38,7 +38,7 @@ typedef struct tagDISKCONTEXT
     ULONGLONG SectorNumber;
 } DISKCONTEXT;
 
-static CHAR Hex[] = "0123456789abcdef";
+static const CHAR Hex[] = "0123456789abcdef";
 
 /* Data cache for BIOS disks pre-enumeration */
 UCHAR PcBiosDiskCount = 0;
index c5c82af..6d42279 100644 (file)
@@ -9,7 +9,7 @@ typedef struct _FRAME
     void *Address;
 } FRAME;
 
-char *i386ExceptionDescriptionText[] =
+static const char *i386ExceptionDescriptionText[] =
 {
     "Exception 00: DIVIDE BY ZERO\n\n",
     "Exception 01: DEBUG EXCEPTION\n\n",
index 552b75f..c00604e 100644 (file)
@@ -24,7 +24,7 @@
 #include "compat.h"
 
 extern void BootMain( LPSTR CmdLine );
-extern PCHAR GetFreeLoaderVersionString();
+extern const PCSTR GetFreeLoaderVersionString(VOID);
 extern ULONG CacheSizeLimit;
 of_proxy ofproxy;
 void *PageDirectoryStart, *PageDirectoryEnd;
index 0de7bf4..528fd4b 100644 (file)
@@ -6,7 +6,6 @@
 #define IMAGE_FILE_HEADER_SIZE 20
 #define IMAGE_OPTIONAL_HEADER_AddressOfEntryPoint 16
 
-
 .code16
 
 /* fat helper code */
@@ -292,7 +291,7 @@ ExitToLongMode:
     mov gs,ax
     mov ss,ax
 
-    /* Safe current stack pointer */
+    /* Save current stack pointer */
     mov word ptr ds:[stack16], sp
 
     /* Set PAE and PGE: 10100000b */
index 0c79ae1..4f47f4b 100644 (file)
@@ -30,7 +30,7 @@ RealModeEntryPoint:
     /* Enable A20 address line */
     call EnableA20
 
-    /* Safe real mode entry point in shared memory */
+    /* Save real mode entry point in shared memory */
     mov dword ptr ds:[BSS_RealModeEntry], offset switch_to_real16
 
     /* Address the image with es segment */
@@ -116,7 +116,7 @@ exit_to_protected:
 
     cli
 
-    /* Safe current stack pointer */
+    /* Save current stack pointer */
     mov word ptr ds:[stack16], sp
 
     /* Load the GDT */
index e370c28..ed506ae 100644 (file)
@@ -29,9 +29,9 @@ VOID
 (*OS_LOADING_METHOD)(IN OperatingSystemItem* OperatingSystem,
                      IN USHORT OperatingSystemVersion);
 
-struct
+static const struct
 {
-    CHAR BootType[80];
+    PCHAR BootType;
     USHORT OperatingSystemVersion;
     OS_LOADING_METHOD Load;
 } OSLoadingMethods[] =
index 802d295..02e55b6 100644 (file)
@@ -51,13 +51,12 @@ VOID OptionMenuCustomBoot(VOID)
 #endif
         "ReactOS"
         };
-    ULONG CustomBootMenuCount = sizeof(CustomBootMenuList) / sizeof(CustomBootMenuList[0]);
     ULONG SelectedMenuItem;
 
     if (!UiDisplayMenu("Please choose a boot method:", "",
                        FALSE,
                        CustomBootMenuList,
-                       CustomBootMenuCount,
+                       sizeof(CustomBootMenuList) / sizeof(CustomBootMenuList[0]),
                        0, -1,
                        &SelectedMenuItem,
                        TRUE,
index ad5c02a..d796f7a 100644 (file)
@@ -36,4 +36,4 @@
 #define FREELOADER_MINOR_VERSION    0
 #define FREELOADER_PATCH_VERSION    0
 
-PCHAR GetFreeLoaderVersionString(VOID);
+const PCSTR GetFreeLoaderVersionString(VOID);
index 99a1c9d..8259c38 100644 (file)
@@ -17,7 +17,7 @@ DBG_DEFAULT_CHANNEL(WINDOWS);
 
 extern ULONG LoaderPagesSpanned;
 
-PCHAR  MemTypeDesc[]  = {
+static const PCSTR MemTypeDesc[] = {
     "ExceptionBlock    ", // ?
     "SystemBlock       ", // ?
     "Free              ",
index ebb7709..0300b02 100644 (file)
@@ -50,6 +50,7 @@ PCSTR OptionsMenuList[] =
 #endif
 };
 
+const
 PCSTR FrldrDbgMsg = "Enable FreeLdr debug channels\n"
                     "Acceptable syntax: [level1]#channel1[,[level2]#channel2]\n"
                     "level can be one of: trace,warn,fixme,err\n"
@@ -78,8 +79,6 @@ enum BootOption
     DIRECTORY_SERVICES_RESTORE_MODE,
 };
 
-ULONG OptionsMenuItemCount = sizeof(OptionsMenuList) / sizeof(OptionsMenuList[0]);
-
 static enum BootOption BootOptionChoice = NO_OPTION;
 static BOOLEAN BootLogging = FALSE;
 static BOOLEAN VgaMode = FALSE;
@@ -95,7 +94,7 @@ VOID DoOptionsMenu(VOID)
     if (!UiDisplayMenu("Select an option:", "",
                        TRUE,
                        OptionsMenuList,
-                       OptionsMenuItemCount,
+                       sizeof(OptionsMenuList) / sizeof(OptionsMenuList[0]),
                        11, // Use "Start ReactOS normally" as default; see the switch below.
                        -1,
                        &SelectedMenuItem,
index e64864d..fcd2521 100644 (file)
 
 #include <freeldr.h>
 
-CHAR FreeLoaderVersionString[80];
+#define TOSTRING_(X) #X
+#define TOSTRING(X) TOSTRING_(X)
 
-PCHAR GetFreeLoaderVersionString(VOID)
-{
+static const PCSTR FreeLoaderVersionString =
 #if (FREELOADER_PATCH_VERSION == 0)
-    sprintf(FreeLoaderVersionString, "FreeLoader v%d.%d", FREELOADER_MAJOR_VERSION, FREELOADER_MINOR_VERSION);
+    "FreeLoader v" TOSTRING(FREELOADER_MAJOR_VERSION) "." TOSTRING(FREELOADER_MINOR_VERSION);
 #else
-    sprintf(FreeLoaderVersionString, "FreeLoader v%d.%d.%d", FREELOADER_MAJOR_VERSION, FREELOADER_MINOR_VERSION, FREELOADER_PATCH_VERSION);
+    "FreeLoader v" TOSTRING(FREELOADER_MAJOR_VERSION) "." TOSTRING(FREELOADER_MINOR_VERSION) "." TOSTRING(FREELOADER_PATCH_VERSION);
 #endif
 
+const PCSTR GetFreeLoaderVersionString(VOID)
+{
     return FreeLoaderVersionString;
 }