From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (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 57DF620958BD7 for ; Tue, 12 Sep 2017 02:54:35 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8EED15D68A; Tue, 12 Sep 2017 09:57:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8EED15D68A Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=lersek@redhat.com Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-50.rdu2.redhat.com [10.10.120.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08D9A5E1D5; Tue, 12 Sep 2017 09:57:29 +0000 (UTC) To: "Ni, Ruiyu" , "Zeng, Star" , edk2-devel-01 Cc: Ard Biesheuvel , "Dong, Eric" , Paulo Alcantara References: <20170910001304.8628-1-lersek@redhat.com> <20170910001304.8628-4-lersek@redhat.com> <0C09AFA07DD0434D9E2A0C6AEB0483103B9400FA@shsmsx102.ccr.corp.intel.com> <734D49CCEBEEF84792F5B80ED585239D5BA2C08D@SHSMSX104.ccr.corp.intel.com> From: Laszlo Ersek Message-ID: <62218237-d2ee-49c5-7e3d-08381615fef2@redhat.com> Date: Tue, 12 Sep 2017 11:57:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5BA2C08D@SHSMSX104.ccr.corp.intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 12 Sep 2017 09:57:31 +0000 (UTC) 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:54:35 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 09/12/17 11:38, Ni, Ruiyu wrote: > Star, > Sizeof is an operator, not a function, like + or -. Not having () is ok. Ugh, just seeing this now :) So what should I do now? If Star agrees, I would prefer *not* to add the parens. If Star insists, I can add them. Thanks Laszlo >> -----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() >> >> Reviewed-by: Star Zeng >> >> BTW: How about to use "sizeof ()" instead of "sizeof"? >> >> >> 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() >> >> 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 >> 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/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 >> >