Author: hbelusca
Date: Sun Dec 27 19:30:53 2015
New Revision: 70445
URL:
http://svn.reactos.org/svn/reactos?rev=70445&view=rev
Log:
[VFATLIB]
- Formatting fixes.
- Use RtlZeroMemory/RtlFillMemory instead of memset.
Modified:
trunk/reactos/lib/fslib/vfatlib/common.c
trunk/reactos/lib/fslib/vfatlib/fat12.c
trunk/reactos/lib/fslib/vfatlib/fat16.c
Modified: trunk/reactos/lib/fslib/vfatlib/common.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/common.c…
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/common.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/common.c [iso-8859-1] Sun Dec 27 19:30:53 2015
@@ -129,7 +129,6 @@
done:
/* Free the buffer */
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
-
return Status;
}
Modified: trunk/reactos/lib/fslib/vfatlib/fat12.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/fat12.c?…
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/fat12.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/fat12.c [iso-8859-1] Sun Dec 27 19:30:53 2015
@@ -35,12 +35,13 @@
return STATUS_INSUFFICIENT_RESOURCES;
/* Zero the new bootsector */
- memset(NewBootSector, 0, BootSector->BytesPerSector);
+ RtlZeroMemory(NewBootSector, BootSector->BytesPerSector);
/* Copy FAT16 BPB to new bootsector */
memcpy(&NewBootSector->OEMName[0],
&BootSector->OEMName[0],
- FIELD_OFFSET(FAT16_BOOT_SECTOR, Res2) - FIELD_OFFSET(FAT16_BOOT_SECTOR,
OEMName)); /* FAT16 BPB length (up to (not including) Res2) */
+ FIELD_OFFSET(FAT16_BOOT_SECTOR, Res2) - FIELD_OFFSET(FAT16_BOOT_SECTOR,
OEMName));
+ /* FAT16 BPB length (up to (not including) Res2) */
/* Write the boot sector signature */
NewBootSector->Signature1 = 0xAA550000;
@@ -59,15 +60,14 @@
if (!NT_SUCCESS(Status))
{
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
- RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
- return Status;
- }
-
- /* Free the new boot sector */
+ goto done;
+ }
+
+ UpdateProgress(Context, 1);
+
+done:
+ /* Free the buffer */
RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
-
- UpdateProgress(Context, 1);
-
return Status;
}
@@ -94,7 +94,7 @@
return STATUS_INSUFFICIENT_RESOURCES;
/* Zero the buffer */
- memset(Buffer, 0, 32 * 1024);
+ RtlZeroMemory(Buffer, 32 * 1024);
/* FAT cluster 0 & 1*/
Buffer[0] = 0xf8; /* Media type */
@@ -115,14 +115,13 @@
if (!NT_SUCCESS(Status))
{
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
- RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
- return Status;
+ goto done;
}
UpdateProgress(Context, 1);
/* Zero the begin of the buffer */
- memset(Buffer, 0, 3);
+ RtlZeroMemory(Buffer, 3);
/* Zero the rest of the FAT */
Sectors = 32 * 1024 / BootSector->BytesPerSector;
@@ -148,16 +147,15 @@
if (!NT_SUCCESS(Status))
{
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
- RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
- return Status;
+ goto done;
}
UpdateProgress(Context, Sectors);
}
+done:
/* Free the buffer */
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
-
return Status;
}
@@ -198,7 +196,7 @@
return STATUS_INSUFFICIENT_RESOURCES;
/* Zero the buffer */
- memset(Buffer, 0, 32 * 1024);
+ RtlZeroMemory(Buffer, 32 * 1024);
Sectors = 32 * 1024 / BootSector->BytesPerSector;
for (i = 0; i < RootDirSectors; i += Sectors)
@@ -225,16 +223,15 @@
if (!NT_SUCCESS(Status))
{
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
- RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
- return Status;
+ goto done;
}
UpdateProgress(Context, Sectors);
}
+done:
/* Free the buffer */
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
-
return Status;
}
@@ -277,7 +274,7 @@
DPRINT("SectorCount = %lu\n", SectorCount);
- memset(&BootSector, 0, sizeof(FAT16_BOOT_SECTOR));
+ RtlZeroMemory(&BootSector, sizeof(FAT16_BOOT_SECTOR));
memcpy(&BootSector.OEMName[0], "MSWIN4.1", 8);
BootSector.BytesPerSector = DiskGeometry->BytesPerSector;
BootSector.SectorsPerCluster = ClusterSize / BootSector.BytesPerSector;
@@ -301,7 +298,7 @@
else
{
RtlUnicodeStringToOemString(&VolumeLabel, Label, TRUE);
- memset(&BootSector.VolumeLabel[0], ' ', 11);
+ RtlFillMemory(&BootSector.VolumeLabel[0], 11, ' ');
memcpy(&BootSector.VolumeLabel[0], VolumeLabel.Buffer,
VolumeLabel.Length < 11 ? VolumeLabel.Length : 11);
RtlFreeOemString(&VolumeLabel);
Modified: trunk/reactos/lib/fslib/vfatlib/fat16.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/fat16.c?…
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/fat16.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/fat16.c [iso-8859-1] Sun Dec 27 19:30:53 2015
@@ -35,12 +35,13 @@
return STATUS_INSUFFICIENT_RESOURCES;
/* Zero the new bootsector */
- memset(NewBootSector, 0, BootSector->BytesPerSector);
+ RtlZeroMemory(NewBootSector, BootSector->BytesPerSector);
/* Copy FAT16 BPB to new bootsector */
memcpy(&NewBootSector->OEMName[0],
&BootSector->OEMName[0],
- FIELD_OFFSET(FAT16_BOOT_SECTOR, Res2) - FIELD_OFFSET(FAT16_BOOT_SECTOR,
OEMName)); /* FAT16 BPB length (up to (not including) Res2) */
+ FIELD_OFFSET(FAT16_BOOT_SECTOR, Res2) - FIELD_OFFSET(FAT16_BOOT_SECTOR,
OEMName));
+ /* FAT16 BPB length (up to (not including) Res2) */
/* Write the boot sector signature */
NewBootSector->Signature1 = 0xAA550000;
@@ -59,15 +60,14 @@
if (!NT_SUCCESS(Status))
{
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
- RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
- return Status;
+ goto done;
}
UpdateProgress(Context, 1);
- /* Free the new boot sector */
+done:
+ /* Free the buffer */
RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
-
return Status;
}
@@ -93,7 +93,7 @@
return STATUS_INSUFFICIENT_RESOURCES;
/* Zero the buffer */
- memset(Buffer, 0, 32 * 1024);
+ RtlZeroMemory(Buffer, 32 * 1024);
/* FAT cluster 0 */
Buffer[0] = 0xf8; /* Media type */
@@ -117,14 +117,13 @@
if (!NT_SUCCESS(Status))
{
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
- RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
- return Status;
+ goto done;
}
UpdateProgress(Context, 1);
/* Zero the begin of the buffer */
- memset(Buffer, 0, 4);
+ RtlZeroMemory(Buffer, 4);
/* Zero the rest of the FAT */
Sectors = 32 * 1024 / BootSector->BytesPerSector;
@@ -150,16 +149,15 @@
if (!NT_SUCCESS(Status))
{
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
- RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
- return Status;
+ goto done;
}
UpdateProgress(Context, Sectors);
}
+done:
/* Free the buffer */
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
-
return Status;
}
@@ -199,7 +197,7 @@
return STATUS_INSUFFICIENT_RESOURCES;
/* Zero the buffer */
- memset(Buffer, 0, 32 * 1024);
+ RtlZeroMemory(Buffer, 32 * 1024);
Sectors = 32 * 1024 / BootSector->BytesPerSector;
for (i = 0; i < RootDirSectors; i += Sectors)
@@ -224,16 +222,15 @@
if (!NT_SUCCESS(Status))
{
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
- RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
- return Status;
+ goto done;
}
UpdateProgress(Context, Sectors);
}
+done:
/* Free the buffer */
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
-
return Status;
}
@@ -284,7 +281,7 @@
SectorCount = PartitionInfo->PartitionLength.QuadPart >>
GetShiftCount(DiskGeometry->BytesPerSector); /* Use shifting to avoid 64-bit
division */
- memset(&BootSector, 0, sizeof(FAT16_BOOT_SECTOR));
+ RtlZeroMemory(&BootSector, sizeof(FAT16_BOOT_SECTOR));
memcpy(&BootSector.OEMName[0], "MSWIN4.1", 8);
BootSector.BytesPerSector = DiskGeometry->BytesPerSector;
BootSector.SectorsPerCluster = ClusterSize / BootSector.BytesPerSector;
@@ -308,7 +305,7 @@
else
{
RtlUnicodeStringToOemString(&VolumeLabel, Label, TRUE);
- memset(&BootSector.VolumeLabel[0], ' ', 11);
+ RtlFillMemory(&BootSector.VolumeLabel[0], 11, ' ');
memcpy(&BootSector.VolumeLabel[0], VolumeLabel.Buffer,
VolumeLabel.Length < 11 ? VolumeLabel.Length : 11);
RtlFreeOemString(&VolumeLabel);