mirror of https://github.com/acidanthera/audk.git
Fix the issues about the loop count for checksum 16,32,64. The input parameters are the buffer size according to Mde Lib spec.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4649 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
3e3c809fc1
commit
f9cea76b15
|
@ -122,14 +122,15 @@ CalculateSum16 (
|
||||||
{
|
{
|
||||||
UINT16 Sum;
|
UINT16 Sum;
|
||||||
UINTN Count;
|
UINTN Count;
|
||||||
|
UINTN Total;
|
||||||
|
|
||||||
ASSERT (Buffer != NULL);
|
ASSERT (Buffer != NULL);
|
||||||
ASSERT (((UINTN) Buffer & 0x1) == 0);
|
ASSERT (((UINTN) Buffer & 0x1) == 0);
|
||||||
ASSERT ((Length & 0x1) == 0);
|
ASSERT ((Length & 0x1) == 0);
|
||||||
ASSERT (Length <= (MAX_ADDRESS - ((UINTN) Buffer) + 1));
|
ASSERT (Length <= (MAX_ADDRESS - ((UINTN) Buffer) + 1));
|
||||||
|
|
||||||
|
Total = Length / sizeof (*Buffer);
|
||||||
for (Sum = 0, Count = 0; Count < Length; Count++) {
|
for (Sum = 0, Count = 0; Count < Total; Count++) {
|
||||||
Sum = (UINT16) (Sum + *(Buffer + Count));
|
Sum = (UINT16) (Sum + *(Buffer + Count));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,14 +204,15 @@ CalculateSum32 (
|
||||||
{
|
{
|
||||||
UINT32 Sum;
|
UINT32 Sum;
|
||||||
UINTN Count;
|
UINTN Count;
|
||||||
|
UINTN Total;
|
||||||
|
|
||||||
ASSERT (Buffer != NULL);
|
ASSERT (Buffer != NULL);
|
||||||
ASSERT (((UINTN) Buffer & 0x3) == 0);
|
ASSERT (((UINTN) Buffer & 0x3) == 0);
|
||||||
ASSERT ((Length & 0x3) == 0);
|
ASSERT ((Length & 0x3) == 0);
|
||||||
ASSERT (Length <= (MAX_ADDRESS - ((UINTN) Buffer) + 1));
|
ASSERT (Length <= (MAX_ADDRESS - ((UINTN) Buffer) + 1));
|
||||||
|
|
||||||
|
Total = Length / sizeof (*Buffer);
|
||||||
for (Sum = 0, Count = 0; Count < Length; Count++) {
|
for (Sum = 0, Count = 0; Count < Total; Count++) {
|
||||||
Sum = Sum + *(Buffer + Count);
|
Sum = Sum + *(Buffer + Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,13 +286,15 @@ CalculateSum64 (
|
||||||
{
|
{
|
||||||
UINT64 Sum;
|
UINT64 Sum;
|
||||||
UINTN Count;
|
UINTN Count;
|
||||||
|
UINTN Total;
|
||||||
|
|
||||||
ASSERT (Buffer != NULL);
|
ASSERT (Buffer != NULL);
|
||||||
ASSERT (((UINTN) Buffer & 0x7) == 0);
|
ASSERT (((UINTN) Buffer & 0x7) == 0);
|
||||||
ASSERT ((Length & 0x7) == 0);
|
ASSERT ((Length & 0x7) == 0);
|
||||||
ASSERT (Length <= (MAX_ADDRESS - ((UINTN) Buffer) + 1));
|
ASSERT (Length <= (MAX_ADDRESS - ((UINTN) Buffer) + 1));
|
||||||
|
|
||||||
for (Sum = 0, Count = 0; Count < Length; Count++) {
|
Total = Length / sizeof (*Buffer);
|
||||||
|
for (Sum = 0, Count = 0; Count < Total; Count++) {
|
||||||
Sum = Sum + *(Buffer + Count);
|
Sum = Sum + *(Buffer + Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue