From: "Gary Lin" <glin@suse.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
"liming.gao@intel.com" <liming.gao@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>, gaozhic <zhichao.gao@intel.com>
Subject: Re: [edk2-devel] [Patch v3] BaseTools: Fix GCC compiler failure in new added tools.
Date: Tue, 9 Jul 2019 10:19:23 +0000 [thread overview]
Message-ID: <20190709101912.GE5004@GaryWorkstation> (raw)
In-Reply-To: <1562666013-13188-1-git-send-email-liming.gao@intel.com>
On Tue, Jul 09, 2019 at 05:53:33PM +0800, Liming Gao wrote:
> From: gaozhic <zhichao.gao@intel.com>
>
> GCC 7 or 8 reports some warnings in new added FCE/FMMT/BlmLib.
>
> Signed-off-by: Liming Gao <liming.gao@intel.com>
> Cc: Bob Feng <bob.c.feng@intel.com>
> ---
> In V2:
> Fix GCC8 compiler issue.
>
> In V3:
> Fix snprintf wrong replacement.
>
> BaseTools/Source/C/BfmLib/BfmLib.c | 117 +++++++++++----------
> BaseTools/Source/C/FCE/BinaryParse.c | 2 +-
> BaseTools/Source/C/FMMT/FirmwareModuleManagement.c | 2 +-
> BaseTools/Source/C/FMMT/FmmtLib.c | 117 +++++++++++----------
> 4 files changed, 122 insertions(+), 116 deletions(-)
>
-->8--
> diff --git a/BaseTools/Source/C/FCE/BinaryParse.c b/BaseTools/Source/C/FCE/BinaryParse.c
> index e9f8ee6826..97d6ecf93b 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, "%s%c%s", FolderName, OS_SEP, pDirent->d_name);
> FfsFile = fopen (FileNameArry, "rb");
> Status = ReadFfsHeader (FfsFile, (UINT32 *)&FileSize);
> if (EFI_ERROR (Status)) {
I got a new warning after applying this patch:
BinaryParse.c: In function ‘FindFileInFolder’:
BinaryParse.c:1243:54: error: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 199 [-Werror=format-truncation=]
1243 | snprintf (FileNameArry, MAX_FILENAME_LEN, "%s%c%s", FolderName, OS_SEP, pDirent->d_name);
| ^~
BinaryParse.c:1243:7: note: ‘snprintf’ output 2 or more bytes (assuming 257) into a destination of size 200
1243 | snprintf (FileNameArry, MAX_FILENAME_LEN, "%s%c%s", FolderName, OS_SEP, pDirent->d_name);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Gary Lin
next prev parent reply other threads:[~2019-07-09 10:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-09 9:53 [Patch v3] BaseTools: Fix GCC compiler failure in new added tools Liming Gao
2019-07-09 10:19 ` Gary Lin [this message]
2019-07-09 18:26 ` [edk2-devel] " Leif Lindholm
2019-07-10 13:42 ` Liming Gao
2019-07-10 20:10 ` Michael D Kinney
2019-07-11 1:47 ` Liming Gao
2019-07-10 20:57 ` Leif Lindholm
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=20190709101912.GE5004@GaryWorkstation \
--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