public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 1/1] OvmfPkg/LinuxInitrdDynamicShellCommand: fix uninitialized status return
@ 2020-03-04 11:49 Ard Biesheuvel
  2020-03-04 16:58 ` Laszlo Ersek
  0 siblings, 1 reply; 3+ messages in thread
From: Ard Biesheuvel @ 2020-03-04 11:49 UTC (permalink / raw)
  To: devel; +Cc: lersek, Ard Biesheuvel

The Linaro CI reports:

  OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c:132:7:
  error: variable 'Status' is used uninitialized whenever 'if' condition is
                false [-Werror,-Wsometimes-uninitialized]
    if (mInitrdLoadFile2Handle != NULL) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c:141:10:
  note: uninitialized use occurs here
    return Status;
           ^~~~~~
  OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c:132:3:
  note: remove the 'if' if its condition is always true
    if (mInitrdLoadFile2Handle != NULL) {
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c:130:23:
  note: initialize the variable 'Status' to silence this warning
    EFI_STATUS    Status;
                      ^
                       = 0

Fix this by pulling the return of Status into the conditional block where
it is assigned, and return EFI_SUCCESS otherwise.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c b/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c
index ed8fbaa77069..021b072826a9 100644
--- a/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c
+++ b/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c
@@ -137,8 +137,9 @@ UninstallLoadFile2Protocol (
     if (!EFI_ERROR (Status)) {
       mInitrdLoadFile2Handle = NULL;
     }
+    return Status;
   }
-  return Status;
+  return EFI_SUCCESS;
 }
 
 STATIC
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] OvmfPkg/LinuxInitrdDynamicShellCommand: fix uninitialized status return
  2020-03-04 11:49 [PATCH 1/1] OvmfPkg/LinuxInitrdDynamicShellCommand: fix uninitialized status return Ard Biesheuvel
@ 2020-03-04 16:58 ` Laszlo Ersek
  2020-03-04 17:43   ` Ard Biesheuvel
  0 siblings, 1 reply; 3+ messages in thread
From: Laszlo Ersek @ 2020-03-04 16:58 UTC (permalink / raw)
  To: Ard Biesheuvel, devel

On 03/04/20 12:49, Ard Biesheuvel wrote:
> The Linaro CI reports:
> 
>   OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c:132:7:
>   error: variable 'Status' is used uninitialized whenever 'if' condition is
>                 false [-Werror,-Wsometimes-uninitialized]
>     if (mInitrdLoadFile2Handle != NULL) {
>         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c:141:10:
>   note: uninitialized use occurs here
>     return Status;
>            ^~~~~~
>   OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c:132:3:
>   note: remove the 'if' if its condition is always true
>     if (mInitrdLoadFile2Handle != NULL) {
>     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c:130:23:
>   note: initialize the variable 'Status' to silence this warning
>     EFI_STATUS    Status;
>                       ^
>                        = 0
> 
> Fix this by pulling the return of Status into the conditional block where
> it is assigned, and return EFI_SUCCESS otherwise.
> 
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c b/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c
> index ed8fbaa77069..021b072826a9 100644
> --- a/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c
> +++ b/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c
> @@ -137,8 +137,9 @@ UninstallLoadFile2Protocol (
>      if (!EFI_ERROR (Status)) {
>        mInitrdLoadFile2Handle = NULL;
>      }
> +    return Status;
>    }
> -  return Status;
> +  return EFI_SUCCESS;
>  }
>  
>  STATIC
> 

I should have caught this in review. :/

Please add the following to the commit message:

Fixes: 2632178bc683f1f28f9dbe269f85d6b26b1800de
Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Thanks
Laszlo


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] OvmfPkg/LinuxInitrdDynamicShellCommand: fix uninitialized status return
  2020-03-04 16:58 ` Laszlo Ersek
@ 2020-03-04 17:43   ` Ard Biesheuvel
  0 siblings, 0 replies; 3+ messages in thread
From: Ard Biesheuvel @ 2020-03-04 17:43 UTC (permalink / raw)
  To: Laszlo Ersek; +Cc: edk2-devel-groups-io

On Wed, 4 Mar 2020 at 17:58, Laszlo Ersek <lersek@redhat.com> wrote:
>
> On 03/04/20 12:49, Ard Biesheuvel wrote:
> > The Linaro CI reports:
> >
> >   OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c:132:7:
> >   error: variable 'Status' is used uninitialized whenever 'if' condition is
> >                 false [-Werror,-Wsometimes-uninitialized]
> >     if (mInitrdLoadFile2Handle != NULL) {
> >         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >   OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c:141:10:
> >   note: uninitialized use occurs here
> >     return Status;
> >            ^~~~~~
> >   OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c:132:3:
> >   note: remove the 'if' if its condition is always true
> >     if (mInitrdLoadFile2Handle != NULL) {
> >     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >   OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c:130:23:
> >   note: initialize the variable 'Status' to silence this warning
> >     EFI_STATUS    Status;
> >                       ^
> >                        = 0
> >
> > Fix this by pulling the return of Status into the conditional block where
> > it is assigned, and return EFI_SUCCESS otherwise.
> >
> > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > ---
> >  OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c b/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c
> > index ed8fbaa77069..021b072826a9 100644
> > --- a/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c
> > +++ b/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c
> > @@ -137,8 +137,9 @@ UninstallLoadFile2Protocol (
> >      if (!EFI_ERROR (Status)) {
> >        mInitrdLoadFile2Handle = NULL;
> >      }
> > +    return Status;
> >    }
> > -  return Status;
> > +  return EFI_SUCCESS;
> >  }
> >
> >  STATIC
> >
>
> I should have caught this in review. :/
>
> Please add the following to the commit message:
>
> Fixes: 2632178bc683f1f28f9dbe269f85d6b26b1800de
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
>

Pushed as 6c6fef024718578596a3554e6d287a89aa49b950

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-04 17:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-04 11:49 [PATCH 1/1] OvmfPkg/LinuxInitrdDynamicShellCommand: fix uninitialized status return Ard Biesheuvel
2020-03-04 16:58 ` Laszlo Ersek
2020-03-04 17:43   ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox