* [PATCH] MdeModulePkg: Initialize local variable value before they are used
@ 2021-03-09 1:24 gaoliming
2021-03-09 2:10 ` Wu, Hao A
2021-03-11 17:21 ` [edk2-devel] " Laszlo Ersek
0 siblings, 2 replies; 6+ messages in thread
From: gaoliming @ 2021-03-09 1:24 UTC (permalink / raw)
To: devel; +Cc: Jian J Wang, Hao A Wu
This change is to fix the compiler error on GCC49 release build.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Signed-off-by: Liming Gao <gaoliming@byosoft.com.cn>
---
MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c | 1 +
.../Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
index e99a812a44..0779f94f9e 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
@@ -1122,6 +1122,7 @@ AhciDmaTransfer (
Map = NULL;
PciIo = Instance->PciIo;
+ Status = EFI_SUCCESS;
if (PciIo == NULL) {
return EFI_INVALID_PARAMETER;
diff --git a/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c b/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
index 0c9299c8b0..7822cbf4bb 100644
--- a/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
+++ b/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
@@ -117,6 +117,7 @@ CreateBasicVariablePolicy (
// Now we've gotta determine the total size of the buffer required for
// the VariablePolicy structure.
+ NameSize = 0;
TotalSize = sizeof( VARIABLE_POLICY_ENTRY );
if (Name != NULL) {
NameSize = StrnSizeS( Name, MAX_UINT16 );
--
2.27.0.windows.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] MdeModulePkg: Initialize local variable value before they are used
2021-03-09 1:24 [PATCH] MdeModulePkg: Initialize local variable value before they are used gaoliming
@ 2021-03-09 2:10 ` Wu, Hao A
2021-03-11 1:10 ` 回复: " gaoliming
2021-03-11 17:21 ` [edk2-devel] " Laszlo Ersek
1 sibling, 1 reply; 6+ messages in thread
From: Wu, Hao A @ 2021-03-09 2:10 UTC (permalink / raw)
To: Liming Gao, devel@edk2.groups.io; +Cc: Wang, Jian J
> -----Original Message-----
> From: Liming Gao <gaoliming@byosoft.com.cn>
> Sent: Tuesday, March 9, 2021 9:24 AM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>
> Subject: [PATCH] MdeModulePkg: Initialize local variable value before they are
> used
>
> This change is to fix the compiler error on GCC49 release build.
Thanks Liming. The patch looks good to me:
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
I have one question that I think both the reports are false positives.
Do you think it will be better to add this information in the commit message?
Best Regards,
Hao Wu
>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Signed-off-by: Liming Gao <gaoliming@byosoft.com.cn>
> ---
> MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c | 1 +
> .../Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> index e99a812a44..0779f94f9e 100644
> --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> @@ -1122,6 +1122,7 @@ AhciDmaTransfer (
>
> Map = NULL;
> PciIo = Instance->PciIo;
> + Status = EFI_SUCCESS;
>
> if (PciIo == NULL) {
> return EFI_INVALID_PARAMETER;
> diff --git
> a/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
> b/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
> index 0c9299c8b0..7822cbf4bb 100644
> ---
> a/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
> +++
> b/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
> @@ -117,6 +117,7 @@ CreateBasicVariablePolicy (
>
> // Now we've gotta determine the total size of the buffer required for
> // the VariablePolicy structure.
> + NameSize = 0;
> TotalSize = sizeof( VARIABLE_POLICY_ENTRY );
> if (Name != NULL) {
> NameSize = StrnSizeS( Name, MAX_UINT16 );
> --
> 2.27.0.windows.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* 回复: [PATCH] MdeModulePkg: Initialize local variable value before they are used
2021-03-09 2:10 ` Wu, Hao A
@ 2021-03-11 1:10 ` gaoliming
2021-03-11 1:32 ` [edk2-devel] " Wu, Hao A
0 siblings, 1 reply; 6+ messages in thread
From: gaoliming @ 2021-03-11 1:10 UTC (permalink / raw)
To: 'Wu, Hao A', devel; +Cc: 'Wang, Jian J'
Hao:
Yes. I agree. I will add this information when I merge it.
Thanks
Liming
> -----邮件原件-----
> 发件人: Wu, Hao A <hao.a.wu@intel.com>
> 发送时间: 2021年3月9日 10:10
> 收件人: Liming Gao <gaoliming@byosoft.com.cn>; devel@edk2.groups.io
> 抄送: Wang, Jian J <jian.j.wang@intel.com>
> 主题: RE: [PATCH] MdeModulePkg: Initialize local variable value before
they
> are used
>
> > -----Original Message-----
> > From: Liming Gao <gaoliming@byosoft.com.cn>
> > Sent: Tuesday, March 9, 2021 9:24 AM
> > To: devel@edk2.groups.io
> > Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A
> <hao.a.wu@intel.com>
> > Subject: [PATCH] MdeModulePkg: Initialize local variable value before
they
> are
> > used
> >
> > This change is to fix the compiler error on GCC49 release build.
>
>
> Thanks Liming. The patch looks good to me:
> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
>
> I have one question that I think both the reports are false positives.
> Do you think it will be better to add this information in the commit
message?
>
> Best Regards,
> Hao Wu
>
>
> >
> > Cc: Jian J Wang <jian.j.wang@intel.com>
> > Cc: Hao A Wu <hao.a.wu@intel.com>
> > Signed-off-by: Liming Gao <gaoliming@byosoft.com.cn>
> > ---
> > MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> | 1 +
> > .../Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c | 1 +
> > 2 files changed, 2 insertions(+)
> >
> > diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> > b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> > index e99a812a44..0779f94f9e 100644
> > --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> > +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> > @@ -1122,6 +1122,7 @@ AhciDmaTransfer (
> >
> > Map = NULL;
> > PciIo = Instance->PciIo;
> > + Status = EFI_SUCCESS;
> >
> > if (PciIo == NULL) {
> > return EFI_INVALID_PARAMETER;
> > diff --git
> >
> a/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
> >
> b/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
> > index 0c9299c8b0..7822cbf4bb 100644
> > ---
> >
> a/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
> > +++
> >
> b/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
> > @@ -117,6 +117,7 @@ CreateBasicVariablePolicy (
> >
> > // Now we've gotta determine the total size of the buffer required
for
> > // the VariablePolicy structure.
> > + NameSize = 0;
> > TotalSize = sizeof( VARIABLE_POLICY_ENTRY );
> > if (Name != NULL) {
> > NameSize = StrnSizeS( Name, MAX_UINT16 );
> > --
> > 2.27.0.windows.1
> >
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [edk2-devel] 回复: [PATCH] MdeModulePkg: Initialize local variable value before they are used
2021-03-11 1:10 ` 回复: " gaoliming
@ 2021-03-11 1:32 ` Wu, Hao A
0 siblings, 0 replies; 6+ messages in thread
From: Wu, Hao A @ 2021-03-11 1:32 UTC (permalink / raw)
To: devel@edk2.groups.io, gaoliming@byosoft.com.cn; +Cc: Wang, Jian J
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of gaoliming
> Sent: Thursday, March 11, 2021 9:10 AM
> To: Wu, Hao A <hao.a.wu@intel.com>; devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>
> Subject: [edk2-devel] 回复: [PATCH] MdeModulePkg: Initialize local variable
> value before they are used
>
> Hao:
> Yes. I agree. I will add this information when I merge it.
Hello Liming,
Thanks a lot.
Best Regards,
Hao Wu
>
> Thanks
> Liming
> > -----邮件原件-----
> > 发件人: Wu, Hao A <hao.a.wu@intel.com>
> > 发送时间: 2021年3月9日 10:10
> > 收件人: Liming Gao <gaoliming@byosoft.com.cn>; devel@edk2.groups.io
> > 抄送: Wang, Jian J <jian.j.wang@intel.com>
> > 主题: RE: [PATCH] MdeModulePkg: Initialize local variable value before
> they
> > are used
> >
> > > -----Original Message-----
> > > From: Liming Gao <gaoliming@byosoft.com.cn>
> > > Sent: Tuesday, March 9, 2021 9:24 AM
> > > To: devel@edk2.groups.io
> > > Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A
> > <hao.a.wu@intel.com>
> > > Subject: [PATCH] MdeModulePkg: Initialize local variable value before
> they
> > are
> > > used
> > >
> > > This change is to fix the compiler error on GCC49 release build.
> >
> >
> > Thanks Liming. The patch looks good to me:
> > Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
> >
> > I have one question that I think both the reports are false positives.
> > Do you think it will be better to add this information in the commit
> message?
> >
> > Best Regards,
> > Hao Wu
> >
> >
> > >
> > > Cc: Jian J Wang <jian.j.wang@intel.com>
> > > Cc: Hao A Wu <hao.a.wu@intel.com>
> > > Signed-off-by: Liming Gao <gaoliming@byosoft.com.cn>
> > > ---
> > > MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> > | 1 +
> > > .../Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c | 1 +
> > > 2 files changed, 2 insertions(+)
> > >
> > > diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> > > b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> > > index e99a812a44..0779f94f9e 100644
> > > --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> > > +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> > > @@ -1122,6 +1122,7 @@ AhciDmaTransfer (
> > >
> > > Map = NULL;
> > > PciIo = Instance->PciIo;
> > > + Status = EFI_SUCCESS;
> > >
> > > if (PciIo == NULL) {
> > > return EFI_INVALID_PARAMETER;
> > > diff --git
> > >
> > a/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
> > >
> > b/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
> > > index 0c9299c8b0..7822cbf4bb 100644
> > > ---
> > >
> > a/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
> > > +++
> > >
> > b/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
> > > @@ -117,6 +117,7 @@ CreateBasicVariablePolicy (
> > >
> > > // Now we've gotta determine the total size of the buffer required
> for
> > > // the VariablePolicy structure.
> > > + NameSize = 0;
> > > TotalSize = sizeof( VARIABLE_POLICY_ENTRY );
> > > if (Name != NULL) {
> > > NameSize = StrnSizeS( Name, MAX_UINT16 );
> > > --
> > > 2.27.0.windows.1
> > >
>
>
>
>
>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [edk2-devel] [PATCH] MdeModulePkg: Initialize local variable value before they are used
2021-03-09 1:24 [PATCH] MdeModulePkg: Initialize local variable value before they are used gaoliming
2021-03-09 2:10 ` Wu, Hao A
@ 2021-03-11 17:21 ` Laszlo Ersek
2021-03-15 2:57 ` 回复: " gaoliming
1 sibling, 1 reply; 6+ messages in thread
From: Laszlo Ersek @ 2021-03-11 17:21 UTC (permalink / raw)
To: devel, gaoliming; +Cc: Jian J Wang, Hao A Wu, sergei
Hi Liming,
On 03/09/21 02:24, gaoliming wrote:
> This change is to fix the compiler error on GCC49 release build.
>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Signed-off-by: Liming Gao <gaoliming@byosoft.com.cn>
> ---
> MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c | 1 +
> .../Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> index e99a812a44..0779f94f9e 100644
> --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> @@ -1122,6 +1122,7 @@ AhciDmaTransfer (
>
> Map = NULL;
> PciIo = Instance->PciIo;
> + Status = EFI_SUCCESS;
>
> if (PciIo == NULL) {
> return EFI_INVALID_PARAMETER;
> diff --git a/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c b/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
> index 0c9299c8b0..7822cbf4bb 100644
> --- a/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
> +++ b/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
> @@ -117,6 +117,7 @@ CreateBasicVariablePolicy (
>
> // Now we've gotta determine the total size of the buffer required for
> // the VariablePolicy structure.
> + NameSize = 0;
> TotalSize = sizeof( VARIABLE_POLICY_ENTRY );
> if (Name != NULL) {
> NameSize = StrnSizeS( Name, MAX_UINT16 );
>
(1) we have a bugzilla ticket related to this (or more precisely,
overlapping AtaAtapiPassThru):
https://bugzilla.tianocore.org/show_bug.cgi?id=3228
I think mentioning the BZ in the commit message might make sense.
(2) Recently we have used a special comment format for such assignments.
Namely:
//
// Set Status to suppress incorrect compiler/analyzer warnings
//
Status = EFI_SUCCESS;
Hao already requested that we should document that we only suppress
compiler false positives with these assignments -- they are not needed
functionally. However, I think saying so in the commit message *only* is
not sufficient. I think we should stick with the above code-comment
format (which we've used recently in several places).
Thanks!
Laszlo
^ permalink raw reply [flat|nested] 6+ messages in thread
* 回复: [edk2-devel] [PATCH] MdeModulePkg: Initialize local variable value before they are used
2021-03-11 17:21 ` [edk2-devel] " Laszlo Ersek
@ 2021-03-15 2:57 ` gaoliming
0 siblings, 0 replies; 6+ messages in thread
From: gaoliming @ 2021-03-15 2:57 UTC (permalink / raw)
To: 'Laszlo Ersek', devel
Cc: 'Jian J Wang', 'Hao A Wu', sergei
Laszlo:
I agree your comments. I will update the patch to include the comments in code and commit message.
Thanks
Liming
> -----邮件原件-----
> 发件人: Laszlo Ersek <lersek@redhat.com>
> 发送时间: 2021年3月12日 1:22
> 收件人: devel@edk2.groups.io; gaoliming@byosoft.com.cn
> 抄送: Jian J Wang <jian.j.wang@intel.com>; Hao A Wu
> <hao.a.wu@intel.com>; sergei@posteo.net
> 主题: Re: [edk2-devel] [PATCH] MdeModulePkg: Initialize local variable value
> before they are used
>
> Hi Liming,
>
> On 03/09/21 02:24, gaoliming wrote:
> > This change is to fix the compiler error on GCC49 release build.
> >
> > Cc: Jian J Wang <jian.j.wang@intel.com>
> > Cc: Hao A Wu <hao.a.wu@intel.com>
> > Signed-off-by: Liming Gao <gaoliming@byosoft.com.cn>
> > ---
> > MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> | 1 +
> > .../Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c | 1 +
> > 2 files changed, 2 insertions(+)
> >
> > diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> > index e99a812a44..0779f94f9e 100644
> > --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> > +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
> > @@ -1122,6 +1122,7 @@ AhciDmaTransfer (
> >
> > Map = NULL;
> > PciIo = Instance->PciIo;
> > + Status = EFI_SUCCESS;
> >
> > if (PciIo == NULL) {
> > return EFI_INVALID_PARAMETER;
> > diff --git
> a/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
> b/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
> > index 0c9299c8b0..7822cbf4bb 100644
> > ---
> a/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
> > +++
> b/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c
> > @@ -117,6 +117,7 @@ CreateBasicVariablePolicy (
> >
> > // Now we've gotta determine the total size of the buffer required for
> > // the VariablePolicy structure.
> > + NameSize = 0;
> > TotalSize = sizeof( VARIABLE_POLICY_ENTRY );
> > if (Name != NULL) {
> > NameSize = StrnSizeS( Name, MAX_UINT16 );
> >
>
> (1) we have a bugzilla ticket related to this (or more precisely,
> overlapping AtaAtapiPassThru):
>
> https://bugzilla.tianocore.org/show_bug.cgi?id=3228
>
> I think mentioning the BZ in the commit message might make sense.
>
> (2) Recently we have used a special comment format for such assignments.
> Namely:
>
> //
> // Set Status to suppress incorrect compiler/analyzer warnings
> //
> Status = EFI_SUCCESS;
>
> Hao already requested that we should document that we only suppress
> compiler false positives with these assignments -- they are not needed
> functionally. However, I think saying so in the commit message *only* is
> not sufficient. I think we should stick with the above code-comment
> format (which we've used recently in several places).
>
> Thanks!
> Laszlo
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-03-15 2:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-09 1:24 [PATCH] MdeModulePkg: Initialize local variable value before they are used gaoliming
2021-03-09 2:10 ` Wu, Hao A
2021-03-11 1:10 ` 回复: " gaoliming
2021-03-11 1:32 ` [edk2-devel] " Wu, Hao A
2021-03-11 17:21 ` [edk2-devel] " Laszlo Ersek
2021-03-15 2:57 ` 回复: " gaoliming
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox