From cc4e0485045285042ad088736ef278459b139d54 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Mon, 8 Sep 2008 01:24:16 +0000 Subject: [PATCH] Correct the wrong '?' character to '-', and add check DestinationBuffer == SourceBuffer for CompareMem functions in all BaseMemory library instances. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5831 6f19259b-4bc3-4df7-8a09-765794883524 --- MdePkg/Include/Library/BaseMemoryLib.h | 14 +++++++------- MdePkg/Include/Library/MemoryAllocationLib.h | 6 +++--- MdePkg/Library/BaseDebugLibNull/DebugLib.c | 2 +- MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c | 2 +- MdePkg/Library/BaseMemoryLib/CompareMemWrapper.c | 2 +- MdePkg/Library/BaseMemoryLib/MemLibGuid.c | 2 +- MdePkg/Library/BaseMemoryLib/ScanMem16Wrapper.c | 2 +- MdePkg/Library/BaseMemoryLib/ScanMem32Wrapper.c | 2 +- MdePkg/Library/BaseMemoryLib/ScanMem64Wrapper.c | 2 +- MdePkg/Library/BaseMemoryLib/ScanMem8Wrapper.c | 2 +- MdePkg/Library/BaseMemoryLib/SetMemWrapper.c | 2 +- MdePkg/Library/BaseMemoryLib/ZeroMemWrapper.c | 2 +- .../Library/BaseMemoryLibMmx/CompareMemWrapper.c | 2 +- MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c | 2 +- MdePkg/Library/BaseMemoryLibMmx/ScanMem16Wrapper.c | 2 +- MdePkg/Library/BaseMemoryLibMmx/ScanMem32Wrapper.c | 2 +- MdePkg/Library/BaseMemoryLibMmx/ScanMem64Wrapper.c | 2 +- MdePkg/Library/BaseMemoryLibMmx/ScanMem8Wrapper.c | 2 +- MdePkg/Library/BaseMemoryLibMmx/SetMemWrapper.c | 2 +- MdePkg/Library/BaseMemoryLibMmx/ZeroMemWrapper.c | 2 +- .../BaseMemoryLibOptDxe/CompareMemWrapper.c | 2 +- MdePkg/Library/BaseMemoryLibOptDxe/MemLibGuid.c | 2 +- .../Library/BaseMemoryLibOptDxe/ScanMem16Wrapper.c | 2 +- .../Library/BaseMemoryLibOptDxe/ScanMem32Wrapper.c | 2 +- .../Library/BaseMemoryLibOptDxe/ScanMem64Wrapper.c | 2 +- .../Library/BaseMemoryLibOptDxe/ScanMem8Wrapper.c | 2 +- MdePkg/Library/BaseMemoryLibOptDxe/SetMemWrapper.c | 2 +- .../Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c | 2 +- .../BaseMemoryLibOptPei/CompareMemWrapper.c | 2 +- MdePkg/Library/BaseMemoryLibOptPei/MemLibGuid.c | 2 +- .../Library/BaseMemoryLibOptPei/ScanMem16Wrapper.c | 2 +- .../Library/BaseMemoryLibOptPei/ScanMem32Wrapper.c | 2 +- .../Library/BaseMemoryLibOptPei/ScanMem64Wrapper.c | 2 +- .../Library/BaseMemoryLibOptPei/ScanMem8Wrapper.c | 2 +- MdePkg/Library/BaseMemoryLibOptPei/SetMemWrapper.c | 2 +- .../Library/BaseMemoryLibOptPei/ZeroMemWrapper.c | 2 +- .../BaseMemoryLibRepStr/CompareMemWrapper.c | 2 +- MdePkg/Library/BaseMemoryLibRepStr/MemLibGuid.c | 2 +- .../Library/BaseMemoryLibRepStr/ScanMem16Wrapper.c | 2 +- .../Library/BaseMemoryLibRepStr/ScanMem32Wrapper.c | 2 +- .../Library/BaseMemoryLibRepStr/ScanMem64Wrapper.c | 2 +- .../Library/BaseMemoryLibRepStr/ScanMem8Wrapper.c | 2 +- MdePkg/Library/BaseMemoryLibRepStr/SetMemWrapper.c | 2 +- .../Library/BaseMemoryLibRepStr/ZeroMemWrapper.c | 2 +- .../Library/BaseMemoryLibSse2/CompareMemWrapper.c | 2 +- MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c | 2 +- .../Library/BaseMemoryLibSse2/ScanMem16Wrapper.c | 2 +- .../Library/BaseMemoryLibSse2/ScanMem32Wrapper.c | 2 +- .../Library/BaseMemoryLibSse2/ScanMem64Wrapper.c | 2 +- MdePkg/Library/BaseMemoryLibSse2/ScanMem8Wrapper.c | 2 +- MdePkg/Library/BaseMemoryLibSse2/SetMemWrapper.c | 2 +- MdePkg/Library/BaseMemoryLibSse2/ZeroMemWrapper.c | 2 +- MdePkg/Library/DxeMemoryLib/CompareMemWrapper.c | 2 +- MdePkg/Library/DxeMemoryLib/MemLib.c | 4 ++-- MdePkg/Library/DxeMemoryLib/MemLibGuid.c | 2 +- MdePkg/Library/DxeMemoryLib/ScanMem16Wrapper.c | 2 +- MdePkg/Library/DxeMemoryLib/ScanMem32Wrapper.c | 2 +- MdePkg/Library/DxeMemoryLib/ScanMem64Wrapper.c | 2 +- MdePkg/Library/DxeMemoryLib/ScanMem8Wrapper.c | 2 +- MdePkg/Library/DxeMemoryLib/SetMemWrapper.c | 2 +- MdePkg/Library/DxeMemoryLib/ZeroMemWrapper.c | 2 +- MdePkg/Library/PeiMemoryLib/CompareMemWrapper.c | 2 +- MdePkg/Library/PeiMemoryLib/MemLib.c | 4 ++-- MdePkg/Library/PeiMemoryLib/MemLibGuid.c | 2 +- MdePkg/Library/PeiMemoryLib/ScanMem16Wrapper.c | 2 +- MdePkg/Library/PeiMemoryLib/ScanMem32Wrapper.c | 2 +- MdePkg/Library/PeiMemoryLib/ScanMem64Wrapper.c | 2 +- MdePkg/Library/PeiMemoryLib/ScanMem8Wrapper.c | 2 +- MdePkg/Library/PeiMemoryLib/SetMemWrapper.c | 2 +- MdePkg/Library/PeiMemoryLib/ZeroMemWrapper.c | 2 +- MdePkg/Library/UefiDebugLibConOut/DebugLib.c | 2 +- MdePkg/Library/UefiDebugLibStdErr/DebugLib.c | 2 +- 72 files changed, 82 insertions(+), 82 deletions(-) diff --git a/MdePkg/Include/Library/BaseMemoryLib.h b/MdePkg/Include/Library/BaseMemoryLib.h index b680f2b550..4eb0bf257a 100644 --- a/MdePkg/Include/Library/BaseMemoryLib.h +++ b/MdePkg/Include/Library/BaseMemoryLib.h @@ -43,7 +43,7 @@ CopyMem ( Fills a target buffer with a byte value, and returns the target buffer. This function fills Length bytes of Buffer with Value, and returns Buffer. - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Memory to set. @param Length Number of bytes to set. @@ -146,7 +146,7 @@ SetMem64 ( This function fills Length bytes of Buffer with zeros, and returns Buffer. If Length > 0 and Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to fill with zeros. @param Length Number of bytes in Buffer to fill with zeros. @@ -199,7 +199,7 @@ CompareMem ( then a pointer to the matching byte in the target buffer is returned. If no match is found, then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. @@ -227,7 +227,7 @@ ScanMem8 ( If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). If Length is not aligned on a 16-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. @@ -255,7 +255,7 @@ ScanMem16 ( If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 32-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. @@ -283,7 +283,7 @@ ScanMem32 ( If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 64-bit boundary, then ASSERT(). If Length is not aligned on a 64-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. @@ -355,7 +355,7 @@ CompareGuid ( If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 128-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Include/Library/MemoryAllocationLib.h b/MdePkg/Include/Library/MemoryAllocationLib.h index 935ff3b96b..76a9f8a564 100644 --- a/MdePkg/Include/Library/MemoryAllocationLib.h +++ b/MdePkg/Include/Library/MemoryAllocationLib.h @@ -304,7 +304,7 @@ AllocateReservedZeroPool ( allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. If Buffer is NULL, then ASSERT(). - If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param AllocationSize The number of bytes to allocate and zero. @param Buffer The buffer to copy to the allocated buffer. @@ -327,7 +327,7 @@ AllocateCopyPool ( allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. If Buffer is NULL, then ASSERT(). - If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param AllocationSize The number of bytes to allocate and zero. @param Buffer The buffer to copy to the allocated buffer. @@ -350,7 +350,7 @@ AllocateRuntimeCopyPool ( allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. If Buffer is NULL, then ASSERT(). - If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param AllocationSize The number of bytes to allocate and zero. @param Buffer The buffer to copy to the allocated buffer. diff --git a/MdePkg/Library/BaseDebugLibNull/DebugLib.c b/MdePkg/Library/BaseDebugLibNull/DebugLib.c index 9259ab6432..c9916165a0 100644 --- a/MdePkg/Library/BaseDebugLibNull/DebugLib.c +++ b/MdePkg/Library/BaseDebugLibNull/DebugLib.c @@ -80,7 +80,7 @@ DebugAssert ( If Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue. @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. diff --git a/MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c b/MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c index 266b25cdcf..4a832b87f1 100644 --- a/MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c +++ b/MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c @@ -140,7 +140,7 @@ DebugAssert ( If Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to be filled with PcdDebugClearMemoryValue. @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. diff --git a/MdePkg/Library/BaseMemoryLib/CompareMemWrapper.c b/MdePkg/Library/BaseMemoryLib/CompareMemWrapper.c index 031b7fcec6..61b01096b2 100644 --- a/MdePkg/Library/BaseMemoryLib/CompareMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLib/CompareMemWrapper.c @@ -58,7 +58,7 @@ CompareMem ( IN UINTN Length ) { - if (0 == Length) { + if (Length == 0 || DestinationBuffer == SourceBuffer) { return 0; } ASSERT (DestinationBuffer != NULL); diff --git a/MdePkg/Library/BaseMemoryLib/MemLibGuid.c b/MdePkg/Library/BaseMemoryLib/MemLibGuid.c index 9825b9f792..cbc546fa80 100644 --- a/MdePkg/Library/BaseMemoryLib/MemLibGuid.c +++ b/MdePkg/Library/BaseMemoryLib/MemLibGuid.c @@ -106,7 +106,7 @@ CompareGuid ( If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 128-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLib/ScanMem16Wrapper.c b/MdePkg/Library/BaseMemoryLib/ScanMem16Wrapper.c index e45202d950..c9eb0c49e0 100644 --- a/MdePkg/Library/BaseMemoryLib/ScanMem16Wrapper.c +++ b/MdePkg/Library/BaseMemoryLib/ScanMem16Wrapper.c @@ -39,7 +39,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). If Length is not aligned on a 16-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLib/ScanMem32Wrapper.c b/MdePkg/Library/BaseMemoryLib/ScanMem32Wrapper.c index a4a16372e6..797879c0b1 100644 --- a/MdePkg/Library/BaseMemoryLib/ScanMem32Wrapper.c +++ b/MdePkg/Library/BaseMemoryLib/ScanMem32Wrapper.c @@ -39,7 +39,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 32-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLib/ScanMem64Wrapper.c b/MdePkg/Library/BaseMemoryLib/ScanMem64Wrapper.c index b182243648..076bb34f1b 100644 --- a/MdePkg/Library/BaseMemoryLib/ScanMem64Wrapper.c +++ b/MdePkg/Library/BaseMemoryLib/ScanMem64Wrapper.c @@ -39,7 +39,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 64-bit boundary, then ASSERT(). If Length is not aligned on a 64-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLib/ScanMem8Wrapper.c b/MdePkg/Library/BaseMemoryLib/ScanMem8Wrapper.c index 8164e2a181..dc5f3e960f 100644 --- a/MdePkg/Library/BaseMemoryLib/ScanMem8Wrapper.c +++ b/MdePkg/Library/BaseMemoryLib/ScanMem8Wrapper.c @@ -37,7 +37,7 @@ then a pointer to the matching byte in the target buffer is returned. If no match is found, then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLib/SetMemWrapper.c b/MdePkg/Library/BaseMemoryLib/SetMemWrapper.c index 0e3428cd7a..63e7f22085 100644 --- a/MdePkg/Library/BaseMemoryLib/SetMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLib/SetMemWrapper.c @@ -32,7 +32,7 @@ Fills a target buffer with a byte value, and returns the target buffer. This function fills Length bytes of Buffer with Value, and returns Buffer. - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Memory to set. @param Length Number of bytes to set. diff --git a/MdePkg/Library/BaseMemoryLib/ZeroMemWrapper.c b/MdePkg/Library/BaseMemoryLib/ZeroMemWrapper.c index 87565f1c9a..e24b106e76 100644 --- a/MdePkg/Library/BaseMemoryLib/ZeroMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLib/ZeroMemWrapper.c @@ -33,7 +33,7 @@ This function fills Length bytes of Buffer with zeros, and returns Buffer. If Length > 0 and Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to fill with zeros. @param Length Number of bytes in Buffer to fill with zeros. diff --git a/MdePkg/Library/BaseMemoryLibMmx/CompareMemWrapper.c b/MdePkg/Library/BaseMemoryLibMmx/CompareMemWrapper.c index 1886da59df..3be161278c 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/CompareMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibMmx/CompareMemWrapper.c @@ -55,7 +55,7 @@ CompareMem ( IN UINTN Length ) { - if (0 == Length) { + if (Length == 0 || DestinationBuffer == SourceBuffer) { return 0; } ASSERT (DestinationBuffer != NULL); diff --git a/MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c b/MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c index 15e5294d9f..0d46ab92f5 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c +++ b/MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c @@ -104,7 +104,7 @@ CompareGuid ( If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 128-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibMmx/ScanMem16Wrapper.c b/MdePkg/Library/BaseMemoryLibMmx/ScanMem16Wrapper.c index d746c8fc60..083400743f 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/ScanMem16Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibMmx/ScanMem16Wrapper.c @@ -36,7 +36,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). If Length is not aligned on a 16-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibMmx/ScanMem32Wrapper.c b/MdePkg/Library/BaseMemoryLibMmx/ScanMem32Wrapper.c index d6681deecf..25aa05b0a0 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/ScanMem32Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibMmx/ScanMem32Wrapper.c @@ -36,7 +36,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 32-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibMmx/ScanMem64Wrapper.c b/MdePkg/Library/BaseMemoryLibMmx/ScanMem64Wrapper.c index 6d8d8c9d95..da7834c68c 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/ScanMem64Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibMmx/ScanMem64Wrapper.c @@ -36,7 +36,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 64-bit boundary, then ASSERT(). If Length is not aligned on a 64-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibMmx/ScanMem8Wrapper.c b/MdePkg/Library/BaseMemoryLibMmx/ScanMem8Wrapper.c index ce4eed606a..1396fa1e49 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/ScanMem8Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibMmx/ScanMem8Wrapper.c @@ -34,7 +34,7 @@ then a pointer to the matching byte in the target buffer is returned. If no match is found, then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibMmx/SetMemWrapper.c b/MdePkg/Library/BaseMemoryLibMmx/SetMemWrapper.c index 1c1a289b53..77e3b326fd 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/SetMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibMmx/SetMemWrapper.c @@ -29,7 +29,7 @@ Fills a target buffer with a byte value, and returns the target buffer. This function fills Length bytes of Buffer with Value, and returns Buffer. - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Memory to set. @param Length Number of bytes to set. diff --git a/MdePkg/Library/BaseMemoryLibMmx/ZeroMemWrapper.c b/MdePkg/Library/BaseMemoryLibMmx/ZeroMemWrapper.c index 00205b1908..dcebcf5ee6 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/ZeroMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibMmx/ZeroMemWrapper.c @@ -30,7 +30,7 @@ This function fills Length bytes of Buffer with zeros, and returns Buffer. If Length > 0 and Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to fill with zeros. @param Length Number of bytes in Buffer to fill with zeros. diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/CompareMemWrapper.c b/MdePkg/Library/BaseMemoryLibOptDxe/CompareMemWrapper.c index 031b7fcec6..61b01096b2 100644 --- a/MdePkg/Library/BaseMemoryLibOptDxe/CompareMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibOptDxe/CompareMemWrapper.c @@ -58,7 +58,7 @@ CompareMem ( IN UINTN Length ) { - if (0 == Length) { + if (Length == 0 || DestinationBuffer == SourceBuffer) { return 0; } ASSERT (DestinationBuffer != NULL); diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/MemLibGuid.c b/MdePkg/Library/BaseMemoryLibOptDxe/MemLibGuid.c index 9825b9f792..cbc546fa80 100644 --- a/MdePkg/Library/BaseMemoryLibOptDxe/MemLibGuid.c +++ b/MdePkg/Library/BaseMemoryLibOptDxe/MemLibGuid.c @@ -106,7 +106,7 @@ CompareGuid ( If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 128-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/ScanMem16Wrapper.c b/MdePkg/Library/BaseMemoryLibOptDxe/ScanMem16Wrapper.c index 54abe1c356..82a3528228 100644 --- a/MdePkg/Library/BaseMemoryLibOptDxe/ScanMem16Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibOptDxe/ScanMem16Wrapper.c @@ -39,7 +39,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). If Length is not aligned on a 16-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/ScanMem32Wrapper.c b/MdePkg/Library/BaseMemoryLibOptDxe/ScanMem32Wrapper.c index b91a38b973..de744d54e7 100644 --- a/MdePkg/Library/BaseMemoryLibOptDxe/ScanMem32Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibOptDxe/ScanMem32Wrapper.c @@ -39,7 +39,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 32-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/ScanMem64Wrapper.c b/MdePkg/Library/BaseMemoryLibOptDxe/ScanMem64Wrapper.c index f47d700c9b..6e7c34af60 100644 --- a/MdePkg/Library/BaseMemoryLibOptDxe/ScanMem64Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibOptDxe/ScanMem64Wrapper.c @@ -39,7 +39,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 64-bit boundary, then ASSERT(). If Length is not aligned on a 64-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/ScanMem8Wrapper.c b/MdePkg/Library/BaseMemoryLibOptDxe/ScanMem8Wrapper.c index 8164e2a181..dc5f3e960f 100644 --- a/MdePkg/Library/BaseMemoryLibOptDxe/ScanMem8Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibOptDxe/ScanMem8Wrapper.c @@ -37,7 +37,7 @@ then a pointer to the matching byte in the target buffer is returned. If no match is found, then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/SetMemWrapper.c b/MdePkg/Library/BaseMemoryLibOptDxe/SetMemWrapper.c index 0e3428cd7a..63e7f22085 100644 --- a/MdePkg/Library/BaseMemoryLibOptDxe/SetMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibOptDxe/SetMemWrapper.c @@ -32,7 +32,7 @@ Fills a target buffer with a byte value, and returns the target buffer. This function fills Length bytes of Buffer with Value, and returns Buffer. - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Memory to set. @param Length Number of bytes to set. diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c b/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c index e27851b077..9f90ba98ee 100644 --- a/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c @@ -33,7 +33,7 @@ This function fills Length bytes of Buffer with zeros, and returns Buffer. If Length > 0 and Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to fill with zeros. @param Length Number of bytes in Buffer to fill with zeros. diff --git a/MdePkg/Library/BaseMemoryLibOptPei/CompareMemWrapper.c b/MdePkg/Library/BaseMemoryLibOptPei/CompareMemWrapper.c index 031b7fcec6..61b01096b2 100644 --- a/MdePkg/Library/BaseMemoryLibOptPei/CompareMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibOptPei/CompareMemWrapper.c @@ -58,7 +58,7 @@ CompareMem ( IN UINTN Length ) { - if (0 == Length) { + if (Length == 0 || DestinationBuffer == SourceBuffer) { return 0; } ASSERT (DestinationBuffer != NULL); diff --git a/MdePkg/Library/BaseMemoryLibOptPei/MemLibGuid.c b/MdePkg/Library/BaseMemoryLibOptPei/MemLibGuid.c index cbbad2cb5d..9386e751ce 100644 --- a/MdePkg/Library/BaseMemoryLibOptPei/MemLibGuid.c +++ b/MdePkg/Library/BaseMemoryLibOptPei/MemLibGuid.c @@ -106,7 +106,7 @@ CompareGuid ( If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 128-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibOptPei/ScanMem16Wrapper.c b/MdePkg/Library/BaseMemoryLibOptPei/ScanMem16Wrapper.c index 54abe1c356..82a3528228 100644 --- a/MdePkg/Library/BaseMemoryLibOptPei/ScanMem16Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibOptPei/ScanMem16Wrapper.c @@ -39,7 +39,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). If Length is not aligned on a 16-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibOptPei/ScanMem32Wrapper.c b/MdePkg/Library/BaseMemoryLibOptPei/ScanMem32Wrapper.c index b91a38b973..de744d54e7 100644 --- a/MdePkg/Library/BaseMemoryLibOptPei/ScanMem32Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibOptPei/ScanMem32Wrapper.c @@ -39,7 +39,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 32-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibOptPei/ScanMem64Wrapper.c b/MdePkg/Library/BaseMemoryLibOptPei/ScanMem64Wrapper.c index f47d700c9b..6e7c34af60 100644 --- a/MdePkg/Library/BaseMemoryLibOptPei/ScanMem64Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibOptPei/ScanMem64Wrapper.c @@ -39,7 +39,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 64-bit boundary, then ASSERT(). If Length is not aligned on a 64-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibOptPei/ScanMem8Wrapper.c b/MdePkg/Library/BaseMemoryLibOptPei/ScanMem8Wrapper.c index 8164e2a181..dc5f3e960f 100644 --- a/MdePkg/Library/BaseMemoryLibOptPei/ScanMem8Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibOptPei/ScanMem8Wrapper.c @@ -37,7 +37,7 @@ then a pointer to the matching byte in the target buffer is returned. If no match is found, then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibOptPei/SetMemWrapper.c b/MdePkg/Library/BaseMemoryLibOptPei/SetMemWrapper.c index 0e3428cd7a..63e7f22085 100644 --- a/MdePkg/Library/BaseMemoryLibOptPei/SetMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibOptPei/SetMemWrapper.c @@ -32,7 +32,7 @@ Fills a target buffer with a byte value, and returns the target buffer. This function fills Length bytes of Buffer with Value, and returns Buffer. - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Memory to set. @param Length Number of bytes to set. diff --git a/MdePkg/Library/BaseMemoryLibOptPei/ZeroMemWrapper.c b/MdePkg/Library/BaseMemoryLibOptPei/ZeroMemWrapper.c index e27851b077..9f90ba98ee 100644 --- a/MdePkg/Library/BaseMemoryLibOptPei/ZeroMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibOptPei/ZeroMemWrapper.c @@ -33,7 +33,7 @@ This function fills Length bytes of Buffer with zeros, and returns Buffer. If Length > 0 and Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to fill with zeros. @param Length Number of bytes in Buffer to fill with zeros. diff --git a/MdePkg/Library/BaseMemoryLibRepStr/CompareMemWrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/CompareMemWrapper.c index 031b7fcec6..61b01096b2 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/CompareMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/CompareMemWrapper.c @@ -58,7 +58,7 @@ CompareMem ( IN UINTN Length ) { - if (0 == Length) { + if (Length == 0 || DestinationBuffer == SourceBuffer) { return 0; } ASSERT (DestinationBuffer != NULL); diff --git a/MdePkg/Library/BaseMemoryLibRepStr/MemLibGuid.c b/MdePkg/Library/BaseMemoryLibRepStr/MemLibGuid.c index cbbad2cb5d..9386e751ce 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/MemLibGuid.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/MemLibGuid.c @@ -106,7 +106,7 @@ CompareGuid ( If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 128-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibRepStr/ScanMem16Wrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/ScanMem16Wrapper.c index 54abe1c356..82a3528228 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/ScanMem16Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/ScanMem16Wrapper.c @@ -39,7 +39,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). If Length is not aligned on a 16-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibRepStr/ScanMem32Wrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/ScanMem32Wrapper.c index b91a38b973..de744d54e7 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/ScanMem32Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/ScanMem32Wrapper.c @@ -39,7 +39,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 32-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibRepStr/ScanMem64Wrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/ScanMem64Wrapper.c index f47d700c9b..6e7c34af60 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/ScanMem64Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/ScanMem64Wrapper.c @@ -39,7 +39,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 64-bit boundary, then ASSERT(). If Length is not aligned on a 64-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibRepStr/ScanMem8Wrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/ScanMem8Wrapper.c index 8164e2a181..dc5f3e960f 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/ScanMem8Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/ScanMem8Wrapper.c @@ -37,7 +37,7 @@ then a pointer to the matching byte in the target buffer is returned. If no match is found, then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibRepStr/SetMemWrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/SetMemWrapper.c index 0e3428cd7a..63e7f22085 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/SetMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/SetMemWrapper.c @@ -32,7 +32,7 @@ Fills a target buffer with a byte value, and returns the target buffer. This function fills Length bytes of Buffer with Value, and returns Buffer. - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Memory to set. @param Length Number of bytes to set. diff --git a/MdePkg/Library/BaseMemoryLibRepStr/ZeroMemWrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/ZeroMemWrapper.c index e27851b077..9f90ba98ee 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/ZeroMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/ZeroMemWrapper.c @@ -33,7 +33,7 @@ This function fills Length bytes of Buffer with zeros, and returns Buffer. If Length > 0 and Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to fill with zeros. @param Length Number of bytes in Buffer to fill with zeros. diff --git a/MdePkg/Library/BaseMemoryLibSse2/CompareMemWrapper.c b/MdePkg/Library/BaseMemoryLibSse2/CompareMemWrapper.c index 031b7fcec6..61b01096b2 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/CompareMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibSse2/CompareMemWrapper.c @@ -58,7 +58,7 @@ CompareMem ( IN UINTN Length ) { - if (0 == Length) { + if (Length == 0 || DestinationBuffer == SourceBuffer) { return 0; } ASSERT (DestinationBuffer != NULL); diff --git a/MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c b/MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c index cf364c1d1f..dcf8d78d7e 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c +++ b/MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c @@ -105,7 +105,7 @@ CompareGuid ( If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 128-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibSse2/ScanMem16Wrapper.c b/MdePkg/Library/BaseMemoryLibSse2/ScanMem16Wrapper.c index 54abe1c356..82a3528228 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/ScanMem16Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibSse2/ScanMem16Wrapper.c @@ -39,7 +39,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). If Length is not aligned on a 16-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibSse2/ScanMem32Wrapper.c b/MdePkg/Library/BaseMemoryLibSse2/ScanMem32Wrapper.c index b91a38b973..de744d54e7 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/ScanMem32Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibSse2/ScanMem32Wrapper.c @@ -39,7 +39,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 32-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibSse2/ScanMem64Wrapper.c b/MdePkg/Library/BaseMemoryLibSse2/ScanMem64Wrapper.c index f47d700c9b..6e7c34af60 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/ScanMem64Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibSse2/ScanMem64Wrapper.c @@ -39,7 +39,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 64-bit boundary, then ASSERT(). If Length is not aligned on a 64-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibSse2/ScanMem8Wrapper.c b/MdePkg/Library/BaseMemoryLibSse2/ScanMem8Wrapper.c index 8164e2a181..dc5f3e960f 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/ScanMem8Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibSse2/ScanMem8Wrapper.c @@ -37,7 +37,7 @@ then a pointer to the matching byte in the target buffer is returned. If no match is found, then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/BaseMemoryLibSse2/SetMemWrapper.c b/MdePkg/Library/BaseMemoryLibSse2/SetMemWrapper.c index 0e3428cd7a..63e7f22085 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/SetMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibSse2/SetMemWrapper.c @@ -32,7 +32,7 @@ Fills a target buffer with a byte value, and returns the target buffer. This function fills Length bytes of Buffer with Value, and returns Buffer. - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Memory to set. @param Length Number of bytes to set. diff --git a/MdePkg/Library/BaseMemoryLibSse2/ZeroMemWrapper.c b/MdePkg/Library/BaseMemoryLibSse2/ZeroMemWrapper.c index e27851b077..9f90ba98ee 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/ZeroMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibSse2/ZeroMemWrapper.c @@ -33,7 +33,7 @@ This function fills Length bytes of Buffer with zeros, and returns Buffer. If Length > 0 and Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to fill with zeros. @param Length Number of bytes in Buffer to fill with zeros. diff --git a/MdePkg/Library/DxeMemoryLib/CompareMemWrapper.c b/MdePkg/Library/DxeMemoryLib/CompareMemWrapper.c index ae7accc86f..c62cfe0354 100644 --- a/MdePkg/Library/DxeMemoryLib/CompareMemWrapper.c +++ b/MdePkg/Library/DxeMemoryLib/CompareMemWrapper.c @@ -53,7 +53,7 @@ CompareMem ( IN UINTN Length ) { - if (Length == 0) { + if (Length == 0 || DestinationBuffer == SourceBuffer) { return 0; } ASSERT (DestinationBuffer != NULL); diff --git a/MdePkg/Library/DxeMemoryLib/MemLib.c b/MdePkg/Library/DxeMemoryLib/MemLib.c index faa32f5390..5489fd0f08 100644 --- a/MdePkg/Library/DxeMemoryLib/MemLib.c +++ b/MdePkg/Library/DxeMemoryLib/MemLib.c @@ -1,7 +1,7 @@ /** @file - Base Memory Library. + Base Memory Library functions implementation bases on Uefi Boot Service. - Copyright (c) 2006, Intel Corporation
+ Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at diff --git a/MdePkg/Library/DxeMemoryLib/MemLibGuid.c b/MdePkg/Library/DxeMemoryLib/MemLibGuid.c index 9767710e8c..b7625d6081 100644 --- a/MdePkg/Library/DxeMemoryLib/MemLibGuid.c +++ b/MdePkg/Library/DxeMemoryLib/MemLibGuid.c @@ -102,7 +102,7 @@ CompareGuid ( If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 128-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/DxeMemoryLib/ScanMem16Wrapper.c b/MdePkg/Library/DxeMemoryLib/ScanMem16Wrapper.c index c66f8a3444..8e0b812749 100644 --- a/MdePkg/Library/DxeMemoryLib/ScanMem16Wrapper.c +++ b/MdePkg/Library/DxeMemoryLib/ScanMem16Wrapper.c @@ -35,7 +35,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). If Length is not aligned on a 16-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/DxeMemoryLib/ScanMem32Wrapper.c b/MdePkg/Library/DxeMemoryLib/ScanMem32Wrapper.c index 896a893095..00cdc60cee 100644 --- a/MdePkg/Library/DxeMemoryLib/ScanMem32Wrapper.c +++ b/MdePkg/Library/DxeMemoryLib/ScanMem32Wrapper.c @@ -34,7 +34,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 32-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/DxeMemoryLib/ScanMem64Wrapper.c b/MdePkg/Library/DxeMemoryLib/ScanMem64Wrapper.c index aea67e1fdc..b80921b2a6 100644 --- a/MdePkg/Library/DxeMemoryLib/ScanMem64Wrapper.c +++ b/MdePkg/Library/DxeMemoryLib/ScanMem64Wrapper.c @@ -34,7 +34,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 64-bit boundary, then ASSERT(). If Length is not aligned on a 64-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/DxeMemoryLib/ScanMem8Wrapper.c b/MdePkg/Library/DxeMemoryLib/ScanMem8Wrapper.c index aaaa75f70c..d9cd42d9db 100644 --- a/MdePkg/Library/DxeMemoryLib/ScanMem8Wrapper.c +++ b/MdePkg/Library/DxeMemoryLib/ScanMem8Wrapper.c @@ -33,7 +33,7 @@ then a pointer to the matching byte in the target buffer is returned. If no match is found, then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/DxeMemoryLib/SetMemWrapper.c b/MdePkg/Library/DxeMemoryLib/SetMemWrapper.c index cf07c74c99..ab7efa90cf 100644 --- a/MdePkg/Library/DxeMemoryLib/SetMemWrapper.c +++ b/MdePkg/Library/DxeMemoryLib/SetMemWrapper.c @@ -27,7 +27,7 @@ Fills a target buffer with a byte value, and returns the target buffer. This function fills Length bytes of Buffer with Value, and returns Buffer. - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Memory to set. @param Length Number of bytes to set. diff --git a/MdePkg/Library/DxeMemoryLib/ZeroMemWrapper.c b/MdePkg/Library/DxeMemoryLib/ZeroMemWrapper.c index c020c2226c..387700329c 100644 --- a/MdePkg/Library/DxeMemoryLib/ZeroMemWrapper.c +++ b/MdePkg/Library/DxeMemoryLib/ZeroMemWrapper.c @@ -29,7 +29,7 @@ This function fills Length bytes of Buffer with zeros, and returns Buffer. If Length > 0 and Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to fill with zeros. @param Length Number of bytes in Buffer to fill with zeros. diff --git a/MdePkg/Library/PeiMemoryLib/CompareMemWrapper.c b/MdePkg/Library/PeiMemoryLib/CompareMemWrapper.c index 48948617d1..9d85c57fa3 100644 --- a/MdePkg/Library/PeiMemoryLib/CompareMemWrapper.c +++ b/MdePkg/Library/PeiMemoryLib/CompareMemWrapper.c @@ -53,7 +53,7 @@ CompareMem ( IN UINTN Length ) { - if (Length == 0) { + if (Length == 0 || DestinationBuffer == SourceBuffer) { return 0; } ASSERT (DestinationBuffer != NULL); diff --git a/MdePkg/Library/PeiMemoryLib/MemLib.c b/MdePkg/Library/PeiMemoryLib/MemLib.c index 82e50825c0..cbd88c1c6d 100644 --- a/MdePkg/Library/PeiMemoryLib/MemLib.c +++ b/MdePkg/Library/PeiMemoryLib/MemLib.c @@ -1,7 +1,7 @@ /** @file - Base Memory Library. + Base Memory Library functions implementation bases on PeiServcie. - Copyright (c) 2006, Intel Corporation
+ Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at diff --git a/MdePkg/Library/PeiMemoryLib/MemLibGuid.c b/MdePkg/Library/PeiMemoryLib/MemLibGuid.c index f7f1b16beb..db7f3588fc 100644 --- a/MdePkg/Library/PeiMemoryLib/MemLibGuid.c +++ b/MdePkg/Library/PeiMemoryLib/MemLibGuid.c @@ -102,7 +102,7 @@ CompareGuid ( If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 128-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/PeiMemoryLib/ScanMem16Wrapper.c b/MdePkg/Library/PeiMemoryLib/ScanMem16Wrapper.c index 66a2cd40d9..94541f4f50 100644 --- a/MdePkg/Library/PeiMemoryLib/ScanMem16Wrapper.c +++ b/MdePkg/Library/PeiMemoryLib/ScanMem16Wrapper.c @@ -34,7 +34,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). If Length is not aligned on a 16-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/PeiMemoryLib/ScanMem32Wrapper.c b/MdePkg/Library/PeiMemoryLib/ScanMem32Wrapper.c index f3518b7d87..e80d730548 100644 --- a/MdePkg/Library/PeiMemoryLib/ScanMem32Wrapper.c +++ b/MdePkg/Library/PeiMemoryLib/ScanMem32Wrapper.c @@ -34,7 +34,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 32-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/PeiMemoryLib/ScanMem64Wrapper.c b/MdePkg/Library/PeiMemoryLib/ScanMem64Wrapper.c index 1bd7fe3fe5..36adb50052 100644 --- a/MdePkg/Library/PeiMemoryLib/ScanMem64Wrapper.c +++ b/MdePkg/Library/PeiMemoryLib/ScanMem64Wrapper.c @@ -34,7 +34,7 @@ If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 64-bit boundary, then ASSERT(). If Length is not aligned on a 64-bit boundary, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/PeiMemoryLib/ScanMem8Wrapper.c b/MdePkg/Library/PeiMemoryLib/ScanMem8Wrapper.c index d12af184f7..b30cd320f2 100644 --- a/MdePkg/Library/PeiMemoryLib/ScanMem8Wrapper.c +++ b/MdePkg/Library/PeiMemoryLib/ScanMem8Wrapper.c @@ -32,7 +32,7 @@ then a pointer to the matching byte in the target buffer is returned. If no match is found, then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @param Length Number of bytes in Buffer to scan. diff --git a/MdePkg/Library/PeiMemoryLib/SetMemWrapper.c b/MdePkg/Library/PeiMemoryLib/SetMemWrapper.c index ea0a3e0106..f8c611285f 100644 --- a/MdePkg/Library/PeiMemoryLib/SetMemWrapper.c +++ b/MdePkg/Library/PeiMemoryLib/SetMemWrapper.c @@ -27,7 +27,7 @@ Fills a target buffer with a byte value, and returns the target buffer. This function fills Length bytes of Buffer with Value, and returns Buffer. - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Memory to set. @param Length Number of bytes to set. diff --git a/MdePkg/Library/PeiMemoryLib/ZeroMemWrapper.c b/MdePkg/Library/PeiMemoryLib/ZeroMemWrapper.c index 33b9d07ecf..337b45346e 100644 --- a/MdePkg/Library/PeiMemoryLib/ZeroMemWrapper.c +++ b/MdePkg/Library/PeiMemoryLib/ZeroMemWrapper.c @@ -28,7 +28,7 @@ This function fills Length bytes of Buffer with zeros, and returns Buffer. If Length > 0 and Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to fill with zeros. @param Length Number of bytes in Buffer to fill with zeros. diff --git a/MdePkg/Library/UefiDebugLibConOut/DebugLib.c b/MdePkg/Library/UefiDebugLibConOut/DebugLib.c index 393c698690..63a72e8ab1 100644 --- a/MdePkg/Library/UefiDebugLibConOut/DebugLib.c +++ b/MdePkg/Library/UefiDebugLibConOut/DebugLib.c @@ -154,7 +154,7 @@ DebugAssert ( If Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to be filled with PcdDebugClearMemoryValue. @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. diff --git a/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c b/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c index a7d4d2829b..217f164de5 100644 --- a/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c +++ b/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c @@ -152,7 +152,7 @@ DebugAssert ( If Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue. @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. -- 2.39.2