public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ruiyu" <ruiyu.ni@intel.com>
To: "Zeng, Star" <star.zeng@intel.com>,
	Laszlo Ersek <lersek@redhat.com>,
	edk2-devel-01 <edk2-devel@lists.01.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	"Dong, Eric" <eric.dong@intel.com>,
	Paulo Alcantara <pcacjr@zytor.com>
Subject: Re: [PATCH 3/5] MdeModulePkg/UdfDxe: replace zero-init of local variables with ZeroMem()
Date: Tue, 12 Sep 2017 09:38:58 +0000	[thread overview]
Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BA2C08D@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103B9400FA@shsmsx102.ccr.corp.intel.com>

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 <lersek@redhat.com>; edk2-devel-01 <edk2-
> devel@lists.01.org>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Dong, Eric
> <eric.dong@intel.com>; Paulo Alcantara <pcacjr@zytor.com>; Ni, Ruiyu
> <ruiyu.ni@intel.com>; Zeng, Star <star.zeng@intel.com>
> Subject: RE: [PATCH 3/5] MdeModulePkg/UdfDxe: replace zero-init of local
> variables with ZeroMem()
> 
> Reviewed-by: Star Zeng <star.zeng@intel.com>
> 
> 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 <edk2-devel@lists.01.org>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Dong, Eric
> <eric.dong@intel.com>; Paulo Alcantara <pcacjr@zytor.com>; Ni, Ruiyu
> <ruiyu.ni@intel.com>; Zeng, Star <star.zeng@intel.com>
> 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 <ard.biesheuvel@linaro.org>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Paulo Alcantara <pcacjr@zytor.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>  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
> 



  reply	other threads:[~2017-09-12  9:36 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-10  0:12 [PATCH 0/5] MdeModulePkg: UDF fixes and cleanups Laszlo Ersek
2017-09-10  0:13 ` [PATCH 1/5] MdeModulePkg/UdfDxe: ASSERT() valid ReadFileInfo Flags for INLINE_DATA req Laszlo Ersek
2017-09-10  0:13 ` [PATCH 2/5] MdeModulePkg/UdfDxe: don't return unset Status if INLINE_DATA req succeeds Laszlo Ersek
2017-09-12  9:06   ` Zeng, Star
2017-09-10  0:13 ` [PATCH 3/5] MdeModulePkg/UdfDxe: replace zero-init of local variables with ZeroMem() Laszlo Ersek
2017-09-12  8:55   ` Zeng, Star
2017-09-12  9:38     ` Ni, Ruiyu [this message]
2017-09-12  9:57       ` Laszlo Ersek
2017-09-12 10:02         ` Zeng, Star
2017-09-12  9:55     ` Laszlo Ersek
2017-09-10  0:13 ` [PATCH 4/5] MdeModulePkg/PartitionDxe: don't divide 64-bit values with C operators Laszlo Ersek
2017-09-12  5:41   ` Bi, Dandan
2017-09-12  7:58     ` Laszlo Ersek
2017-09-12  8:28       ` Ni, Ruiyu
2017-09-12  8:46       ` Zeng, Star
2017-09-10  0:13 ` [PATCH 5/5] MdeModulePkg/PartitionDxe: remove always false comparison Laszlo Ersek
2017-09-12  8:50   ` Zeng, Star
2017-09-10  4:24 ` [PATCH 0/5] MdeModulePkg: UDF fixes and cleanups Shi, Steven
2017-09-10  8:38   ` Laszlo Ersek
2017-09-10 13:52     ` Laszlo Ersek
2017-09-10 14:27       ` Shi, Steven
2017-09-10 15:51         ` Paulo Alcantara
2017-09-11  6:58           ` Laszlo Ersek
2017-09-11 13:55             ` Paulo Alcantara
2017-09-11 13:07           ` Shi, Steven
2017-09-11 13:26             ` Ni, Ruiyu
2017-09-11 13:26             ` Laszlo Ersek
2017-09-11 13:52             ` Paulo Alcantara
2017-09-11 14:00               ` Shi, Steven
2017-09-10 15:05 ` Paulo Alcantara
2017-09-11 11:58 ` Ard Biesheuvel
2017-09-12 10:14 ` Laszlo Ersek
2017-09-12 15:38   ` Ard Biesheuvel
2017-09-12 21:29     ` Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=734D49CCEBEEF84792F5B80ED585239D5BA2C08D@SHSMSX104.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox