MdePkg: Apply uncrustify changes

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Apply uncrustify changes to .c/.h files in the MdePkg package

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
Michael Kubacki
2021-12-05 14:54:05 -08:00
committed by mergify[bot]
parent 1436aea4d5
commit 2f88bd3a12
975 changed files with 55681 additions and 57790 deletions

View File

@@ -48,9 +48,10 @@ CompareMem (
IN UINTN Length
)
{
if (Length == 0 || DestinationBuffer == SourceBuffer) {
if ((Length == 0) || (DestinationBuffer == SourceBuffer)) {
return 0;
}
ASSERT (DestinationBuffer != NULL);
ASSERT (SourceBuffer != NULL);
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer));

View File

@@ -11,9 +11,6 @@
**/
#include "MemLibInternals.h"
/**
@@ -29,9 +26,9 @@
VOID *
EFIAPI
InternalMemCopyMem (
OUT VOID *DestinationBuffer,
IN CONST VOID *SourceBuffer,
IN UINTN Length
OUT VOID *DestinationBuffer,
IN CONST VOID *SourceBuffer,
IN UINTN Length
)
{
//
@@ -39,32 +36,32 @@ InternalMemCopyMem (
// volatile to prevent the optimizer from replacing this function with
// the intrinsic memcpy()
//
volatile UINT8 *Destination8;
CONST UINT8 *Source8;
volatile UINT32 *Destination32;
CONST UINT32 *Source32;
volatile UINT64 *Destination64;
CONST UINT64 *Source64;
UINTN Alignment;
volatile UINT8 *Destination8;
CONST UINT8 *Source8;
volatile UINT32 *Destination32;
CONST UINT32 *Source32;
volatile UINT64 *Destination64;
CONST UINT64 *Source64;
UINTN Alignment;
if ((((UINTN)DestinationBuffer & 0x7) == 0) && (((UINTN)SourceBuffer & 0x7) == 0) && (Length >= 8)) {
if (SourceBuffer > DestinationBuffer) {
Destination64 = (UINT64*)DestinationBuffer;
Source64 = (CONST UINT64*)SourceBuffer;
Destination64 = (UINT64 *)DestinationBuffer;
Source64 = (CONST UINT64 *)SourceBuffer;
while (Length >= 8) {
*(Destination64++) = *(Source64++);
Length -= 8;
Length -= 8;
}
// Finish if there are still some bytes to copy
Destination8 = (UINT8*)Destination64;
Source8 = (CONST UINT8*)Source64;
Destination8 = (UINT8 *)Destination64;
Source8 = (CONST UINT8 *)Source64;
while (Length-- != 0) {
*(Destination8++) = *(Source8++);
}
} else if (SourceBuffer < DestinationBuffer) {
Destination64 = (UINT64*)((UINTN)DestinationBuffer + Length);
Source64 = (CONST UINT64*)((UINTN)SourceBuffer + Length);
Destination64 = (UINT64 *)((UINTN)DestinationBuffer + Length);
Source64 = (CONST UINT64 *)((UINTN)SourceBuffer + Length);
// Destination64 and Source64 were aligned on a 64-bit boundary
// but if length is not a multiple of 8 bytes then they won't be
@@ -72,40 +69,41 @@ InternalMemCopyMem (
Alignment = Length & 0x7;
if (Alignment != 0) {
Destination8 = (UINT8*)Destination64;
Source8 = (CONST UINT8*)Source64;
Destination8 = (UINT8 *)Destination64;
Source8 = (CONST UINT8 *)Source64;
while (Alignment-- != 0) {
*(--Destination8) = *(--Source8);
--Length;
}
Destination64 = (UINT64*)Destination8;
Source64 = (CONST UINT64*)Source8;
Destination64 = (UINT64 *)Destination8;
Source64 = (CONST UINT64 *)Source8;
}
while (Length > 0) {
*(--Destination64) = *(--Source64);
Length -= 8;
Length -= 8;
}
}
} else if ((((UINTN)DestinationBuffer & 0x3) == 0) && (((UINTN)SourceBuffer & 0x3) == 0) && (Length >= 4)) {
if (SourceBuffer > DestinationBuffer) {
Destination32 = (UINT32*)DestinationBuffer;
Source32 = (CONST UINT32*)SourceBuffer;
Destination32 = (UINT32 *)DestinationBuffer;
Source32 = (CONST UINT32 *)SourceBuffer;
while (Length >= 4) {
*(Destination32++) = *(Source32++);
Length -= 4;
Length -= 4;
}
// Finish if there are still some bytes to copy
Destination8 = (UINT8*)Destination32;
Source8 = (CONST UINT8*)Source32;
Destination8 = (UINT8 *)Destination32;
Source8 = (CONST UINT8 *)Source32;
while (Length-- != 0) {
*(Destination8++) = *(Source8++);
}
} else if (SourceBuffer < DestinationBuffer) {
Destination32 = (UINT32*)((UINTN)DestinationBuffer + Length);
Source32 = (CONST UINT32*)((UINTN)SourceBuffer + Length);
Destination32 = (UINT32 *)((UINTN)DestinationBuffer + Length);
Source32 = (CONST UINT32 *)((UINTN)SourceBuffer + Length);
// Destination32 and Source32 were aligned on a 32-bit boundary
// but if length is not a multiple of 4 bytes then they won't be
@@ -113,36 +111,38 @@ InternalMemCopyMem (
Alignment = Length & 0x3;
if (Alignment != 0) {
Destination8 = (UINT8*)Destination32;
Source8 = (CONST UINT8*)Source32;
Destination8 = (UINT8 *)Destination32;
Source8 = (CONST UINT8 *)Source32;
while (Alignment-- != 0) {
*(--Destination8) = *(--Source8);
--Length;
}
Destination32 = (UINT32*)Destination8;
Source32 = (CONST UINT32*)Source8;
Destination32 = (UINT32 *)Destination8;
Source32 = (CONST UINT32 *)Source8;
}
while (Length > 0) {
*(--Destination32) = *(--Source32);
Length -= 4;
Length -= 4;
}
}
} else {
if (SourceBuffer > DestinationBuffer) {
Destination8 = (UINT8*)DestinationBuffer;
Source8 = (CONST UINT8*)SourceBuffer;
Destination8 = (UINT8 *)DestinationBuffer;
Source8 = (CONST UINT8 *)SourceBuffer;
while (Length-- != 0) {
*(Destination8++) = *(Source8++);
}
} else if (SourceBuffer < DestinationBuffer) {
Destination8 = (UINT8*)DestinationBuffer + (Length - 1);
Source8 = (CONST UINT8*)SourceBuffer + (Length - 1);
Destination8 = (UINT8 *)DestinationBuffer + (Length - 1);
Source8 = (CONST UINT8 *)SourceBuffer + (Length - 1);
while (Length-- != 0) {
*(Destination8--) = *(Source8--);
}
}
}
return DestinationBuffer;
}

View File

@@ -47,11 +47,13 @@ CopyMem (
if (Length == 0) {
return DestinationBuffer;
}
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer));
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer));
if (DestinationBuffer == SourceBuffer) {
return DestinationBuffer;
}
return InternalMemCopyMem (DestinationBuffer, SourceBuffer, Length);
}

View File

@@ -26,14 +26,15 @@
VOID *
EFIAPI
InternalMemSetMem16 (
OUT VOID *Buffer,
IN UINTN Length,
IN UINT16 Value
OUT VOID *Buffer,
IN UINTN Length,
IN UINT16 Value
)
{
for (; Length != 0; Length--) {
((UINT16*)Buffer)[Length - 1] = Value;
for ( ; Length != 0; Length--) {
((UINT16 *)Buffer)[Length - 1] = Value;
}
return Buffer;
}
@@ -50,14 +51,15 @@ InternalMemSetMem16 (
VOID *
EFIAPI
InternalMemSetMem32 (
OUT VOID *Buffer,
IN UINTN Length,
IN UINT32 Value
OUT VOID *Buffer,
IN UINTN Length,
IN UINT32 Value
)
{
for (; Length != 0; Length--) {
((UINT32*)Buffer)[Length - 1] = Value;
for ( ; Length != 0; Length--) {
((UINT32 *)Buffer)[Length - 1] = Value;
}
return Buffer;
}
@@ -74,14 +76,15 @@ InternalMemSetMem32 (
VOID *
EFIAPI
InternalMemSetMem64 (
OUT VOID *Buffer,
IN UINTN Length,
IN UINT64 Value
OUT VOID *Buffer,
IN UINTN Length,
IN UINT64 Value
)
{
for (; Length != 0; Length--) {
((UINT64*)Buffer)[Length - 1] = Value;
for ( ; Length != 0; Length--) {
((UINT64 *)Buffer)[Length - 1] = Value;
}
return Buffer;
}
@@ -97,8 +100,8 @@ InternalMemSetMem64 (
VOID *
EFIAPI
InternalMemZeroMem (
OUT VOID *Buffer,
IN UINTN Length
OUT VOID *Buffer,
IN UINTN Length
)
{
return InternalMemSetMem (Buffer, Length, 0);
@@ -120,17 +123,19 @@ InternalMemZeroMem (
INTN
EFIAPI
InternalMemCompareMem (
IN CONST VOID *DestinationBuffer,
IN CONST VOID *SourceBuffer,
IN UINTN Length
IN CONST VOID *DestinationBuffer,
IN CONST VOID *SourceBuffer,
IN UINTN Length
)
{
while ((--Length != 0) &&
(*(INT8*)DestinationBuffer == *(INT8*)SourceBuffer)) {
DestinationBuffer = (INT8*)DestinationBuffer + 1;
SourceBuffer = (INT8*)SourceBuffer + 1;
(*(INT8 *)DestinationBuffer == *(INT8 *)SourceBuffer))
{
DestinationBuffer = (INT8 *)DestinationBuffer + 1;
SourceBuffer = (INT8 *)SourceBuffer + 1;
}
return (INTN)*(UINT8*)DestinationBuffer - (INTN)*(UINT8*)SourceBuffer;
return (INTN)*(UINT8 *)DestinationBuffer - (INTN)*(UINT8 *)SourceBuffer;
}
/**
@@ -147,20 +152,22 @@ InternalMemCompareMem (
CONST VOID *
EFIAPI
InternalMemScanMem8 (
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINT8 Value
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINT8 Value
)
{
CONST UINT8 *Pointer;
CONST UINT8 *Pointer;
Pointer = (CONST UINT8*)Buffer;
Pointer = (CONST UINT8 *)Buffer;
do {
if (*Pointer == Value) {
return Pointer;
}
++Pointer;
} while (--Length != 0);
return NULL;
}
@@ -178,20 +185,22 @@ InternalMemScanMem8 (
CONST VOID *
EFIAPI
InternalMemScanMem16 (
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINT16 Value
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINT16 Value
)
{
CONST UINT16 *Pointer;
CONST UINT16 *Pointer;
Pointer = (CONST UINT16*)Buffer;
Pointer = (CONST UINT16 *)Buffer;
do {
if (*Pointer == Value) {
return Pointer;
}
++Pointer;
} while (--Length != 0);
return NULL;
}
@@ -209,20 +218,22 @@ InternalMemScanMem16 (
CONST VOID *
EFIAPI
InternalMemScanMem32 (
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINT32 Value
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINT32 Value
)
{
CONST UINT32 *Pointer;
CONST UINT32 *Pointer;
Pointer = (CONST UINT32*)Buffer;
Pointer = (CONST UINT32 *)Buffer;
do {
if (*Pointer == Value) {
return Pointer;
}
++Pointer;
} while (--Length != 0);
return NULL;
}
@@ -240,20 +251,22 @@ InternalMemScanMem32 (
CONST VOID *
EFIAPI
InternalMemScanMem64 (
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINT64 Value
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINT64 Value
)
{
CONST UINT64 *Pointer;
CONST UINT64 *Pointer;
Pointer = (CONST UINT64*)Buffer;
Pointer = (CONST UINT64 *)Buffer;
do {
if (*Pointer == Value) {
return Pointer;
}
++Pointer;
} while (--Length != 0);
return NULL;
}
@@ -274,8 +287,8 @@ InternalMemIsZeroBuffer (
IN UINTN Length
)
{
CONST UINT8 *BufferData;
UINTN Index;
CONST UINT8 *BufferData;
UINTN Index;
BufferData = Buffer;
for (Index = 0; Index < Length; Index++) {
@@ -283,5 +296,6 @@ InternalMemIsZeroBuffer (
return FALSE;
}
}
return TRUE;
}

View File

@@ -42,12 +42,12 @@ CopyGuid (
)
{
WriteUnaligned64 (
(UINT64*)DestinationGuid,
ReadUnaligned64 ((CONST UINT64*)SourceGuid)
(UINT64 *)DestinationGuid,
ReadUnaligned64 ((CONST UINT64 *)SourceGuid)
);
WriteUnaligned64 (
(UINT64*)DestinationGuid + 1,
ReadUnaligned64 ((CONST UINT64*)SourceGuid + 1)
(UINT64 *)DestinationGuid + 1,
ReadUnaligned64 ((CONST UINT64 *)SourceGuid + 1)
);
return DestinationGuid;
}
@@ -80,12 +80,12 @@ CompareGuid (
UINT64 HighPartOfGuid1;
UINT64 HighPartOfGuid2;
LowPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1);
LowPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2);
HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1);
HighPartOfGuid2 = ReadUnaligned64 ((CONST UINT64*) Guid2 + 1);
LowPartOfGuid1 = ReadUnaligned64 ((CONST UINT64 *)Guid1);
LowPartOfGuid2 = ReadUnaligned64 ((CONST UINT64 *)Guid2);
HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64 *)Guid1 + 1);
HighPartOfGuid2 = ReadUnaligned64 ((CONST UINT64 *)Guid2 + 1);
return (BOOLEAN) (LowPartOfGuid1 == LowPartOfGuid2 && HighPartOfGuid1 == HighPartOfGuid2);
return (BOOLEAN)(LowPartOfGuid1 == LowPartOfGuid2 && HighPartOfGuid1 == HighPartOfGuid2);
}
/**
@@ -118,20 +118,22 @@ ScanGuid (
IN CONST GUID *Guid
)
{
CONST GUID *GuidPtr;
CONST GUID *GuidPtr;
ASSERT (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0);
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
ASSERT ((Length & (sizeof (*GuidPtr) - 1)) == 0);
GuidPtr = (GUID*)Buffer;
GuidPtr = (GUID *)Buffer;
Buffer = GuidPtr + Length / sizeof (*GuidPtr);
while (GuidPtr < (CONST GUID*)Buffer) {
while (GuidPtr < (CONST GUID *)Buffer) {
if (CompareGuid (GuidPtr, Guid)) {
return (VOID*)GuidPtr;
return (VOID *)GuidPtr;
}
GuidPtr++;
}
return NULL;
}
@@ -158,8 +160,8 @@ IsZeroGuid (
UINT64 LowPartOfGuid;
UINT64 HighPartOfGuid;
LowPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid);
HighPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid + 1);
LowPartOfGuid = ReadUnaligned64 ((CONST UINT64 *)Guid);
HighPartOfGuid = ReadUnaligned64 ((CONST UINT64 *)Guid + 1);
return (BOOLEAN) (LowPartOfGuid == 0 && HighPartOfGuid == 0);
return (BOOLEAN)(LowPartOfGuid == 0 && HighPartOfGuid == 0);
}

View File

@@ -35,9 +35,9 @@
VOID *
EFIAPI
InternalMemCopyMem (
OUT VOID *DestinationBuffer,
IN CONST VOID *SourceBuffer,
IN UINTN Length
OUT VOID *DestinationBuffer,
IN CONST VOID *SourceBuffer,
IN UINTN Length
);
/**
@@ -53,9 +53,9 @@ InternalMemCopyMem (
VOID *
EFIAPI
InternalMemSetMem (
OUT VOID *Buffer,
IN UINTN Length,
IN UINT8 Value
OUT VOID *Buffer,
IN UINTN Length,
IN UINT8 Value
);
/**
@@ -71,9 +71,9 @@ InternalMemSetMem (
VOID *
EFIAPI
InternalMemSetMem16 (
OUT VOID *Buffer,
IN UINTN Length,
IN UINT16 Value
OUT VOID *Buffer,
IN UINTN Length,
IN UINT16 Value
);
/**
@@ -89,9 +89,9 @@ InternalMemSetMem16 (
VOID *
EFIAPI
InternalMemSetMem32 (
OUT VOID *Buffer,
IN UINTN Length,
IN UINT32 Value
OUT VOID *Buffer,
IN UINTN Length,
IN UINT32 Value
);
/**
@@ -107,9 +107,9 @@ InternalMemSetMem32 (
VOID *
EFIAPI
InternalMemSetMem64 (
OUT VOID *Buffer,
IN UINTN Length,
IN UINT64 Value
OUT VOID *Buffer,
IN UINTN Length,
IN UINT64 Value
);
/**
@@ -124,8 +124,8 @@ InternalMemSetMem64 (
VOID *
EFIAPI
InternalMemZeroMem (
OUT VOID *Buffer,
IN UINTN Length
OUT VOID *Buffer,
IN UINTN Length
);
/**
@@ -144,9 +144,9 @@ InternalMemZeroMem (
INTN
EFIAPI
InternalMemCompareMem (
IN CONST VOID *DestinationBuffer,
IN CONST VOID *SourceBuffer,
IN UINTN Length
IN CONST VOID *DestinationBuffer,
IN CONST VOID *SourceBuffer,
IN UINTN Length
);
/**
@@ -163,9 +163,9 @@ InternalMemCompareMem (
CONST VOID *
EFIAPI
InternalMemScanMem8 (
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINT8 Value
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINT8 Value
);
/**
@@ -182,9 +182,9 @@ InternalMemScanMem8 (
CONST VOID *
EFIAPI
InternalMemScanMem16 (
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINT16 Value
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINT16 Value
);
/**
@@ -201,9 +201,9 @@ InternalMemScanMem16 (
CONST VOID *
EFIAPI
InternalMemScanMem32 (
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINT32 Value
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINT32 Value
);
/**
@@ -220,9 +220,9 @@ InternalMemScanMem32 (
CONST VOID *
EFIAPI
InternalMemScanMem64 (
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINT64 Value
IN CONST VOID *Buffer,
IN UINTN Length,
IN UINT64 Value
);
/**

View File

@@ -57,5 +57,5 @@ ScanMem16 (
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));
ASSERT ((Length & (sizeof (Value) - 1)) == 0);
return (VOID*)InternalMemScanMem16 (Buffer, Length / sizeof (Value), Value);
return (VOID *)InternalMemScanMem16 (Buffer, Length / sizeof (Value), Value);
}

View File

@@ -56,5 +56,5 @@ ScanMem32 (
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));
ASSERT ((Length & (sizeof (Value) - 1)) == 0);
return (VOID*)InternalMemScanMem32 (Buffer, Length / sizeof (Value), Value);
return (VOID *)InternalMemScanMem32 (Buffer, Length / sizeof (Value), Value);
}

View File

@@ -57,5 +57,5 @@ ScanMem64 (
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));
ASSERT ((Length & (sizeof (Value) - 1)) == 0);
return (VOID*)InternalMemScanMem64 (Buffer, Length / sizeof (Value), Value);
return (VOID *)InternalMemScanMem64 (Buffer, Length / sizeof (Value), Value);
}

View File

@@ -49,10 +49,11 @@ ScanMem8 (
if (Length == 0) {
return NULL;
}
ASSERT (Buffer != NULL);
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));
return (VOID*)InternalMemScanMem8 (Buffer, Length, Value);
return (VOID *)InternalMemScanMem8 (Buffer, Length, Value);
}
/**
@@ -90,4 +91,3 @@ ScanMemN (
return ScanMem32 (Buffer, Length, (UINT32)Value);
}
}

View File

@@ -12,9 +12,6 @@
**/
#include "MemLibInternals.h"
/**
@@ -30,9 +27,9 @@
VOID *
EFIAPI
InternalMemSetMem (
OUT VOID *Buffer,
IN UINTN Length,
IN UINT8 Value
OUT VOID *Buffer,
IN UINTN Length,
IN UINT8 Value
)
{
//
@@ -40,42 +37,44 @@ InternalMemSetMem (
// volatile to prevent the optimizer from replacing this function with
// the intrinsic memset()
//
volatile UINT8 *Pointer8;
volatile UINT32 *Pointer32;
volatile UINT64 *Pointer64;
UINT32 Value32;
UINT64 Value64;
volatile UINT8 *Pointer8;
volatile UINT32 *Pointer32;
volatile UINT64 *Pointer64;
UINT32 Value32;
UINT64 Value64;
if ((((UINTN)Buffer & 0x7) == 0) && (Length >= 8)) {
// Generate the 64bit value
Value32 = (Value << 24) | (Value << 16) | (Value << 8) | Value;
Value64 = LShiftU64 (Value32, 32) | Value32;
Pointer64 = (UINT64*)Buffer;
Pointer64 = (UINT64 *)Buffer;
while (Length >= 8) {
*(Pointer64++) = Value64;
Length -= 8;
Length -= 8;
}
// Finish with bytes if needed
Pointer8 = (UINT8*)Pointer64;
Pointer8 = (UINT8 *)Pointer64;
} else if ((((UINTN)Buffer & 0x3) == 0) && (Length >= 4)) {
// Generate the 32bit value
Value32 = (Value << 24) | (Value << 16) | (Value << 8) | Value;
Pointer32 = (UINT32*)Buffer;
Pointer32 = (UINT32 *)Buffer;
while (Length >= 4) {
*(Pointer32++) = Value32;
Length -= 4;
Length -= 4;
}
// Finish with bytes if needed
Pointer8 = (UINT8*)Pointer32;
Pointer8 = (UINT8 *)Pointer32;
} else {
Pointer8 = (UINT8*)Buffer;
Pointer8 = (UINT8 *)Buffer;
}
while (Length-- > 0) {
*(Pointer8++) = Value;
}
return Buffer;
}