[edk2-devel] [PATCH] Release build in GCC5 has warning message Wreturn-local-addr in HashPeiLib

JoeX Lu posted 1 patch 1 year ago
Failed in applying to current master (apply log)
.../HashLibBaseCryptoRouterPei.c                | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
[edk2-devel] [PATCH] Release build in GCC5 has warning message Wreturn-local-addr in HashPeiLib
Posted by JoeX Lu 1 year ago
CC: Jiewen Yao <jiewen.yao@intel.com>
CC: Jian J Wang <jian.j.wang@intel.com>
Signed-off-by: JoeX Lu <pen-chunx.lu@intel.com>
---
 .../HashLibBaseCryptoRouterPei.c                | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.c b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.c
index eeb424b6c3..bf7a5fc65c 100644
--- a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.c
+++ b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.c
@@ -84,11 +84,20 @@ InternalCreateHashInterfaceHob (
   EFI_GUID  *Identifier
   )
 {
-  HASH_INTERFACE_HOB  LocalHashInterfaceHob;
+  HASH_INTERFACE_HOB  *LocalHashInterfaceHob;
+  HASH_INTERFACE_HOB  *HobBuffer;
 
-  ZeroMem (&LocalHashInterfaceHob, sizeof (LocalHashInterfaceHob));
-  CopyGuid (&LocalHashInterfaceHob.Identifier, Identifier);
-  return BuildGuidDataHob (&mHashLibPeiRouterGuid, &LocalHashInterfaceHob, sizeof (LocalHashInterfaceHob));
+  HobBuffer = NULL;
+  LocalHashInterfaceHob = AllocateZeroPool (sizeof (HASH_INTERFACE_HOB));
+  if (LocalHashInterfaceHob == NULL) {
+    return NULL;
+  }
+  CopyGuid (&LocalHashInterfaceHob->Identifier, Identifier);
+  HobBuffer = (HASH_INTERFACE_HOB*) BuildGuidDataHob (&mHashLibPeiRouterGuid, LocalHashInterfaceHob, sizeof (LocalHashInterfaceHob));
+  if (LocalHashInterfaceHob != NULL) {
+    FreePool (LocalHashInterfaceHob);
+  }
+  return HobBuffer;
 }
 
 /**
-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103700): https://edk2.groups.io/g/devel/message/103700
Mute This Topic: https://groups.io/mt/98532174/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH] Release build in GCC5 has warning message Wreturn-local-addr in HashPeiLib
Posted by Yao, Jiewen 1 year ago
Hi
I am not sure if I can understand the patch.

Would you please clarify what the problem is in the original code?

> -----Original Message-----
> From: Lu, Pen-ChunX <pen-chunx.lu@intel.com>
> Sent: Thursday, April 27, 2023 2:59 PM
> To: devel@edk2.groups.io
> Cc: Lu, Pen-ChunX <pen-chunx.lu@intel.com>; Yao, Jiewen
> <jiewen.yao@intel.com>; Wang, Jian J <jian.j.wang@intel.com>
> Subject: [PATCH] Release build in GCC5 has warning message Wreturn-local-
> addr in HashPeiLib
> 
> CC: Jiewen Yao <jiewen.yao@intel.com>
> CC: Jian J Wang <jian.j.wang@intel.com>
> Signed-off-by: JoeX Lu <pen-chunx.lu@intel.com>
> ---
>  .../HashLibBaseCryptoRouterPei.c                | 17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git
> a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterP
> ei.c
> b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterP
> ei.c
> index eeb424b6c3..bf7a5fc65c 100644
> ---
> a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterP
> ei.c
> +++
> b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterP
> ei.c
> @@ -84,11 +84,20 @@ InternalCreateHashInterfaceHob (
>    EFI_GUID  *Identifier
>    )
>  {
> -  HASH_INTERFACE_HOB  LocalHashInterfaceHob;
> +  HASH_INTERFACE_HOB  *LocalHashInterfaceHob;
> +  HASH_INTERFACE_HOB  *HobBuffer;
> 
> -  ZeroMem (&LocalHashInterfaceHob, sizeof (LocalHashInterfaceHob));
> -  CopyGuid (&LocalHashInterfaceHob.Identifier, Identifier);
> -  return BuildGuidDataHob (&mHashLibPeiRouterGuid,
> &LocalHashInterfaceHob, sizeof (LocalHashInterfaceHob));
> +  HobBuffer = NULL;
> +  LocalHashInterfaceHob = AllocateZeroPool (sizeof
> (HASH_INTERFACE_HOB));
> +  if (LocalHashInterfaceHob == NULL) {
> +    return NULL;
> +  }
> +  CopyGuid (&LocalHashInterfaceHob->Identifier, Identifier);
> +  HobBuffer = (HASH_INTERFACE_HOB*) BuildGuidDataHob
> (&mHashLibPeiRouterGuid, LocalHashInterfaceHob, sizeof
> (LocalHashInterfaceHob));
> +  if (LocalHashInterfaceHob != NULL) {
> +    FreePool (LocalHashInterfaceHob);
> +  }
> +  return HobBuffer;
>  }
> 
>  /**
> --
> 2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103702): https://edk2.groups.io/g/devel/message/103702
Mute This Topic: https://groups.io/mt/98532174/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH] Release build in GCC5 has warning message Wreturn-local-addr in HashPeiLib
Posted by JoeX Lu 1 year ago
Hi,
 It means the code might be possible return local variable address when we used the function.
 So I allocate a resource to local variable to avoid this.

Best Regards,
Joe Lu

-----Original Message-----
From: Yao, Jiewen <jiewen.yao@intel.com> 
Sent: Thursday, April 27, 2023 3:51 PM
To: Lu, Pen-ChunX <pen-chunx.lu@intel.com>; devel@edk2.groups.io
Cc: Wang, Jian J <jian.j.wang@intel.com>
Subject: RE: [PATCH] Release build in GCC5 has warning message Wreturn-local-addr in HashPeiLib

Hi
I am not sure if I can understand the patch.

Would you please clarify what the problem is in the original code?

> -----Original Message-----
> From: Lu, Pen-ChunX <pen-chunx.lu@intel.com>
> Sent: Thursday, April 27, 2023 2:59 PM
> To: devel@edk2.groups.io
> Cc: Lu, Pen-ChunX <pen-chunx.lu@intel.com>; Yao, Jiewen 
> <jiewen.yao@intel.com>; Wang, Jian J <jian.j.wang@intel.com>
> Subject: [PATCH] Release build in GCC5 has warning message 
> Wreturn-local- addr in HashPeiLib
> 
> CC: Jiewen Yao <jiewen.yao@intel.com>
> CC: Jian J Wang <jian.j.wang@intel.com>
> Signed-off-by: JoeX Lu <pen-chunx.lu@intel.com>
> ---
>  .../HashLibBaseCryptoRouterPei.c                | 17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git
> a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterP
> ei.c
> b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterP
> ei.c
> index eeb424b6c3..bf7a5fc65c 100644
> ---
> a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterP
> ei.c
> +++
> b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterP
> ei.c
> @@ -84,11 +84,20 @@ InternalCreateHashInterfaceHob (
>    EFI_GUID  *Identifier
>    )
>  {
> -  HASH_INTERFACE_HOB  LocalHashInterfaceHob;
> +  HASH_INTERFACE_HOB  *LocalHashInterfaceHob;  HASH_INTERFACE_HOB  
> + *HobBuffer;
> 
> -  ZeroMem (&LocalHashInterfaceHob, sizeof (LocalHashInterfaceHob));
> -  CopyGuid (&LocalHashInterfaceHob.Identifier, Identifier);
> -  return BuildGuidDataHob (&mHashLibPeiRouterGuid, 
> &LocalHashInterfaceHob, sizeof (LocalHashInterfaceHob));
> +  HobBuffer = NULL;
> +  LocalHashInterfaceHob = AllocateZeroPool (sizeof
> (HASH_INTERFACE_HOB));
> +  if (LocalHashInterfaceHob == NULL) {
> +    return NULL;
> +  }
> +  CopyGuid (&LocalHashInterfaceHob->Identifier, Identifier);  
> + HobBuffer = (HASH_INTERFACE_HOB*) BuildGuidDataHob
> (&mHashLibPeiRouterGuid, LocalHashInterfaceHob, sizeof 
> (LocalHashInterfaceHob));
> +  if (LocalHashInterfaceHob != NULL) {
> +    FreePool (LocalHashInterfaceHob);  }  return HobBuffer;
>  }
> 
>  /**
> --
> 2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103704): https://edk2.groups.io/g/devel/message/103704
Mute This Topic: https://groups.io/mt/98532174/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH] Release build in GCC5 has warning message Wreturn-local-addr in HashPeiLib
Posted by Yao, Jiewen 1 year ago
Could you please show me how this function returns *local variable*?

return BuildGuidDataHob (&mHashLibPeiRouterGuid, &LocalHashInterfaceHob, sizeof (LocalHashInterfaceHob));


I don't understand the analysis.


> -----Original Message-----
> From: Lu, Pen-ChunX <pen-chunx.lu@intel.com>
> Sent: Thursday, April 27, 2023 3:58 PM
> To: Yao, Jiewen <jiewen.yao@intel.com>; devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>
> Subject: RE: [PATCH] Release build in GCC5 has warning message Wreturn-
> local-addr in HashPeiLib
> 
> Hi,
>  It means the code might be possible return local variable address when we
> used the function.
>  So I allocate a resource to local variable to avoid this.
> 
> Best Regards,
> Joe Lu
> 
> -----Original Message-----
> From: Yao, Jiewen <jiewen.yao@intel.com>
> Sent: Thursday, April 27, 2023 3:51 PM
> To: Lu, Pen-ChunX <pen-chunx.lu@intel.com>; devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>
> Subject: RE: [PATCH] Release build in GCC5 has warning message Wreturn-
> local-addr in HashPeiLib
> 
> Hi
> I am not sure if I can understand the patch.
> 
> Would you please clarify what the problem is in the original code?
> 
> > -----Original Message-----
> > From: Lu, Pen-ChunX <pen-chunx.lu@intel.com>
> > Sent: Thursday, April 27, 2023 2:59 PM
> > To: devel@edk2.groups.io
> > Cc: Lu, Pen-ChunX <pen-chunx.lu@intel.com>; Yao, Jiewen
> > <jiewen.yao@intel.com>; Wang, Jian J <jian.j.wang@intel.com>
> > Subject: [PATCH] Release build in GCC5 has warning message
> > Wreturn-local- addr in HashPeiLib
> >
> > CC: Jiewen Yao <jiewen.yao@intel.com>
> > CC: Jian J Wang <jian.j.wang@intel.com>
> > Signed-off-by: JoeX Lu <pen-chunx.lu@intel.com>
> > ---
> >  .../HashLibBaseCryptoRouterPei.c                | 17 +++++++++++++----
> >  1 file changed, 13 insertions(+), 4 deletions(-)
> >
> > diff --git
> >
> a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterP
> > ei.c
> >
> b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterP
> > ei.c
> > index eeb424b6c3..bf7a5fc65c 100644
> > ---
> >
> a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterP
> > ei.c
> > +++
> >
> b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterP
> > ei.c
> > @@ -84,11 +84,20 @@ InternalCreateHashInterfaceHob (
> >    EFI_GUID  *Identifier
> >    )
> >  {
> > -  HASH_INTERFACE_HOB  LocalHashInterfaceHob;
> > +  HASH_INTERFACE_HOB  *LocalHashInterfaceHob;
> HASH_INTERFACE_HOB
> > + *HobBuffer;
> >
> > -  ZeroMem (&LocalHashInterfaceHob, sizeof (LocalHashInterfaceHob));
> > -  CopyGuid (&LocalHashInterfaceHob.Identifier, Identifier);
> > -  return BuildGuidDataHob (&mHashLibPeiRouterGuid,
> > &LocalHashInterfaceHob, sizeof (LocalHashInterfaceHob));
> > +  HobBuffer = NULL;
> > +  LocalHashInterfaceHob = AllocateZeroPool (sizeof
> > (HASH_INTERFACE_HOB));
> > +  if (LocalHashInterfaceHob == NULL) {
> > +    return NULL;
> > +  }
> > +  CopyGuid (&LocalHashInterfaceHob->Identifier, Identifier);
> > + HobBuffer = (HASH_INTERFACE_HOB*) BuildGuidDataHob
> > (&mHashLibPeiRouterGuid, LocalHashInterfaceHob, sizeof
> > (LocalHashInterfaceHob));
> > +  if (LocalHashInterfaceHob != NULL) {
> > +    FreePool (LocalHashInterfaceHob);  }  return HobBuffer;
> >  }
> >
> >  /**
> > --
> > 2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103706): https://edk2.groups.io/g/devel/message/103706
Mute This Topic: https://groups.io/mt/98532174/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH] Release build in GCC5 has warning message Wreturn-local-addr in HashPeiLib
Posted by JoeX Lu 1 year ago
Theis patch just wants to remove the warning message in GCC5 release build just like attachment.

-----Original Message-----
From: Yao, Jiewen <jiewen.yao@intel.com> 
Sent: Thursday, April 27, 2023 4:21 PM
To: Lu, Pen-ChunX <pen-chunx.lu@intel.com>; devel@edk2.groups.io
Cc: Wang, Jian J <jian.j.wang@intel.com>
Subject: RE: [PATCH] Release build in GCC5 has warning message Wreturn-local-addr in HashPeiLib

Could you please show me how this function returns *local variable*?

return BuildGuidDataHob (&mHashLibPeiRouterGuid, &LocalHashInterfaceHob, sizeof (LocalHashInterfaceHob));


I don't understand the analysis.


> -----Original Message-----
> From: Lu, Pen-ChunX <pen-chunx.lu@intel.com>
> Sent: Thursday, April 27, 2023 3:58 PM
> To: Yao, Jiewen <jiewen.yao@intel.com>; devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>
> Subject: RE: [PATCH] Release build in GCC5 has warning message 
> Wreturn- local-addr in HashPeiLib
> 
> Hi,
>  It means the code might be possible return local variable address 
> when we used the function.
>  So I allocate a resource to local variable to avoid this.
> 
> Best Regards,
> Joe Lu
> 
> -----Original Message-----
> From: Yao, Jiewen <jiewen.yao@intel.com>
> Sent: Thursday, April 27, 2023 3:51 PM
> To: Lu, Pen-ChunX <pen-chunx.lu@intel.com>; devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>
> Subject: RE: [PATCH] Release build in GCC5 has warning message 
> Wreturn- local-addr in HashPeiLib
> 
> Hi
> I am not sure if I can understand the patch.
> 
> Would you please clarify what the problem is in the original code?
> 
> > -----Original Message-----
> > From: Lu, Pen-ChunX <pen-chunx.lu@intel.com>
> > Sent: Thursday, April 27, 2023 2:59 PM
> > To: devel@edk2.groups.io
> > Cc: Lu, Pen-ChunX <pen-chunx.lu@intel.com>; Yao, Jiewen 
> > <jiewen.yao@intel.com>; Wang, Jian J <jian.j.wang@intel.com>
> > Subject: [PATCH] Release build in GCC5 has warning message
> > Wreturn-local- addr in HashPeiLib
> >
> > CC: Jiewen Yao <jiewen.yao@intel.com>
> > CC: Jian J Wang <jian.j.wang@intel.com>
> > Signed-off-by: JoeX Lu <pen-chunx.lu@intel.com>
> > ---
> >  .../HashLibBaseCryptoRouterPei.c                | 17 +++++++++++++----
> >  1 file changed, 13 insertions(+), 4 deletions(-)
> >
> > diff --git
> >
> a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterP
> > ei.c
> >
> b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterP
> > ei.c
> > index eeb424b6c3..bf7a5fc65c 100644
> > ---
> >
> a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterP
> > ei.c
> > +++
> >
> b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterP
> > ei.c
> > @@ -84,11 +84,20 @@ InternalCreateHashInterfaceHob (
> >    EFI_GUID  *Identifier
> >    )
> >  {
> > -  HASH_INTERFACE_HOB  LocalHashInterfaceHob;
> > +  HASH_INTERFACE_HOB  *LocalHashInterfaceHob;
> HASH_INTERFACE_HOB
> > + *HobBuffer;
> >
> > -  ZeroMem (&LocalHashInterfaceHob, sizeof (LocalHashInterfaceHob));
> > -  CopyGuid (&LocalHashInterfaceHob.Identifier, Identifier);
> > -  return BuildGuidDataHob (&mHashLibPeiRouterGuid, 
> > &LocalHashInterfaceHob, sizeof (LocalHashInterfaceHob));
> > +  HobBuffer = NULL;
> > +  LocalHashInterfaceHob = AllocateZeroPool (sizeof
> > (HASH_INTERFACE_HOB));
> > +  if (LocalHashInterfaceHob == NULL) {
> > +    return NULL;
> > +  }
> > +  CopyGuid (&LocalHashInterfaceHob->Identifier, Identifier); 
> > + HobBuffer = (HASH_INTERFACE_HOB*) BuildGuidDataHob
> > (&mHashLibPeiRouterGuid, LocalHashInterfaceHob, sizeof 
> > (LocalHashInterfaceHob));
> > +  if (LocalHashInterfaceHob != NULL) {
> > +    FreePool (LocalHashInterfaceHob);  }  return HobBuffer;
> >  }
> >
> >  /**
> > --
> > 2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103708): https://edk2.groups.io/g/devel/message/103708
Mute This Topic: https://groups.io/mt/98532174/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH] Release build in GCC5 has warning message Wreturn-local-addr in HashPeiLib
Posted by Yao, Jiewen 1 year ago
This seems false alarm to me.

Unless you can prove there is real issue, I don't think this is right patch.

Nacked-by: Jiewen Yao <Jiewen.yao@intel.com>

> -----Original Message-----
> From: Lu, Pen-ChunX <pen-chunx.lu@intel.com>
> Sent: Thursday, April 27, 2023 4:55 PM
> To: Yao, Jiewen <jiewen.yao@intel.com>; devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>
> Subject: RE: [PATCH] Release build in GCC5 has warning message Wreturn-
> local-addr in HashPeiLib
> 
> Theis patch just wants to remove the warning message in GCC5 release build
> just like attachment.
> 
> -----Original Message-----
> From: Yao, Jiewen <jiewen.yao@intel.com>
> Sent: Thursday, April 27, 2023 4:21 PM
> To: Lu, Pen-ChunX <pen-chunx.lu@intel.com>; devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>
> Subject: RE: [PATCH] Release build in GCC5 has warning message Wreturn-
> local-addr in HashPeiLib
> 
> Could you please show me how this function returns *local variable*?
> 
> return BuildGuidDataHob (&mHashLibPeiRouterGuid,
> &LocalHashInterfaceHob, sizeof (LocalHashInterfaceHob));
> 
> 
> I don't understand the analysis.
> 
> 
> > -----Original Message-----
> > From: Lu, Pen-ChunX <pen-chunx.lu@intel.com>
> > Sent: Thursday, April 27, 2023 3:58 PM
> > To: Yao, Jiewen <jiewen.yao@intel.com>; devel@edk2.groups.io
> > Cc: Wang, Jian J <jian.j.wang@intel.com>
> > Subject: RE: [PATCH] Release build in GCC5 has warning message
> > Wreturn- local-addr in HashPeiLib
> >
> > Hi,
> >  It means the code might be possible return local variable address
> > when we used the function.
> >  So I allocate a resource to local variable to avoid this.
> >
> > Best Regards,
> > Joe Lu
> >
> > -----Original Message-----
> > From: Yao, Jiewen <jiewen.yao@intel.com>
> > Sent: Thursday, April 27, 2023 3:51 PM
> > To: Lu, Pen-ChunX <pen-chunx.lu@intel.com>; devel@edk2.groups.io
> > Cc: Wang, Jian J <jian.j.wang@intel.com>
> > Subject: RE: [PATCH] Release build in GCC5 has warning message
> > Wreturn- local-addr in HashPeiLib
> >
> > Hi
> > I am not sure if I can understand the patch.
> >
> > Would you please clarify what the problem is in the original code?
> >
> > > -----Original Message-----
> > > From: Lu, Pen-ChunX <pen-chunx.lu@intel.com>
> > > Sent: Thursday, April 27, 2023 2:59 PM
> > > To: devel@edk2.groups.io
> > > Cc: Lu, Pen-ChunX <pen-chunx.lu@intel.com>; Yao, Jiewen
> > > <jiewen.yao@intel.com>; Wang, Jian J <jian.j.wang@intel.com>
> > > Subject: [PATCH] Release build in GCC5 has warning message
> > > Wreturn-local- addr in HashPeiLib
> > >
> > > CC: Jiewen Yao <jiewen.yao@intel.com>
> > > CC: Jian J Wang <jian.j.wang@intel.com>
> > > Signed-off-by: JoeX Lu <pen-chunx.lu@intel.com>
> > > ---
> > >  .../HashLibBaseCryptoRouterPei.c                | 17 +++++++++++++----
> > >  1 file changed, 13 insertions(+), 4 deletions(-)
> > >
> > > diff --git
> > >
> >
> a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterP
> > > ei.c
> > >
> >
> b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterP
> > > ei.c
> > > index eeb424b6c3..bf7a5fc65c 100644
> > > ---
> > >
> >
> a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterP
> > > ei.c
> > > +++
> > >
> >
> b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterP
> > > ei.c
> > > @@ -84,11 +84,20 @@ InternalCreateHashInterfaceHob (
> > >    EFI_GUID  *Identifier
> > >    )
> > >  {
> > > -  HASH_INTERFACE_HOB  LocalHashInterfaceHob;
> > > +  HASH_INTERFACE_HOB  *LocalHashInterfaceHob;
> > HASH_INTERFACE_HOB
> > > + *HobBuffer;
> > >
> > > -  ZeroMem (&LocalHashInterfaceHob, sizeof (LocalHashInterfaceHob));
> > > -  CopyGuid (&LocalHashInterfaceHob.Identifier, Identifier);
> > > -  return BuildGuidDataHob (&mHashLibPeiRouterGuid,
> > > &LocalHashInterfaceHob, sizeof (LocalHashInterfaceHob));
> > > +  HobBuffer = NULL;
> > > +  LocalHashInterfaceHob = AllocateZeroPool (sizeof
> > > (HASH_INTERFACE_HOB));
> > > +  if (LocalHashInterfaceHob == NULL) {
> > > +    return NULL;
> > > +  }
> > > +  CopyGuid (&LocalHashInterfaceHob->Identifier, Identifier);
> > > + HobBuffer = (HASH_INTERFACE_HOB*) BuildGuidDataHob
> > > (&mHashLibPeiRouterGuid, LocalHashInterfaceHob, sizeof
> > > (LocalHashInterfaceHob));
> > > +  if (LocalHashInterfaceHob != NULL) {
> > > +    FreePool (LocalHashInterfaceHob);  }  return HobBuffer;
> > >  }
> > >
> > >  /**
> > > --
> > > 2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103709): https://edk2.groups.io/g/devel/message/103709
Mute This Topic: https://groups.io/mt/98532174/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-