https://git.reactos.org/?p=reactos.git;a=commitdiff;h=60d4a34892d80f9326e1947a2e91fec572b9895f

commit 60d4a34892d80f9326e1947a2e91fec572b9895f
Author:     Hermès Bélusca-Maïto <[email protected]>
AuthorDate: Fri Nov 19 02:22:00 2021 +0100
Commit:     Hermès Bélusca-Maïto <[email protected]>
CommitDate: Fri Nov 19 02:22:20 2021 +0100

    [FREELDR] Switch to RtlZeroMemory() from memset().
---
 boot/freeldr/freeldr/arch/i386/hwacpi.c        |  2 +-
 boot/freeldr/freeldr/arch/i386/hwpci.c         |  8 ++++----
 boot/freeldr/freeldr/arch/i386/ntoskrnl.c      |  2 +-
 boot/freeldr/freeldr/arch/i386/pc/machpc.c     | 17 +++++++++--------
 boot/freeldr/freeldr/arch/i386/pc/pchw.c       |  4 ++--
 boot/freeldr/freeldr/arch/i386/pc98/machpc98.c |  5 ++++-
 boot/freeldr/freeldr/arch/i386/xbox/machxbox.c | 12 ++++++------
 boot/freeldr/freeldr/disk/partition.c          |  2 +-
 boot/freeldr/freeldr/lib/fs/btrfs.c            |  2 +-
 9 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/boot/freeldr/freeldr/arch/i386/hwacpi.c 
b/boot/freeldr/freeldr/arch/i386/hwacpi.c
index 9b471116629..120de9ecb57 100644
--- a/boot/freeldr/freeldr/arch/i386/hwacpi.c
+++ b/boot/freeldr/freeldr/arch/i386/hwacpi.c
@@ -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;
diff --git a/boot/freeldr/freeldr/arch/i386/hwpci.c 
b/boot/freeldr/freeldr/arch/i386/hwpci.c
index 035572b4996..94bd4b59ecd 100644
--- a/boot/freeldr/freeldr/arch/i386/hwpci.c
+++ b/boot/freeldr/freeldr/arch/i386/hwpci.c
@@ -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 */
diff --git a/boot/freeldr/freeldr/arch/i386/ntoskrnl.c 
b/boot/freeldr/freeldr/arch/i386/ntoskrnl.c
index 4255e5cf0e0..40a3d16466e 100644
--- a/boot/freeldr/freeldr/arch/i386/ntoskrnl.c
+++ b/boot/freeldr/freeldr/arch/i386/ntoskrnl.c
@@ -20,7 +20,7 @@ KeInitializeEvent(
     IN EVENT_TYPE Type,
     IN BOOLEAN State)
 {
-    memset(Event, 0, sizeof(*Event));
+    RtlZeroMemory(Event, sizeof(*Event));
 }
 
 VOID
diff --git a/boot/freeldr/freeldr/arch/i386/pc/machpc.c 
b/boot/freeldr/freeldr/arch/i386/pc/machpc.c
index 2f0b3563b87..8ac4139442a 100644
--- a/boot/freeldr/freeldr/arch/i386/pc/machpc.c
+++ b/boot/freeldr/freeldr/arch/i386/pc/machpc.c
@@ -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;
diff --git a/boot/freeldr/freeldr/arch/i386/pc/pchw.c 
b/boot/freeldr/freeldr/arch/i386/pc/pchw.c
index f69de0f3c90..6ade22f7d42 100644
--- a/boot/freeldr/freeldr/arch/i386/pc/pchw.c
+++ b/boot/freeldr/freeldr/arch/i386/pc/pchw.c
@@ -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;
diff --git a/boot/freeldr/freeldr/arch/i386/pc98/machpc98.c 
b/boot/freeldr/freeldr/arch/i386/pc98/machpc98.c
index 38ddf378378..2ba4707de7a 100644
--- a/boot/freeldr/freeldr/arch/i386/pc98/machpc98.c
+++ b/boot/freeldr/freeldr/arch/i386/pc98/machpc98.c
@@ -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;
diff --git a/boot/freeldr/freeldr/arch/i386/xbox/machxbox.c 
b/boot/freeldr/freeldr/arch/i386/xbox/machxbox.c
index e2f615593cd..0aba6db9c49 100644
--- a/boot/freeldr/freeldr/arch/i386/xbox/machxbox.c
+++ b/boot/freeldr/freeldr/arch/i386/xbox/machxbox.c
@@ -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;
diff --git a/boot/freeldr/freeldr/disk/partition.c 
b/boot/freeldr/freeldr/disk/partition.c
index 5738238ecd4..7afb6e1edbc 100644
--- a/boot/freeldr/freeldr/disk/partition.c
+++ b/boot/freeldr/freeldr/disk/partition.c
@@ -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;
diff --git a/boot/freeldr/freeldr/lib/fs/btrfs.c 
b/boot/freeldr/freeldr/lib/fs/btrfs.c
index 6b6a0c87d83..33cfb6e9d9f 100644
--- a/boot/freeldr/freeldr/lib/fs/btrfs.c
+++ b/boot/freeldr/freeldr/lib/fs/btrfs.c
@@ -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);
 }
 

Reply via email to