]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/VirtioFsDxe: suppress incorrect gcc warnings
authorSergei Dmitrouk <sergei@posteo.net>
Tue, 11 May 2021 22:56:16 +0000 (22:56 +0000)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 14 May 2021 10:00:13 +0000 (10:00 +0000)
`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>
Message-Id: <20210511225616.5942-3-sergei@posteo.net>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
OvmfPkg/VirtioFsDxe/SimpleFsOpen.c

index d73d23fe866568f59b7c8347dca3229c13709d15..9e46e8ab83852dfc41ac1b17757eb57b12da3daf 100644 (file)
@@ -332,6 +332,12 @@ VirtioFsSimpleFileOpen (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  //\r
+  // Set CreateDirectoryIfCreating to suppress incorrect compiler/analyzer\r
+  // warnings.\r
+  //\r
+  CreateDirectoryIfCreating = FALSE;\r
+\r
   //\r
   // Validate the Attributes requested for the case when the file ends up being\r
   // created, provided creation is permitted.\r
@@ -426,6 +432,11 @@ VirtioFsSimpleFileOpen (
     goto FreeNewCanonicalPath;\r
   }\r
 \r
+  //\r
+  // Set NewNodeIsDirectory to suppress incorrect compiler/analyzer warnings.\r
+  //\r
+  NewNodeIsDirectory = FALSE;\r
+\r
   //\r
   // Try to open LastComponent directly under DirNodeId, as an existent regular\r
   // file or directory.\r