Reviewed-by: Star Zeng <[email protected]> BTW: How about to use "sizeof ()" instead of "sizeof"?
Thanks, Star -----Original Message----- From: Laszlo Ersek [mailto:[email protected]] Sent: Sunday, September 10, 2017 8:13 AM To: edk2-devel-01 <[email protected]> Cc: Ard Biesheuvel <[email protected]>; Dong, Eric <[email protected]>; Paulo Alcantara <[email protected]>; Ni, Ruiyu <[email protected]>; Zeng, Star <[email protected]> Subject: [PATCH 3/5] MdeModulePkg/UdfDxe: replace zero-init of local variables with ZeroMem() In edk2, initialization of local variables is forbidden, both for stylistic reasons and because such initialization may generate calls to compiler intrinsics. For the following initialization in UdfRead(): CHAR16 FileName[UDF_FILENAME_LENGTH] = { 0 }; clang-3.8 generates a memset() call, when building UdfDxe for IA32, which then fails to link. Replace the initialization with ZeroMem(). Do the same to "FilePath" in UdfOpen(). 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]> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <[email protected]> --- MdeModulePkg/Universal/Disk/UdfDxe/File.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/File.c b/MdeModulePkg/Universal/Disk/UdfDxe/File.c index 8b9339567f8e..e7159ff861f7 100644 --- a/MdeModulePkg/Universal/Disk/UdfDxe/File.c +++ b/MdeModulePkg/Universal/Disk/UdfDxe/File.c @@ -174,15 +174,16 @@ UdfOpen ( { EFI_TPL OldTpl; EFI_STATUS Status; PRIVATE_UDF_FILE_DATA *PrivFileData; PRIVATE_UDF_SIMPLE_FS_DATA *PrivFsData; - CHAR16 FilePath[UDF_PATH_LENGTH] = { 0 }; + CHAR16 FilePath[UDF_PATH_LENGTH]; UDF_FILE_INFO File; PRIVATE_UDF_FILE_DATA *NewPrivFileData; CHAR16 *TempFileName; + ZeroMem (FilePath, sizeof FilePath); OldTpl = gBS->RaiseTPL (TPL_CALLBACK); if (This == NULL || NewHandle == NULL || FileName == NULL) { Status = EFI_INVALID_PARAMETER; goto Error_Invalid_Params; @@ -322,14 +323,15 @@ UdfRead ( EFI_BLOCK_IO_PROTOCOL *BlockIo; EFI_DISK_IO_PROTOCOL *DiskIo; UDF_FILE_INFO FoundFile; UDF_FILE_IDENTIFIER_DESCRIPTOR *NewFileIdentifierDesc; VOID *NewFileEntryData; - CHAR16 FileName[UDF_FILENAME_LENGTH] = { 0 }; + CHAR16 FileName[UDF_FILENAME_LENGTH]; UINT64 FileSize; UINT64 BufferSizeUint64; + ZeroMem (FileName, sizeof FileName); OldTpl = gBS->RaiseTPL (TPL_CALLBACK); if (This == NULL || BufferSize == NULL || (*BufferSize != 0 && Buffer == NULL)) { Status = EFI_INVALID_PARAMETER; -- 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

