From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0CCC921E8796F for ; Tue, 12 Sep 2017 01:52:36 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP; 12 Sep 2017 01:55:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,382,1500966000"; d="scan'208";a="1194145191" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga001.fm.intel.com with ESMTP; 12 Sep 2017 01:55:32 -0700 Received: from fmsmsx118.amr.corp.intel.com (10.18.116.18) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 12 Sep 2017 01:55:31 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx118.amr.corp.intel.com (10.18.116.18) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 12 Sep 2017 01:55:31 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.39]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.93]) with mapi id 14.03.0319.002; Tue, 12 Sep 2017 16:55:29 +0800 From: "Zeng, Star" To: Laszlo Ersek , edk2-devel-01 CC: Ard Biesheuvel , "Dong, Eric" , Paulo Alcantara , "Ni, Ruiyu" , "Zeng, Star" Thread-Topic: [PATCH 3/5] MdeModulePkg/UdfDxe: replace zero-init of local variables with ZeroMem() Thread-Index: AQHTKcmdN8xcThbgGkW+ICnus5pg/aKw9epg Date: Tue, 12 Sep 2017 08:55:29 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9400FA@shsmsx102.ccr.corp.intel.com> References: <20170910001304.8628-1-lersek@redhat.com> <20170910001304.8628-4-lersek@redhat.com> In-Reply-To: <20170910001304.8628-4-lersek@redhat.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 3/5] MdeModulePkg/UdfDxe: replace zero-init of local variables with ZeroMem() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Sep 2017 08:52:36 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng BTW: How about to use "sizeof ()" instead of "sizeof"? Thanks, Star -----Original Message----- From: Laszlo Ersek [mailto:lersek@redhat.com]=20 Sent: Sunday, September 10, 2017 8:13 AM To: edk2-devel-01 Cc: Ard Biesheuvel ; Dong, Eric ; Paulo Alcantara ; Ni, Ruiyu ; = Zeng, Star Subject: [PATCH 3/5] MdeModulePkg/UdfDxe: replace zero-init of local variab= les with ZeroMem() In edk2, initialization of local variables is forbidden, both for stylistic= reasons and because such initialization may generate calls to compiler int= rinsics. For the following initialization in UdfRead(): CHAR16 FileName[UDF_FILENAME_LENGTH] =3D { 0 }; clang-3.8 generates a memset() call, when building UdfDxe for IA32, which t= hen fails to link. Replace the initialization with ZeroMem(). Do the same to "FilePath" in UdfOpen(). Cc: Ard Biesheuvel Cc: Eric Dong Cc: Paulo Alcantara Cc: Ruiyu Ni Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek --- 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/Unive= rsal/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] =3D { 0 }; + CHAR16 FilePath[UDF_PATH_LENGTH]; UDF_FILE_INFO File; PRIVATE_UDF_FILE_DATA *NewPrivFileData; CHAR16 *TempFileName; =20 + ZeroMem (FilePath, sizeof FilePath); OldTpl =3D gBS->RaiseTPL (TPL_CALLBACK); =20 if (This =3D=3D NULL || NewHandle =3D=3D NULL || FileName =3D=3D NULL) { Status =3D 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] =3D { 0 }; + CHAR16 FileName[UDF_FILENAME_LENGTH]; UINT64 FileSize; UINT64 BufferSizeUint64; =20 + ZeroMem (FileName, sizeof FileName); OldTpl =3D gBS->RaiseTPL (TPL_CALLBACK); =20 if (This =3D=3D NULL || BufferSize =3D=3D NULL || (*BufferSize !=3D 0 && Buffer =3D=3D NULL)) { Status =3D EFI_INVALID_PARAMETER; -- 2.14.1.3.gb7cf6e02401b