* [Patch] MdeModulePkg Variable: Update Pointer Minus with UINTN type
@ 2017-12-26 8:36 Liming Gao
2017-12-26 8:39 ` Ard Biesheuvel
0 siblings, 1 reply; 4+ messages in thread
From: Liming Gao @ 2017-12-26 8:36 UTC (permalink / raw)
To: edk2-devel; +Cc: Star Zeng
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
---
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Patch] MdeModulePkg Variable: Update Pointer Minus with UINTN type
2017-12-26 8:36 [Patch] MdeModulePkg Variable: Update Pointer Minus with UINTN type Liming Gao
@ 2017-12-26 8:39 ` Ard Biesheuvel
2017-12-26 8:46 ` Gao, Liming
0 siblings, 1 reply; 4+ messages in thread
From: Ard Biesheuvel @ 2017-12-26 8:39 UTC (permalink / raw)
To: Liming Gao; +Cc: edk2-devel@lists.01.org, Star Zeng
On 26 December 2017 at 08:36, Liming Gao <liming.gao@intel.com> wrote:
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Liming Gao <liming.gao@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
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
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch] MdeModulePkg Variable: Update Pointer Minus with UINTN type
2017-12-26 8:39 ` Ard Biesheuvel
@ 2017-12-26 8:46 ` Gao, Liming
2017-12-26 8:51 ` Ard Biesheuvel
0 siblings, 1 reply; 4+ messages in thread
From: Gao, Liming @ 2017-12-26 8:46 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: edk2-devel@lists.01.org, Zeng, Star
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);
Thanks
Liming
>-----Original Message-----
>From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>Sent: Tuesday, December 26, 2017 4:39 PM
>To: Gao, Liming <liming.gao@intel.com>
>Cc: edk2-devel@lists.01.org; Zeng, Star <star.zeng@intel.com>
>Subject: Re: [edk2] [Patch] MdeModulePkg Variable: Update Pointer Minus
>with UINTN type
>
>On 26 December 2017 at 08:36, Liming Gao <liming.gao@intel.com> wrote:
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Liming Gao <liming.gao@intel.com>
>> Cc: Star Zeng <star.zeng@intel.com>
>
>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
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch] MdeModulePkg Variable: Update Pointer Minus with UINTN type
2017-12-26 8:46 ` Gao, Liming
@ 2017-12-26 8:51 ` Ard Biesheuvel
0 siblings, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2017-12-26 8:51 UTC (permalink / raw)
To: Gao, Liming; +Cc: edk2-devel@lists.01.org, Zeng, Star
On 26 December 2017 at 08:46, Gao, Liming <liming.gao@intel.com> 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:ard.biesheuvel@linaro.org]
>>Sent: Tuesday, December 26, 2017 4:39 PM
>>To: Gao, Liming <liming.gao@intel.com>
>>Cc: edk2-devel@lists.01.org; Zeng, Star <star.zeng@intel.com>
>>Subject: Re: [edk2] [Patch] MdeModulePkg Variable: Update Pointer Minus
>>with UINTN type
>>
>>On 26 December 2017 at 08:36, Liming Gao <liming.gao@intel.com> wrote:
>>> Contributed-under: TianoCore Contribution Agreement 1.1
>>> Signed-off-by: Liming Gao <liming.gao@intel.com>
>>> Cc: Star Zeng <star.zeng@intel.com>
>>
>>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
>>> edk2-devel@lists.01.org
>>> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-12-26 8:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-26 8:36 [Patch] MdeModulePkg Variable: Update Pointer Minus with UINTN type Liming Gao
2017-12-26 8:39 ` Ard Biesheuvel
2017-12-26 8:46 ` Gao, Liming
2017-12-26 8:51 ` Ard Biesheuvel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox