]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/AcpiPlatformDxe: drop double right shift in ADD/WRITE POINTER cmds
authorLaszlo Ersek <lersek@redhat.com>
Tue, 21 Feb 2017 12:30:48 +0000 (13:30 +0100)
committerLaszlo Ersek <lersek@redhat.com>
Wed, 22 Feb 2017 02:35:18 +0000 (03:35 +0100)
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>
OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c

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