[FREELDR] Switch to RtlZeroMemory() from memset().
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Fri, 19 Nov 2021 01:22:00 +0000 (02:22 +0100)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Fri, 19 Nov 2021 01:22:20 +0000 (02:22 +0100)
boot/freeldr/freeldr/arch/i386/hwacpi.c
boot/freeldr/freeldr/arch/i386/hwpci.c
boot/freeldr/freeldr/arch/i386/ntoskrnl.c
boot/freeldr/freeldr/arch/i386/pc/machpc.c
boot/freeldr/freeldr/arch/i386/pc/pchw.c
boot/freeldr/freeldr/arch/i386/pc98/machpc98.c
boot/freeldr/freeldr/arch/i386/xbox/machxbox.c
boot/freeldr/freeldr/disk/partition.c
boot/freeldr/freeldr/lib/fs/btrfs.c

index 9b47111..120de9e 100644 (file)
@@ -81,7 +81,7 @@ DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
             return;
         }
 
-        memset(PartialResourceList, 0, sizeof(CM_PARTIAL_RESOURCE_LIST) + TableSize);
+        RtlZeroMemory(PartialResourceList, sizeof(CM_PARTIAL_RESOURCE_LIST) + TableSize);
         PartialResourceList->Version = 0;
         PartialResourceList->Revision = 0;
         PartialResourceList->Count = 1;
index 035572b..94bd4b5 100644 (file)
@@ -138,7 +138,7 @@ DetectPciIrqRoutingTable(PCONFIGURATION_COMPONENT_DATA BusKey)
         }
 
         /* Initialize resource descriptor */
-        memset(PartialResourceList, 0, Size);
+        RtlZeroMemory(PartialResourceList, Size);
         PartialResourceList->Version = 1;
         PartialResourceList->Revision = 1;
         PartialResourceList->Count = 2;
@@ -196,7 +196,7 @@ DetectPciBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
         }
 
         /* Initialize resource descriptor */
-        memset(PartialResourceList, 0, Size);
+        RtlZeroMemory(PartialResourceList, Size);
 
         /* Create new bus key */
         FldrCreateComponentKey(SystemKey,
@@ -235,7 +235,7 @@ DetectPciBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
                 }
 
                 /* Initialize resource descriptor */
-                memset(PartialResourceList, 0, Size);
+                RtlZeroMemory(PartialResourceList, Size);
                 PartialResourceList->Version = 1;
                 PartialResourceList->Revision = 1;
                 PartialResourceList->Count = 1;
@@ -261,7 +261,7 @@ DetectPciBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
                 }
 
                 /* Initialize resource descriptor */
-                memset(PartialResourceList, 0, Size);
+                RtlZeroMemory(PartialResourceList, Size);
             }
 
             /* Create the bus key */
index 4255e5c..40a3d16 100644 (file)
@@ -20,7 +20,7 @@ KeInitializeEvent(
     IN EVENT_TYPE Type,
     IN BOOLEAN State)
 {
-    memset(Event, 0, sizeof(*Event));
+    RtlZeroMemory(Event, sizeof(*Event));
 }
 
 VOID
index 2f0b356..8ac4139 100644 (file)
@@ -124,7 +124,7 @@ PcGetHarddiskConfigurationData(UCHAR DriveNumber, ULONG* pSize)
         return NULL;
     }
 
-    memset(PartialResourceList, 0, Size);
+    RtlZeroMemory(PartialResourceList, Size);
     PartialResourceList->Version = 1;
     PartialResourceList->Revision = 1;
     PartialResourceList->Count = 1;
@@ -617,7 +617,8 @@ DetectSerialPointerPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey,
             ERR("Failed to allocate resource descriptor\n");
             return;
         }
-        memset(PartialResourceList, 0, Size);
+
+        RtlZeroMemory(PartialResourceList, Size);
         PartialResourceList->Version = 1;
         PartialResourceList->Revision = 1;
         PartialResourceList->Count = 0;
@@ -936,7 +937,7 @@ DetectKeyboardPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey)
         }
 
         /* Initialize resource descriptor */
-        memset(PartialResourceList, 0, Size);
+        RtlZeroMemory(PartialResourceList, Size);
         PartialResourceList->Version = 1;
         PartialResourceList->Revision = 1;
         PartialResourceList->Count = 1;
@@ -997,7 +998,7 @@ DetectKeyboardController(PCONFIGURATION_COMPONENT_DATA BusKey)
     }
 
     /* Initialize resource descriptor */
-    memset(PartialResourceList, 0, Size);
+    RtlZeroMemory(PartialResourceList, Size);
     PartialResourceList->Version = 1;
     PartialResourceList->Revision = 1;
     PartialResourceList->Count = 3;
@@ -1215,7 +1216,8 @@ DetectPS2Mouse(PCONFIGURATION_COMPONENT_DATA BusKey)
                 ERR("Failed to allocate resource descriptor\n");
                 return;
             }
-            memset(PartialResourceList, 0, Size);
+
+            RtlZeroMemory(PartialResourceList, Size);
             PartialResourceList->Version = 1;
             PartialResourceList->Revision = 1;
             PartialResourceList->Count = 0;
@@ -1318,7 +1320,7 @@ DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
     }
 
     /* Initialize resource descriptor */
-    memset(PartialResourceList, 0, Size);
+    RtlZeroMemory(PartialResourceList, Size);
     PartialResourceList->Version = 1;
     PartialResourceList->Revision = 1;
     PartialResourceList->Count = 0;
@@ -1452,9 +1454,8 @@ VOID __cdecl ChainLoadBiosBootSectorCode(
 VOID
 MachInit(const char *CmdLine)
 {
-    memset(&MachVtbl, 0, sizeof(MACHVTBL));
-
     /* Setup vtbl */
+    RtlZeroMemory(&MachVtbl, sizeof(MachVtbl));
     MachVtbl.ConsPutChar = PcConsPutChar;
     MachVtbl.ConsKbHit = PcConsKbHit;
     MachVtbl.ConsGetCh = PcConsGetCh;
index f69de0f..6ade22f 100644 (file)
@@ -235,7 +235,7 @@ DetectBiosFloppyPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey)
             return;
         }
 
-        memset(PartialResourceList, 0, Size);
+        RtlZeroMemory(PartialResourceList, Size);
         PartialResourceList->Version = 1;
         PartialResourceList->Revision = 1;
         PartialResourceList->Count = 1;
@@ -375,7 +375,7 @@ DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA SystemKey,
     }
 
     /* Initialize resource descriptor */
-    memset(PartialResourceList, 0, Size);
+    RtlZeroMemory(PartialResourceList, Size);
     PartialResourceList->Version = 1;
     PartialResourceList->Revision = 1;
     PartialResourceList->Count = 1;
index 38ddf37..2ba4707 100644 (file)
@@ -118,6 +118,9 @@ MachInit(const char *CmdLine)
 {
     if (!Pc98ArchTest())
     {
+        ERR("This is not a supported PC98!\n");
+
+        /* Disable and halt the CPU */
         _disable();
         __halt();
 
@@ -126,7 +129,7 @@ MachInit(const char *CmdLine)
     }
 
     /* Setup vtbl */
-    RtlZeroMemory(&MachVtbl, sizeof(MACHVTBL));
+    RtlZeroMemory(&MachVtbl, sizeof(MachVtbl));
     MachVtbl.ConsPutChar = Pc98ConsPutChar;
     MachVtbl.ConsKbHit = Pc98ConsKbHit;
     MachVtbl.ConsGetCh = Pc98ConsGetCh;
index e2f6155..0aba6db 100644 (file)
@@ -110,7 +110,7 @@ XboxGetHarddiskConfigurationData(UCHAR DriveNumber, ULONG* pSize)
         return NULL;
     }
 
-    memset(PartialResourceList, 0, Size);
+    RtlZeroMemory(PartialResourceList, Size);
     PartialResourceList->Version = 1;
     PartialResourceList->Revision = 1;
     PartialResourceList->Count = 1;
@@ -223,7 +223,7 @@ DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
     }
 
     /* Initialize resource descriptor */
-    memset(PartialResourceList, 0, Size);
+    RtlZeroMemory(PartialResourceList, Size);
     PartialResourceList->Version = 1;
     PartialResourceList->Revision = 1;
     PartialResourceList->Count = 0;
@@ -304,8 +304,6 @@ MachInit(const char *CmdLine)
     PCI_TYPE1_CFG_BITS PciCfg1;
     ULONG PciId;
 
-    memset(&MachVtbl, 0, sizeof(MACHVTBL));
-
     /* Check for Xbox by identifying device at PCI 0:0:0, if it's
      * 0x10DE/0x02A5 then we're running on an Xbox */
 
@@ -322,19 +320,21 @@ MachInit(const char *CmdLine)
     PciId = READ_PORT_ULONG((PULONG)PCI_TYPE1_DATA_PORT);
     if (PciId != 0x02A510DE)
     {
-        ERR("This is not original Xbox!\n");
+        ERR("This is not an original Xbox!\n");
 
         /* Disable and halt the CPU */
         _disable();
         __halt();
 
-        while (TRUE);
+        while (TRUE)
+            NOTHING;
     }
 
     /* Set LEDs to red before anything is initialized */
     XboxSetLED("rrrr");
 
     /* Setup vtbl */
+    RtlZeroMemory(&MachVtbl, sizeof(MachVtbl));
     MachVtbl.ConsPutChar = XboxConsPutChar;
     MachVtbl.ConsKbHit = XboxConsKbHit;
     MachVtbl.ConsGetCh = XboxConsGetCh;
index 5738238..7afb6e1 100644 (file)
@@ -299,7 +299,7 @@ DiskGetBrfrPartitionEntry(
             return FALSE;
         }
 
-        memset(PartitionTableEntry, 0, sizeof(PARTITION_TABLE_ENTRY));
+        RtlZeroMemory(PartitionTableEntry, sizeof(PARTITION_TABLE_ENTRY));
         PartitionTableEntry->SystemIndicator = XboxPartitions[PartitionNumber - 1].SystemIndicator;
         PartitionTableEntry->SectorCountBeforePartition = XboxPartitions[PartitionNumber - 1].SectorCountBeforePartition;
         PartitionTableEntry->PartitionSectorCount = XboxPartitions[PartitionNumber - 1].PartitionSectorCount;
index 6b6a0c8..33cfb6e 100644 (file)
@@ -166,7 +166,7 @@ static inline unsigned long btrfs_chunk_item_size(int num_stripes)
 
 static inline void init_path(const struct btrfs_super_block *sb, struct btrfs_path *path)
 {
-    memset(path, 0, sizeof(*path));
+    RtlZeroMemory(path, sizeof(*path));
     path->tree_buf = FrLdrTempAlloc(sb->nodesize, TAG_BTRFS_NODE);
 }