diff mbox series

arm/recipes-bsp/uefi/edk2-firmware: cherry pick gcc 12.x compatibility patches

Message ID f63e9b72de6922682206b4315af8ca9af6f2522e.1659084730.git.maciek@thing.com
State New
Headers show
Series arm/recipes-bsp/uefi/edk2-firmware: cherry pick gcc 12.x compatibility patches | expand

Commit Message

Maciej Borzecki July 29, 2022, 8:58 a.m. UTC
Cherry pick gcc 12.x compatibility patches from the upstream.

Signed-off-by: Maciej Borzecki <maciek@thing.com>
---
 meta-arm/recipes-bsp/uefi/edk2-firmware.inc   |  3 ++
 ...001-Basetools-turn-off-gcc12-warning.patch | 37 +++++++++++++++
 .../0002-BaseTools-fix-gcc12-warning.patch    | 47 +++++++++++++++++++
 .../0003-BaseTools-fix-gcc12-warning.patch    | 45 ++++++++++++++++++
 4 files changed, 132 insertions(+)
 create mode 100644 meta-arm/recipes-bsp/uefi/files/0001-Basetools-turn-off-gcc12-warning.patch
 create mode 100644 meta-arm/recipes-bsp/uefi/files/0002-BaseTools-fix-gcc12-warning.patch
 create mode 100644 meta-arm/recipes-bsp/uefi/files/0003-BaseTools-fix-gcc12-warning.patch

Comments

Ross Burton July 29, 2022, 10:10 a.m. UTC | #1
Hi,

Thanks for the patch.

The subject should just start with "arm/edk2-firmware:", and each of the patches you’re adding need an Upstream-Status tag (in this case, Upstream-Status: Backport), and *your* Signed-off-by.

Thanks,
Ross

> On 29 Jul 2022, at 09:58, Maciej Borzęcki via lists.yoctoproject.org <maciek=thing.com@lists.yoctoproject.org> wrote:
> 
> Cherry pick gcc 12.x compatibility patches from the upstream.
> 
> Signed-off-by: Maciej Borzecki <maciek@thing.com>
> ---
> meta-arm/recipes-bsp/uefi/edk2-firmware.inc   |  3 ++
> ...001-Basetools-turn-off-gcc12-warning.patch | 37 +++++++++++++++
> .../0002-BaseTools-fix-gcc12-warning.patch    | 47 +++++++++++++++++++
> .../0003-BaseTools-fix-gcc12-warning.patch    | 45 ++++++++++++++++++
> 4 files changed, 132 insertions(+)
> create mode 100644 meta-arm/recipes-bsp/uefi/files/0001-Basetools-turn-off-gcc12-warning.patch
> create mode 100644 meta-arm/recipes-bsp/uefi/files/0002-BaseTools-fix-gcc12-warning.patch
> create mode 100644 meta-arm/recipes-bsp/uefi/files/0003-BaseTools-fix-gcc12-warning.patch
> 
> diff --git a/meta-arm/recipes-bsp/uefi/edk2-firmware.inc b/meta-arm/recipes-bsp/uefi/edk2-firmware.inc
> index 540eb00cb0972761ee2addfe78d9ab51e4ba3e73..0a6ae277a1de7d20cc1a9c5b9984b19fb489e7ef 100644
> --- a/meta-arm/recipes-bsp/uefi/edk2-firmware.inc
> +++ b/meta-arm/recipes-bsp/uefi/edk2-firmware.inc
> @@ -18,6 +18,9 @@ SRC_URI = "\
>     ${EDK2_SRC_URI};name=edk2;destsuffix=edk2;nobranch=1 \
>     ${EDK2_PLATFORMS_SRC_URI};name=edk2-platforms;destsuffix=edk2/edk2-platforms;nobranch=1 \
>     file://unaligned.patch \
> +    file://0001-Basetools-turn-off-gcc12-warning.patch \
> +    file://0002-BaseTools-fix-gcc12-warning.patch \
> +    file://0003-BaseTools-fix-gcc12-warning.patch \
> "
> 
> SRCREV_FORMAT         = "edk2_edk2-platforms"
> diff --git a/meta-arm/recipes-bsp/uefi/files/0001-Basetools-turn-off-gcc12-warning.patch b/meta-arm/recipes-bsp/uefi/files/0001-Basetools-turn-off-gcc12-warning.patch
> new file mode 100644
> index 0000000000000000000000000000000000000000..e63a79338586c259f26afeb734daa234ab384e4f
> --- /dev/null
> +++ b/meta-arm/recipes-bsp/uefi/files/0001-Basetools-turn-off-gcc12-warning.patch
> @@ -0,0 +1,37 @@
> +From 22130dcd98b4d4b76ac8d922adb4a2dbc86fa52c Mon Sep 17 00:00:00 2001
> +From: Gerd Hoffmann <kraxel@redhat.com>
> +Date: Thu, 24 Mar 2022 20:04:36 +0800
> +Subject: [PATCH] Basetools: turn off gcc12 warning
> +
> +In function ?SetDevicePathEndNode?,
> +    inlined from ?FileDevicePath? at DevicePathUtilities.c:857:5:
> +DevicePathUtilities.c:321:3: error: writing 4 bytes into a region of size 1 [-Werror=stringop-overflow=]
> +  321 |   memcpy (Node, &mUefiDevicePathLibEndDevicePath, sizeof (mUefiDevicePathLibEndDevicePath));
> +      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +In file included from UefiDevicePathLib.h:22,
> +                 from DevicePathUtilities.c:16:
> +../Include/Protocol/DevicePath.h: In function ?FileDevicePath?:
> +../Include/Protocol/DevicePath.h:51:9: note: destination object ?Type? of size 1
> +   51 |   UINT8 Type;       ///< 0x01 Hardware Device Path.
> +      |         ^~~~
> +
> +Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> +Reviewed-by: Bob Feng <bob.c.feng@intel.com>
> +---
> + BaseTools/Source/C/DevicePath/GNUmakefile | 3 +++
> + 1 file changed, 3 insertions(+)
> +
> +diff --git a/BaseTools/Source/C/DevicePath/GNUmakefile b/BaseTools/Source/C/DevicePath/GNUmakefile
> +index 7ca08af9662d..b05d2bddfa68 100644
> +--- a/BaseTools/Source/C/DevicePath/GNUmakefile
> ++++ b/BaseTools/Source/C/DevicePath/GNUmakefile
> +@@ -13,6 +13,9 @@ OBJECTS = DevicePath.o UefiDevicePathLib.o DevicePathFromText.o  DevicePathUtili
> + 
> + include $(MAKEROOT)/Makefiles/app.makefile
> + 
> ++# gcc 12 trips over device path handling
> ++BUILD_CFLAGS += -Wno-error=stringop-overflow
> ++
> + LIBS = -lCommon
> + ifeq ($(CYGWIN), CYGWIN)
> +   LIBS += -L/lib/e2fsprogs -luuid
> diff --git a/meta-arm/recipes-bsp/uefi/files/0002-BaseTools-fix-gcc12-warning.patch b/meta-arm/recipes-bsp/uefi/files/0002-BaseTools-fix-gcc12-warning.patch
> new file mode 100644
> index 0000000000000000000000000000000000000000..22297c67bb6ca798f4b177867d99610294320cc8
> --- /dev/null
> +++ b/meta-arm/recipes-bsp/uefi/files/0002-BaseTools-fix-gcc12-warning.patch
> @@ -0,0 +1,47 @@
> +From 85021f8cf22d1bd4114803c6c610dea5ef0059f1 Mon Sep 17 00:00:00 2001
> +From: Gerd Hoffmann <kraxel@redhat.com>
> +Date: Thu, 24 Mar 2022 20:04:35 +0800
> +Subject: [PATCH] BaseTools: fix gcc12 warning
> +
> +Sdk/C/LzmaEnc.c: In function ?LzmaEnc_CodeOneMemBlock?:
> +Sdk/C/LzmaEnc.c:2828:19: error: storing the address of local variable ?outStream? in ?*p.rc.outStream? [-Werror=dangling-pointer=]
> + 2828 |   p->rc.outStream = &outStream.vt;
> +      |   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
> +Sdk/C/LzmaEnc.c:2811:28: note: ?outStream? declared here
> + 2811 |   CLzmaEnc_SeqOutStreamBuf outStream;
> +      |                            ^~~~~~~~~
> +Sdk/C/LzmaEnc.c:2811:28: note: ?pp? declared here
> +Sdk/C/LzmaEnc.c:2828:19: error: storing the address of local variable ?outStream? in ?*(CLzmaEnc *)pp.rc.outStream? [-Werror=dangling-pointer=]
> + 2828 |   p->rc.outStream = &outStream.vt;
> +      |   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
> +Sdk/C/LzmaEnc.c:2811:28: note: ?outStream? declared here
> + 2811 |   CLzmaEnc_SeqOutStreamBuf outStream;
> +      |                            ^~~~~~~~~
> +Sdk/C/LzmaEnc.c:2811:28: note: ?pp? declared here
> +cc1: all warnings being treated as errors
> +
> +Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> +Reviewed-by: Bob Feng <bob.c.feng@intel.com>
> +---
> + BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c | 3 ++-
> + 1 file changed, 2 insertions(+), 1 deletion(-)
> +
> +diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
> +index 4e9b499f8d80..4b9f5fa69248 100644
> +--- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
> ++++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
> +@@ -2825,12 +2825,13 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit,
> + 
> +   nowPos64 = p->nowPos64;
> +   RangeEnc_Init(&p->rc);
> +-  p->rc.outStream = &outStream.vt;
> + 
> +   if (desiredPackSize == 0)
> +     return SZ_ERROR_OUTPUT_EOF;
> + 
> ++  p->rc.outStream = &outStream.vt;
> +   res = LzmaEnc_CodeOneBlock(p, desiredPackSize, *unpackSize);
> ++  p->rc.outStream = NULL;
> + 
> +   *unpackSize = (UInt32)(p->nowPos64 - nowPos64);
> +   *destLen -= outStream.rem;
> diff --git a/meta-arm/recipes-bsp/uefi/files/0003-BaseTools-fix-gcc12-warning.patch b/meta-arm/recipes-bsp/uefi/files/0003-BaseTools-fix-gcc12-warning.patch
> new file mode 100644
> index 0000000000000000000000000000000000000000..77e1d97b2f57820fbe96b7309782fc89690457d2
> --- /dev/null
> +++ b/meta-arm/recipes-bsp/uefi/files/0003-BaseTools-fix-gcc12-warning.patch
> @@ -0,0 +1,45 @@
> +From 7b005f344e533cd913c3ca05b266f9872df886d1 Mon Sep 17 00:00:00 2001
> +From: Gerd Hoffmann <kraxel@redhat.com>
> +Date: Thu, 24 Mar 2022 20:04:34 +0800
> +Subject: [PATCH] BaseTools: fix gcc12 warning
> +
> +GenFfs.c:545:5: error: pointer ?InFileHandle? used after ?fclose? [-Werror=use-after-free]
> +  545 |     Error(NULL, 0, 4001, "Resource", "memory cannot be allocated  of %s", InFileHandle);
> +      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +GenFfs.c:544:5: note: call to ?fclose? here
> +  544 |     fclose (InFileHandle);
> +      |     ^~~~~~~~~~~~~~~~~~~~~
> +
> +Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> +Reviewed-by: Bob Feng <bob.c.feng@intel.com>
> +---
> + BaseTools/Source/C/GenFfs/GenFfs.c | 2 +-
> + BaseTools/Source/C/GenSec/GenSec.c | 2 +-
> + 2 files changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/BaseTools/Source/C/GenFfs/GenFfs.c b/BaseTools/Source/C/GenFfs/GenFfs.c
> +index 949025c33325..d78d62ab3689 100644
> +--- a/BaseTools/Source/C/GenFfs/GenFfs.c
> ++++ b/BaseTools/Source/C/GenFfs/GenFfs.c
> +@@ -542,7 +542,7 @@ GetAlignmentFromFile(char *InFile, UINT32 *Alignment)
> +   PeFileBuffer = (UINT8 *) malloc (PeFileSize);
> +   if (PeFileBuffer == NULL) {
> +     fclose (InFileHandle);
> +-    Error(NULL, 0, 4001, "Resource", "memory cannot be allocated  of %s", InFileHandle);
> ++    Error(NULL, 0, 4001, "Resource", "memory cannot be allocated for %s", InFile);
> +     return EFI_OUT_OF_RESOURCES;
> +   }
> +   fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle);
> +diff --git a/BaseTools/Source/C/GenSec/GenSec.c b/BaseTools/Source/C/GenSec/GenSec.c
> +index d54a4f9e0a7d..b1d05367ec0b 100644
> +--- a/BaseTools/Source/C/GenSec/GenSec.c
> ++++ b/BaseTools/Source/C/GenSec/GenSec.c
> +@@ -1062,7 +1062,7 @@ GetAlignmentFromFile(char *InFile, UINT32 *Alignment)
> +   PeFileBuffer = (UINT8 *) malloc (PeFileSize);
> +   if (PeFileBuffer == NULL) {
> +     fclose (InFileHandle);
> +-    Error(NULL, 0, 4001, "Resource", "memory cannot be allocated  of %s", InFileHandle);
> ++    Error(NULL, 0, 4001, "Resource", "memory cannot be allocated for %s", InFile);
> +     return EFI_OUT_OF_RESOURCES;
> +   }
> +   fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle);
> -- 
> 2.37.1
> 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#3608): https://lists.yoctoproject.org/g/meta-arm/message/3608
> Mute This Topic: https://lists.yoctoproject.org/mt/92687028/6875888
> Group Owner: meta-arm+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/meta-arm/unsub [ross.burton@arm.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta-arm/recipes-bsp/uefi/edk2-firmware.inc b/meta-arm/recipes-bsp/uefi/edk2-firmware.inc
index 540eb00cb0972761ee2addfe78d9ab51e4ba3e73..0a6ae277a1de7d20cc1a9c5b9984b19fb489e7ef 100644
--- a/meta-arm/recipes-bsp/uefi/edk2-firmware.inc
+++ b/meta-arm/recipes-bsp/uefi/edk2-firmware.inc
@@ -18,6 +18,9 @@  SRC_URI = "\
     ${EDK2_SRC_URI};name=edk2;destsuffix=edk2;nobranch=1 \
     ${EDK2_PLATFORMS_SRC_URI};name=edk2-platforms;destsuffix=edk2/edk2-platforms;nobranch=1 \
     file://unaligned.patch \
+    file://0001-Basetools-turn-off-gcc12-warning.patch \
+    file://0002-BaseTools-fix-gcc12-warning.patch \
+    file://0003-BaseTools-fix-gcc12-warning.patch \
 "
 
 SRCREV_FORMAT         = "edk2_edk2-platforms"
diff --git a/meta-arm/recipes-bsp/uefi/files/0001-Basetools-turn-off-gcc12-warning.patch b/meta-arm/recipes-bsp/uefi/files/0001-Basetools-turn-off-gcc12-warning.patch
new file mode 100644
index 0000000000000000000000000000000000000000..e63a79338586c259f26afeb734daa234ab384e4f
--- /dev/null
+++ b/meta-arm/recipes-bsp/uefi/files/0001-Basetools-turn-off-gcc12-warning.patch
@@ -0,0 +1,37 @@ 
+From 22130dcd98b4d4b76ac8d922adb4a2dbc86fa52c Mon Sep 17 00:00:00 2001
+From: Gerd Hoffmann <kraxel@redhat.com>
+Date: Thu, 24 Mar 2022 20:04:36 +0800
+Subject: [PATCH] Basetools: turn off gcc12 warning
+
+In function ?SetDevicePathEndNode?,
+    inlined from ?FileDevicePath? at DevicePathUtilities.c:857:5:
+DevicePathUtilities.c:321:3: error: writing 4 bytes into a region of size 1 [-Werror=stringop-overflow=]
+  321 |   memcpy (Node, &mUefiDevicePathLibEndDevicePath, sizeof (mUefiDevicePathLibEndDevicePath));
+      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+In file included from UefiDevicePathLib.h:22,
+                 from DevicePathUtilities.c:16:
+../Include/Protocol/DevicePath.h: In function ?FileDevicePath?:
+../Include/Protocol/DevicePath.h:51:9: note: destination object ?Type? of size 1
+   51 |   UINT8 Type;       ///< 0x01 Hardware Device Path.
+      |         ^~~~
+
+Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
+Reviewed-by: Bob Feng <bob.c.feng@intel.com>
+---
+ BaseTools/Source/C/DevicePath/GNUmakefile | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/BaseTools/Source/C/DevicePath/GNUmakefile b/BaseTools/Source/C/DevicePath/GNUmakefile
+index 7ca08af9662d..b05d2bddfa68 100644
+--- a/BaseTools/Source/C/DevicePath/GNUmakefile
++++ b/BaseTools/Source/C/DevicePath/GNUmakefile
+@@ -13,6 +13,9 @@ OBJECTS = DevicePath.o UefiDevicePathLib.o DevicePathFromText.o  DevicePathUtili
+ 
+ include $(MAKEROOT)/Makefiles/app.makefile
+ 
++# gcc 12 trips over device path handling
++BUILD_CFLAGS += -Wno-error=stringop-overflow
++
+ LIBS = -lCommon
+ ifeq ($(CYGWIN), CYGWIN)
+   LIBS += -L/lib/e2fsprogs -luuid
diff --git a/meta-arm/recipes-bsp/uefi/files/0002-BaseTools-fix-gcc12-warning.patch b/meta-arm/recipes-bsp/uefi/files/0002-BaseTools-fix-gcc12-warning.patch
new file mode 100644
index 0000000000000000000000000000000000000000..22297c67bb6ca798f4b177867d99610294320cc8
--- /dev/null
+++ b/meta-arm/recipes-bsp/uefi/files/0002-BaseTools-fix-gcc12-warning.patch
@@ -0,0 +1,47 @@ 
+From 85021f8cf22d1bd4114803c6c610dea5ef0059f1 Mon Sep 17 00:00:00 2001
+From: Gerd Hoffmann <kraxel@redhat.com>
+Date: Thu, 24 Mar 2022 20:04:35 +0800
+Subject: [PATCH] BaseTools: fix gcc12 warning
+
+Sdk/C/LzmaEnc.c: In function ?LzmaEnc_CodeOneMemBlock?:
+Sdk/C/LzmaEnc.c:2828:19: error: storing the address of local variable ?outStream? in ?*p.rc.outStream? [-Werror=dangling-pointer=]
+ 2828 |   p->rc.outStream = &outStream.vt;
+      |   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?outStream? declared here
+ 2811 |   CLzmaEnc_SeqOutStreamBuf outStream;
+      |                            ^~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?pp? declared here
+Sdk/C/LzmaEnc.c:2828:19: error: storing the address of local variable ?outStream? in ?*(CLzmaEnc *)pp.rc.outStream? [-Werror=dangling-pointer=]
+ 2828 |   p->rc.outStream = &outStream.vt;
+      |   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?outStream? declared here
+ 2811 |   CLzmaEnc_SeqOutStreamBuf outStream;
+      |                            ^~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?pp? declared here
+cc1: all warnings being treated as errors
+
+Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
+Reviewed-by: Bob Feng <bob.c.feng@intel.com>
+---
+ BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
+index 4e9b499f8d80..4b9f5fa69248 100644
+--- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
++++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
+@@ -2825,12 +2825,13 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit,
+ 
+   nowPos64 = p->nowPos64;
+   RangeEnc_Init(&p->rc);
+-  p->rc.outStream = &outStream.vt;
+ 
+   if (desiredPackSize == 0)
+     return SZ_ERROR_OUTPUT_EOF;
+ 
++  p->rc.outStream = &outStream.vt;
+   res = LzmaEnc_CodeOneBlock(p, desiredPackSize, *unpackSize);
++  p->rc.outStream = NULL;
+ 
+   *unpackSize = (UInt32)(p->nowPos64 - nowPos64);
+   *destLen -= outStream.rem;
diff --git a/meta-arm/recipes-bsp/uefi/files/0003-BaseTools-fix-gcc12-warning.patch b/meta-arm/recipes-bsp/uefi/files/0003-BaseTools-fix-gcc12-warning.patch
new file mode 100644
index 0000000000000000000000000000000000000000..77e1d97b2f57820fbe96b7309782fc89690457d2
--- /dev/null
+++ b/meta-arm/recipes-bsp/uefi/files/0003-BaseTools-fix-gcc12-warning.patch
@@ -0,0 +1,45 @@ 
+From 7b005f344e533cd913c3ca05b266f9872df886d1 Mon Sep 17 00:00:00 2001
+From: Gerd Hoffmann <kraxel@redhat.com>
+Date: Thu, 24 Mar 2022 20:04:34 +0800
+Subject: [PATCH] BaseTools: fix gcc12 warning
+
+GenFfs.c:545:5: error: pointer ?InFileHandle? used after ?fclose? [-Werror=use-after-free]
+  545 |     Error(NULL, 0, 4001, "Resource", "memory cannot be allocated  of %s", InFileHandle);
+      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+GenFfs.c:544:5: note: call to ?fclose? here
+  544 |     fclose (InFileHandle);
+      |     ^~~~~~~~~~~~~~~~~~~~~
+
+Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
+Reviewed-by: Bob Feng <bob.c.feng@intel.com>
+---
+ BaseTools/Source/C/GenFfs/GenFfs.c | 2 +-
+ BaseTools/Source/C/GenSec/GenSec.c | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/BaseTools/Source/C/GenFfs/GenFfs.c b/BaseTools/Source/C/GenFfs/GenFfs.c
+index 949025c33325..d78d62ab3689 100644
+--- a/BaseTools/Source/C/GenFfs/GenFfs.c
++++ b/BaseTools/Source/C/GenFfs/GenFfs.c
+@@ -542,7 +542,7 @@ GetAlignmentFromFile(char *InFile, UINT32 *Alignment)
+   PeFileBuffer = (UINT8 *) malloc (PeFileSize);
+   if (PeFileBuffer == NULL) {
+     fclose (InFileHandle);
+-    Error(NULL, 0, 4001, "Resource", "memory cannot be allocated  of %s", InFileHandle);
++    Error(NULL, 0, 4001, "Resource", "memory cannot be allocated for %s", InFile);
+     return EFI_OUT_OF_RESOURCES;
+   }
+   fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle);
+diff --git a/BaseTools/Source/C/GenSec/GenSec.c b/BaseTools/Source/C/GenSec/GenSec.c
+index d54a4f9e0a7d..b1d05367ec0b 100644
+--- a/BaseTools/Source/C/GenSec/GenSec.c
++++ b/BaseTools/Source/C/GenSec/GenSec.c
+@@ -1062,7 +1062,7 @@ GetAlignmentFromFile(char *InFile, UINT32 *Alignment)
+   PeFileBuffer = (UINT8 *) malloc (PeFileSize);
+   if (PeFileBuffer == NULL) {
+     fclose (InFileHandle);
+-    Error(NULL, 0, 4001, "Resource", "memory cannot be allocated  of %s", InFileHandle);
++    Error(NULL, 0, 4001, "Resource", "memory cannot be allocated for %s", InFile);
+     return EFI_OUT_OF_RESOURCES;
+   }
+   fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle);