From: "JoeX Lu" <pen-chunx.lu@intel.com>
To: "Yao, Jiewen" <jiewen.yao@intel.com>,
"devel@edk2.groups.io" <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
Date: Thu, 27 Apr 2023 08:55:22 +0000 [thread overview]
Message-ID: <IA1PR11MB607329E2BBC14CF17B126224C66A9@IA1PR11MB6073.namprd11.prod.outlook.com> (raw)
In-Reply-To: <MW4PR11MB58729B15D32BA450CD47976F8C6A9@MW4PR11MB5872.namprd11.prod.outlook.com>
[-- Attachment #1: Type: text/plain, Size: 3846 bytes --]
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
[-- Attachment #2: Screenshot 2023-04-27 165409.png --]
[-- Type: image/png, Size: 283378 bytes --]
next prev parent reply other threads:[~2023-04-27 8:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-27 6:58 [PATCH] Release build in GCC5 has warning message Wreturn-local-addr in HashPeiLib JoeX Lu
2023-04-27 7:50 ` Yao, Jiewen
2023-04-27 7:58 ` JoeX Lu
2023-04-27 8:21 ` Yao, Jiewen
2023-04-27 8:55 ` JoeX Lu [this message]
2023-04-27 9:10 ` Yao, Jiewen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=IA1PR11MB607329E2BBC14CF17B126224C66A9@IA1PR11MB6073.namprd11.prod.outlook.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox