From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 C845420958BD7 for ; Tue, 12 Sep 2017 02:36:05 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Sep 2017 02:39:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,382,1500966000"; d="scan'208";a="1013519125" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga003.jf.intel.com with ESMTP; 12 Sep 2017 02:39:01 -0700 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 12 Sep 2017 02:39:01 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 12 Sep 2017 02:39:00 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.117]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.93]) with mapi id 14.03.0319.002; Tue, 12 Sep 2017 17:38:59 +0800 From: "Ni, Ruiyu" To: "Zeng, Star" , Laszlo Ersek , edk2-devel-01 CC: Ard Biesheuvel , "Dong, Eric" , Paulo Alcantara Thread-Topic: [PATCH 3/5] MdeModulePkg/UdfDxe: replace zero-init of local variables with ZeroMem() Thread-Index: AQHTKcmd+g70xbQ4LUKAAQ+85p/UrKKwcBSAgACSFvA= Date: Tue, 12 Sep 2017 09:38:58 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BA2C08D@SHSMSX104.ccr.corp.intel.com> References: <20170910001304.8628-1-lersek@redhat.com> <20170910001304.8628-4-lersek@redhat.com> <0C09AFA07DD0434D9E2A0C6AEB0483103B9400FA@shsmsx102.ccr.corp.intel.com> In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103B9400FA@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US, zh-CN 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 09:36:06 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Star, Sizeof is an operator, not a function, like + or -. Not having () is ok. Thanks/Ray > -----Original Message----- > From: Zeng, Star > Sent: Tuesday, September 12, 2017 4:55 PM > To: Laszlo Ersek ; edk2-devel-01 devel@lists.01.org> > Cc: Ard Biesheuvel ; Dong, Eric > ; Paulo Alcantara ; Ni, Ruiyu > ; Zeng, Star > Subject: RE: [PATCH 3/5] MdeModulePkg/UdfDxe: replace zero-init of local > variables with ZeroMem() >=20 > Reviewed-by: Star Zeng >=20 > BTW: How about to use "sizeof ()" instead of "sizeof"? >=20 >=20 > Thanks, > Star > -----Original Message----- > From: Laszlo Ersek [mailto:lersek@redhat.com] > 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 > variables with ZeroMem() >=20 > In edk2, initialization of local variables is forbidden, both for stylist= ic reasons > and because such initialization may generate calls to compiler intrinsics= . >=20 > For the following initialization in UdfRead(): >=20 > CHAR16 FileName[UDF_FILENAME_LENGTH] =3D { 0 }= ; >=20 > clang-3.8 generates a memset() call, when building UdfDxe for IA32, which > then fails to link. >=20 > Replace the initialization with ZeroMem(). >=20 > Do the same to "FilePath" in UdfOpen(). >=20 > 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(-) >=20 > 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] =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 >=20