[edk2-devel] [PATCH v5 5/5] MdeMoudlePkg/CapsulePei: No need to remain space for null-terminate

Gao, Zhichao posted 5 patches 6 years, 8 months ago
[edk2-devel] [PATCH v5 5/5] MdeMoudlePkg/CapsulePei: No need to remain space for null-terminate
Posted by Gao, Zhichao 6 years, 8 months ago
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1853

UnicodeValueToStringS would remain two bytes for the first
parameter to set the null- terminate. So remove this change
in Mu.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: Zhichao gao <zhichao.gao@intel.com>
---
 MdeModulePkg/Universal/CapsulePei/UefiCapsule.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c b/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c
index 3ac95b7be6..fabf30926c 100644
--- a/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c
+++ b/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c
@@ -922,7 +922,7 @@ GetScatterGatherHeadEntries (
     if (Index != 0) {
       UnicodeValueToStringS (
         TempVarName,
-        (sizeof (CapsuleVarName) - ((StrLen (CapsuleVarName) + 1) * sizeof (CHAR16))),
+        (sizeof(CapsuleVarName) - ((UINTN)TempVarName - (UINTN)CapsuleVarName)),
         0,
         Index,
         0
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#42059): https://edk2.groups.io/g/devel/message/42059
Mute This Topic: https://groups.io/mt/32001196/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH v5 5/5] MdeMoudlePkg/CapsulePei: No need to remain space for null-terminate
Posted by Leif Lindholm 6 years, 8 months ago
Many thanks for reworking this series.
This will make the code much more accessible in the future.
One very minor comment below:

On Mon, Jun 10, 2019 at 01:20:36PM +0800, Zhichao Gao wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1853
> 
> UnicodeValueToStringS would remain two bytes for the first
> parameter to set the null- terminate. So remove this change
> in Mu.
> 
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Cc: Michael Turner <Michael.Turner@microsoft.com>
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> Cc: Leif Lindholm <leif.lindholm@linaro.org>
> Signed-off-by: Zhichao gao <zhichao.gao@intel.com>
> ---
>  MdeModulePkg/Universal/CapsulePei/UefiCapsule.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c b/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c
> index 3ac95b7be6..fabf30926c 100644
> --- a/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c
> +++ b/MdeModulePkg/Universal/CapsulePei/UefiCapsule.c
> @@ -922,7 +922,7 @@ GetScatterGatherHeadEntries (
>      if (Index != 0) {
>        UnicodeValueToStringS (
>          TempVarName,
> -        (sizeof (CapsuleVarName) - ((StrLen (CapsuleVarName) + 1) * sizeof (CHAR16))),
> +        (sizeof(CapsuleVarName) - ((UINTN)TempVarName - (UINTN)CapsuleVarName)),

Could you add the space back after sizeof before committing?
With that - for the series:
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>

>          0,
>          Index,
>          0
> -- 
> 2.21.0.windows.1
> 

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#42091): https://edk2.groups.io/g/devel/message/42091
Mute This Topic: https://groups.io/mt/32001196/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-