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 <[email protected]> Cc: Eric Dong <[email protected]> Cc: Paulo Alcantara <[email protected]> Cc: Ruiyu Ni <[email protected]> Cc: Star Zeng <[email protected]> Reported-by: Ard Biesheuvel <[email protected]> Reported-by: Gerd Hoffmann <[email protected]> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <[email protected]> --- MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c index 096fbb4452cb..392494b2eb3f 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: -- 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

