[edk2-devel] [Patch v3] BaseTools: Fix GCC compiler failure in new added tools.
Gary Lin
glin at suse.com
Tue Jul 9 10:19:23 UTC 2019
On Tue, Jul 09, 2019 at 05:53:33PM +0800, Liming Gao wrote:
> From: gaozhic <zhichao.gao at intel.com>
>
> GCC 7 or 8 reports some warnings in new added FCE/FMMT/BlmLib.
>
> Signed-off-by: Liming Gao <liming.gao at intel.com>
> Cc: Bob Feng <bob.c.feng at 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
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#43438): https://edk2.groups.io/g/devel/message/43438
Mute This Topic: https://groups.io/mt/32403705/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list