OvmfPkg/AcpiPlatformDxe: drop double right shift in ADD/WRITE POINTER cmds

The Count parameter of RShiftU64() must be strictly smaller than 64.
ProcessCmdAddPointer() and ProcessCmdWritePointer() currently ensure this
by "cleverly" breaking the last bit of a potentially 8-byte right shift
out to a separate operation.

Instead, exclude the Count==64 case explicitly (in which case the
preexistent outer RShiftU64() would return 0), and keep only the inner
RShiftU64(), with the direct Count however.

This is not a functional change, just style improvement.

Cc: Jordan Justen <jordan.l.justen@intel.com>
Suggested-by: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
This commit is contained in:
Laszlo Ersek 2017-02-21 13:30:48 +01:00
parent b9d56d0b93
commit a3be3b6597
1 changed files with 4 additions and 4 deletions

View File

@ -277,8 +277,8 @@ ProcessCmdAddPointer (
ASSERT ((UINTN)Blob2->Base <= MAX_ADDRESS - Blob2->Size); ASSERT ((UINTN)Blob2->Base <= MAX_ADDRESS - Blob2->Size);
PointerValue += (UINT64)(UINTN)Blob2->Base; PointerValue += (UINT64)(UINTN)Blob2->Base;
if (RShiftU64 ( if (AddPointer->PointerSize < 8 &&
RShiftU64 (PointerValue, AddPointer->PointerSize * 8 - 1), 1) != 0) { RShiftU64 (PointerValue, AddPointer->PointerSize * 8) != 0) {
DEBUG ((EFI_D_ERROR, "%a: relocated pointer value unrepresentable in " DEBUG ((EFI_D_ERROR, "%a: relocated pointer value unrepresentable in "
"\"%a\"\n", __FUNCTION__, AddPointer->PointerFile)); "\"%a\"\n", __FUNCTION__, AddPointer->PointerFile));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
@ -438,8 +438,8 @@ ProcessCmdWritePointer (
ASSERT ((UINTN)PointeeBlob->Base <= MAX_ADDRESS - PointeeBlob->Size); ASSERT ((UINTN)PointeeBlob->Base <= MAX_ADDRESS - PointeeBlob->Size);
PointerValue += (UINT64)(UINTN)PointeeBlob->Base; PointerValue += (UINT64)(UINTN)PointeeBlob->Base;
if (RShiftU64 ( if (WritePointer->PointerSize < 8 &&
RShiftU64 (PointerValue, WritePointer->PointerSize * 8 - 1), 1) != 0) { RShiftU64 (PointerValue, WritePointer->PointerSize * 8) != 0) {
DEBUG ((DEBUG_ERROR, "%a: pointer value unrepresentable in \"%a\"\n", DEBUG ((DEBUG_ERROR, "%a: pointer value unrepresentable in \"%a\"\n",
__FUNCTION__, WritePointer->PointerFile)); __FUNCTION__, WritePointer->PointerFile));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;