]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/UdfDxe: suppress incorrect compiler warning in ReadFile()
authorLaszlo Ersek <lersek@redhat.com>
Tue, 12 Sep 2017 21:54:23 +0000 (23:54 +0200)
committerLaszlo Ersek <lersek@redhat.com>
Wed, 13 Sep 2017 22:05:20 +0000 (00:05 +0200)
When building the driver for DEBUG/RELEASE, GCC48/GCC49 warn about
ReadFile() possibly using "BytesLeft" without initializing it first.

This is not the case. The reads of "BytesLeft" are only reachable if
(ReadFileInfo->Flags == READ_FILE_SEEK_AND_READ). But, in that case, we
also set "BytesLeft" to "ReadFileInfo->FileDataSize", near the top of the
function.

Assign "BytesLeft" zero at the top, and add a comment that conforms to the
pending Coding Style Spec feature request at
<https://bugzilla.tianocore.org/show_bug.cgi?id=607>.

This issue was reported by Ard's and Gerd's CI systems independently.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Paulo Alcantara <pcacjr@zytor.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reported-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reported-by: Gerd Hoffmann <kraxel@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Paulo Alcantara <pcacjr@zytor.com>
MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c

index 199c4ca2db2de903195e84b15edb781a9dfe9ed4..9ec81a6cdcb4b0741b7a77c2e2b95e9b4fde087c 100644 (file)
@@ -893,6 +893,11 @@ ReadFile (
   LogicalBlockSize  = LV_BLOCK_SIZE (Volume, UDF_DEFAULT_LV_NUM);\r
   DoFreeAed         = FALSE;\r
 \r
   LogicalBlockSize  = LV_BLOCK_SIZE (Volume, UDF_DEFAULT_LV_NUM);\r
   DoFreeAed         = FALSE;\r
 \r
+  //\r
+  // set BytesLeft to suppress incorrect compiler/analyzer warnings\r
+  //\r
+  BytesLeft = 0;\r
+\r
   switch (ReadFileInfo->Flags) {\r
   case READ_FILE_GET_FILESIZE:\r
   case READ_FILE_ALLOCATE_AND_READ:\r
   switch (ReadFileInfo->Flags) {\r
   case READ_FILE_GET_FILESIZE:\r
   case READ_FILE_ALLOCATE_AND_READ:\r