From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.85.221.65, mailfrom: philmd@redhat.com) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by groups.io with SMTP; Mon, 08 Jul 2019 08:49:19 -0700 Received: by mail-wr1-f65.google.com with SMTP id g17so7552462wrr.5 for ; Mon, 08 Jul 2019 08:49:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=uVmQWYBRtiX6nBTMAn4kAjTaUBCvf9kpuNGmnZGvBog=; b=nXJMIKAGdJY8PUOmQa7yV2qOwIPw1SL619zOXuabhcH2szMJfuR7LbU2rJck72N4G4 9xrNcSNYwoIl1mUhw1Q2nv8KoXjpN7jaddfKiUg89J2nypNWwitYokT3KpcFMR6M9xz/ ch4InpXkZf1TrXICxJ3mUaT8s+RDuI7qrt91tTybf0giAIsyEwfMCrAvXgsqs8+ch3Zt 7CoBitAdGGYv3wc4ST+gG38slB8IKEZKvYr9GyCRBMnsOo0yW8qBUXis2bUOJXCZq+Tx RfSsaAoevL03XXCtej6/bXRgUpknVMW5A9yiWekJQouslgSkIHFSNfLeaTNXtSkS3Ute Y+XQ== X-Gm-Message-State: APjAAAW1HGrxl4Kobm0OsNTuolPDJMpBXcOJXDYY76cVmiHugyPJ3XZv 1eQ3yZ2D9zRsAktZ9JceLPNZ7w== X-Google-Smtp-Source: APXvYqy6I40Q+T89TXnBCpmI6nfR4btvldPYF/DW4+oLhjjj2Z7tVEtsWPUG1aoF7vcwXsATBPML9w== X-Received: by 2002:adf:b64b:: with SMTP id i11mr481693wre.205.1562600957837; Mon, 08 Jul 2019 08:49:17 -0700 (PDT) Return-Path: Received: from [192.168.1.38] (56.red-88-18-140.staticip.rima-tde.net. [88.18.140.56]) by smtp.gmail.com with ESMTPSA id w23sm19303789wmi.45.2019.07.08.08.49.16 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Mon, 08 Jul 2019 08:49:17 -0700 (PDT) Subject: Re: [edk2-devel] [Patch] BaseTools: Fix GCC compiler failure in new added tools. To: devel@edk2.groups.io, liming.gao@intel.com Cc: gaozhic , Bob Feng References: <1562313092-8576-1-git-send-email-liming.gao@intel.com> From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= Openpgp: id=89C1E78F601EE86C867495CBA2A3FD6EDEADC0DE; url=http://pgp.mit.edu/pks/lookup?op=get&search=0xA2A3FD6EDEADC0DE Message-ID: <37396fda-80e1-b094-97ce-076f06ec9cb5@redhat.com> Date: Mon, 8 Jul 2019 17:49:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <1562313092-8576-1-git-send-email-liming.gao@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Hi, On 7/5/19 9:51 AM, Liming Gao wrote: > From: gaozhic > > GCC 7 or 8 reports some warnings in new added FCE/FMMT/BlmLib. > > Signed-off-by: Liming Gao > Cc: Bob Feng > --- > BaseTools/Source/C/BfmLib/BfmLib.c | 2 +- > BaseTools/Source/C/FCE/BinaryParse.c | 2 +- > BaseTools/Source/C/FMMT/FirmwareModuleManagement.c | 2 +- > BaseTools/Source/C/FMMT/FmmtLib.c | 2 +- > 4 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/BaseTools/Source/C/BfmLib/BfmLib.c b/BaseTools/Source/C/BfmLib/BfmLib.c > index 9dedda3da2..5b7d5859fd 100644 > --- a/BaseTools/Source/C/BfmLib/BfmLib.c > +++ b/BaseTools/Source/C/BfmLib/BfmLib.c > @@ -116,7 +116,7 @@ LibInitializeFvStruct ( > > for (Index = 0; Index < MAX_NUMBER_OF_FILES_IN_FV; Index ++) { > memset (Fv->FfsAttuibutes[Index].FfsName, '\0', _MAX_PATH); > - memset (Fv->FfsAttuibutes[Index].UiName, '\0', _MAX_PATH); > + memset (Fv->FfsAttuibutes[Index].UiName, '\0', _MAX_PATH * sizeof (CHAR16)); What about using wmemset() here? (I'm not sure it would be correct, I just wonder). > > Fv->FfsAttuibutes[Index].IsLeaf = TRUE; > Fv->FfsAttuibutes[Index].TotalSectionNum = 0; > diff --git a/BaseTools/Source/C/FCE/BinaryParse.c b/BaseTools/Source/C/FCE/BinaryParse.c > index e9f8ee6826..3321963cb8 100644 > --- a/BaseTools/Source/C/FCE/BinaryParse.c > +++ b/BaseTools/Source/C/FCE/BinaryParse.c > @@ -1240,7 +1240,7 @@ Done: > ) { > continue; > } > - sprintf (FileNameArry, "%s%c%s", FolderName, OS_SEP, pDirent->d_name); > + snprintf (FileNameArry, MAX_FILENAME_LEN, FolderName, OS_SEP, pDirent->d_name); You dropped the format string... > FfsFile = fopen (FileNameArry, "rb"); > Status = ReadFfsHeader (FfsFile, (UINT32 *)&FileSize); > if (EFI_ERROR (Status)) { > diff --git a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c b/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c > index 63ae3c45a4..6648fbd54f 100644 > --- a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c > +++ b/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c > @@ -1572,7 +1572,7 @@ FmmtImageDelete ( > // If decrease operation executed, we should adjust the ffs list. It will bring in more complex. > // > //FvInFd->FfsNumbers -= 1; > - memset(FvInFd->FfsAttuibutes[Index].UiName, '\0', _MAX_PATH); > + memset(FvInFd->FfsAttuibutes[Index].UiName, '\0', _MAX_PATH * sizeof (CHAR16)); > if (FvInFd->FfsAttuibutes[Index].FvLevel > 1) { > for (j = Index - 1; j >= 0; j--) { > if (FvInFd->FfsAttuibutes[j].FvLevel == FvInFd->FfsAttuibutes[Index].FvLevel - 1) { > diff --git a/BaseTools/Source/C/FMMT/FmmtLib.c b/BaseTools/Source/C/FMMT/FmmtLib.c > index f87042114b..e477a52987 100644 > --- a/BaseTools/Source/C/FMMT/FmmtLib.c > +++ b/BaseTools/Source/C/FMMT/FmmtLib.c > @@ -155,7 +155,7 @@ LibInitializeFvStruct ( > > for (Index = 0; Index < MAX_NUMBER_OF_FILES_IN_FV; Index ++) { > memset (Fv->FfsAttuibutes[Index].FfsName, '\0', _MAX_PATH); > - memset (Fv->FfsAttuibutes[Index].UiName, '\0', _MAX_PATH); > + memset (Fv->FfsAttuibutes[Index].UiName, '\0', _MAX_PATH * sizeof (CHAR16)); > memset (&Fv->FfsAttuibutes[Index].GuidName, '\0', sizeof(EFI_GUID)); > Fv->FfsAttuibutes[Index].UiNameSize = 0; > Fv->FfsAttuibutes[Index].IsLeaf = TRUE; >