* [PATCH v1 1/2] ShellPkg/UefiShellCommandLib: suppress incorrect gcc warning
2021-05-11 22:56 [PATCH v1 0/2] "maybe-uninitialized" warnings emitted by sergei
@ 2021-05-11 22:56 ` Sergei Dmitrouk
2021-05-14 9:19 ` [edk2-devel] " Laszlo Ersek
2021-05-11 22:56 ` [PATCH v1 2/2] OvmfPkg/VirtioFsDxe: suppress incorrect gcc warnings Sergei Dmitrouk
2021-05-14 10:01 ` [edk2-devel] [PATCH v1 0/2] "maybe-uninitialized" warnings emitted by Laszlo Ersek
2 siblings, 1 reply; 6+ messages in thread
From: Sergei Dmitrouk @ 2021-05-11 22:56 UTC (permalink / raw)
To: devel; +Cc: Ray Ni, Zhichao Gao
`Dupes` is used only if `Duplicates != NULL` and function is left if
allocation of memory for `Dupes` fails, so it can't be used
uninitialized.
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3228
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Sergei Dmitrouk <sergei@posteo.net>
---
ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
index b06d22592d33..81923c8ae737 100644
--- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
+++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
@@ -2128,6 +2128,11 @@ ShellSortFileList (
}
}
+ //
+ // Set Dupes to suppress incorrect compiler/analyzer warnings.
+ //
+ Dupes = NULL;
+
//
// If separation of duplicates has been requested, allocate the list for
// them.
--
2.17.6
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [edk2-devel] [PATCH v1 1/2] ShellPkg/UefiShellCommandLib: suppress incorrect gcc warning
2021-05-11 22:56 ` [PATCH v1 1/2] ShellPkg/UefiShellCommandLib: suppress incorrect gcc warning Sergei Dmitrouk
@ 2021-05-14 9:19 ` Laszlo Ersek
0 siblings, 0 replies; 6+ messages in thread
From: Laszlo Ersek @ 2021-05-14 9:19 UTC (permalink / raw)
To: devel, sergei; +Cc: Ray Ni, Zhichao Gao
On 05/12/21 00:56, Sergei Dmitrouk wrote:
> `Dupes` is used only if `Duplicates != NULL` and function is left if
> allocation of memory for `Dupes` fails, so it can't be used
> uninitialized.
>
> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3228
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Zhichao Gao <zhichao.gao@intel.com>
> Signed-off-by: Sergei Dmitrouk <sergei@posteo.net>
> ---
> ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
> index b06d22592d33..81923c8ae737 100644
> --- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
> +++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
> @@ -2128,6 +2128,11 @@ ShellSortFileList (
> }
> }
>
> + //
> + // Set Dupes to suppress incorrect compiler/analyzer warnings.
> + //
> + Dupes = NULL;
> +
> //
> // If separation of duplicates has been requested, allocate the list for
> // them.
>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v1 2/2] OvmfPkg/VirtioFsDxe: suppress incorrect gcc warnings
2021-05-11 22:56 [PATCH v1 0/2] "maybe-uninitialized" warnings emitted by sergei
2021-05-11 22:56 ` [PATCH v1 1/2] ShellPkg/UefiShellCommandLib: suppress incorrect gcc warning Sergei Dmitrouk
@ 2021-05-11 22:56 ` Sergei Dmitrouk
2021-05-14 9:29 ` [edk2-devel] " Laszlo Ersek
2021-05-14 10:01 ` [edk2-devel] [PATCH v1 0/2] "maybe-uninitialized" warnings emitted by Laszlo Ersek
2 siblings, 1 reply; 6+ messages in thread
From: Sergei Dmitrouk @ 2021-05-11 22:56 UTC (permalink / raw)
To: devel; +Cc: Laszlo Ersek, Ard Biesheuvel, Jordan Justen
`CreateDirectoryIfCreating` is used only if `PermitCreation` is set.
`NewNodeIsDirectory` might not set in case of error, but that would lead
to leaving the function before invalid use.
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3228
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Signed-off-by: Sergei Dmitrouk <sergei@posteo.net>
---
OvmfPkg/VirtioFsDxe/SimpleFsOpen.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c b/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c
index d73d23fe8665..9e46e8ab8385 100644
--- a/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c
+++ b/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c
@@ -332,6 +332,12 @@ VirtioFsSimpleFileOpen (
return EFI_INVALID_PARAMETER;
}
+ //
+ // Set CreateDirectoryIfCreating to suppress incorrect compiler/analyzer
+ // warnings.
+ //
+ CreateDirectoryIfCreating = FALSE;
+
//
// Validate the Attributes requested for the case when the file ends up being
// created, provided creation is permitted.
@@ -426,6 +432,11 @@ VirtioFsSimpleFileOpen (
goto FreeNewCanonicalPath;
}
+ //
+ // Set NewNodeIsDirectory to suppress incorrect compiler/analyzer warnings.
+ //
+ NewNodeIsDirectory = FALSE;
+
//
// Try to open LastComponent directly under DirNodeId, as an existent regular
// file or directory.
--
2.17.6
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [edk2-devel] [PATCH v1 2/2] OvmfPkg/VirtioFsDxe: suppress incorrect gcc warnings
2021-05-11 22:56 ` [PATCH v1 2/2] OvmfPkg/VirtioFsDxe: suppress incorrect gcc warnings Sergei Dmitrouk
@ 2021-05-14 9:29 ` Laszlo Ersek
0 siblings, 0 replies; 6+ messages in thread
From: Laszlo Ersek @ 2021-05-14 9:29 UTC (permalink / raw)
To: devel, sergei; +Cc: Ard Biesheuvel, Jordan Justen
On 05/12/21 00:56, Sergei Dmitrouk wrote:
> `CreateDirectoryIfCreating` is used only if `PermitCreation` is set.
>
> `NewNodeIsDirectory` might not set in case of error, but that would lead
> to leaving the function before invalid use.
>
> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3228
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Signed-off-by: Sergei Dmitrouk <sergei@posteo.net>
> ---
> OvmfPkg/VirtioFsDxe/SimpleFsOpen.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c b/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c
> index d73d23fe8665..9e46e8ab8385 100644
> --- a/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c
> +++ b/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c
> @@ -332,6 +332,12 @@ VirtioFsSimpleFileOpen (
> return EFI_INVALID_PARAMETER;
> }
>
> + //
> + // Set CreateDirectoryIfCreating to suppress incorrect compiler/analyzer
> + // warnings.
> + //
> + CreateDirectoryIfCreating = FALSE;
> +
> //
> // Validate the Attributes requested for the case when the file ends up being
> // created, provided creation is permitted.
> @@ -426,6 +432,11 @@ VirtioFsSimpleFileOpen (
> goto FreeNewCanonicalPath;
> }
>
> + //
> + // Set NewNodeIsDirectory to suppress incorrect compiler/analyzer warnings.
> + //
> + NewNodeIsDirectory = FALSE;
> +
> //
> // Try to open LastComponent directly under DirNodeId, as an existent regular
> // file or directory.
>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [edk2-devel] [PATCH v1 0/2] "maybe-uninitialized" warnings emitted by
2021-05-11 22:56 [PATCH v1 0/2] "maybe-uninitialized" warnings emitted by sergei
2021-05-11 22:56 ` [PATCH v1 1/2] ShellPkg/UefiShellCommandLib: suppress incorrect gcc warning Sergei Dmitrouk
2021-05-11 22:56 ` [PATCH v1 2/2] OvmfPkg/VirtioFsDxe: suppress incorrect gcc warnings Sergei Dmitrouk
@ 2021-05-14 10:01 ` Laszlo Ersek
2 siblings, 0 replies; 6+ messages in thread
From: Laszlo Ersek @ 2021-05-14 10:01 UTC (permalink / raw)
To: sergei; +Cc: devel, Ray Ni, Zhichao Gao
On 05/12/21 00:56, Sergei Dmitrouk wrote:
> Compiling for IA32 target with gcc-5.5.0 emits "maybe-uninitialized" warnings.
> Compilation command: build -a IA32 -p OvmfPkg/OvmfPkgIa32.dsc -t GCC49
>
> Sergei Dmitrouk (2):
> ShellPkg/UefiShellCommandLib: suppress incorrect gcc warning
> OvmfPkg/VirtioFsDxe: suppress incorrect gcc warnings
>
> OvmfPkg/VirtioFsDxe/SimpleFsOpen.c | 11 +++++++++++
> .../Library/UefiShellCommandLib/UefiShellCommandLib.c | 5 +++++
> 2 files changed, 16 insertions(+)
>
Merged as commit range 22ac5cc9d9db..d82c4693f8d5, via
<https://github.com/tianocore/edk2/pull/1643>.
I've gone ahead and merged the ShellPkg patch too, with only my R-b. I
had written the original code, and I've carefully verified Sergei's
patch too. Sergei learned the edk2 contribution process, and got it
right, at the first posting attempt; I wouldn't like to make him wait
several days for a ShellPkg ACK, with such a small patch.
Thanks for the contribution!
Laszlo
^ permalink raw reply [flat|nested] 6+ messages in thread