From: Laszlo Ersek Date: Tue, 12 Sep 2017 21:54:23 +0000 (+0200) Subject: MdeModulePkg/UdfDxe: suppress incorrect compiler warning in ReadFile() X-Git-Tag: edk2-stable201903~3419 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=5afa5b815936e2b45a375b6521764195bed68680 MdeModulePkg/UdfDxe: suppress incorrect compiler warning in ReadFile() 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 . This issue was reported by Ard's and Gerd's CI systems independently. Cc: Ard Biesheuvel Cc: Eric Dong Cc: Paulo Alcantara Cc: Ruiyu Ni Cc: Star Zeng Reported-by: Ard Biesheuvel Reported-by: Gerd Hoffmann Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek Reviewed-by: Star Zeng Reviewed-by: Paulo Alcantara --- diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c index 199c4ca2db..9ec81a6cdc 100644 --- a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c +++ b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c @@ -893,6 +893,11 @@ ReadFile ( LogicalBlockSize = LV_BLOCK_SIZE (Volume, UDF_DEFAULT_LV_NUM); DoFreeAed = FALSE; + // + // set BytesLeft to suppress incorrect compiler/analyzer warnings + // + BytesLeft = 0; + switch (ReadFileInfo->Flags) { case READ_FILE_GET_FILESIZE: case READ_FILE_ALLOCATE_AND_READ: