On 26 December 2017 at 08:46, Gao, Liming <[email protected]> wrote: > Ard: > Here is the simpler version. Convert pointer to UINTN, then subtract them > to get the size, last convert it to UINT32. > > AuthVarStorage->Size = (UINT32)((UINTN) AuthStartPtr - (UINTN) > AuthVarStorage); >
That looks much better, thanks (although I prefer no space after the cast) >>-----Original Message----- >>From: Ard Biesheuvel [mailto:[email protected]] >>Sent: Tuesday, December 26, 2017 4:39 PM >>To: Gao, Liming <[email protected]> >>Cc: [email protected]; Zeng, Star <[email protected]> >>Subject: Re: [edk2] [Patch] MdeModulePkg Variable: Update Pointer Minus >>with UINTN type >> >>On 26 December 2017 at 08:36, Liming Gao <[email protected]> wrote: >>> Contributed-under: TianoCore Contribution Agreement 1.1 >>> Signed-off-by: Liming Gao <[email protected]> >>> Cc: Star Zeng <[email protected]> >> >>Could you please add an explanation why this is necessary? Do we >>really need 5 (!) casts to perform a simple subtraction? >> >>> --- >>> MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c >>b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c >>> index 77905a0..a47270a 100644 >>> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c >>> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c >>> @@ -4125,7 +4125,7 @@ ConvertNormalVarStorageToAuthVarStorage ( >>> // >>> AuthVarStorage->Format = NormalVarStorage->Format; >>> AuthVarStorage->State = NormalVarStorage->State; >>> - AuthVarStorage->Size = (UINT32) (UINTN) ((UINT8 *) AuthStartPtr - >>(UINT8 *) AuthVarStorage); >>> + AuthVarStorage->Size = (UINT32)((UINTN) (UINT8 *) AuthStartPtr - >>(UINTN) (UINT8 *) AuthVarStorage); >>> CopyGuid (&AuthVarStorage->Signature, >>&gEfiAuthenticatedVariableGuid); >>> ASSERT (AuthVarStorage->Size <= AuthVarStroageSize); >>> >>> -- >>> 2.8.0.windows.1 >>> >>> _______________________________________________ >>> edk2-devel mailing list >>> [email protected] >>> https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

