1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-08 05:09:24 +00:00

ovmf: backport a fix for build with gcc-16

Fixes build on host with gcc-16:

StringFuncs.c: In function ‘SplitStringByWhitespace’:
StringFuncs.c:113:15: error: variable ‘Item’ set but not used [-Werror=unused-but-set-variable=]
  113 |   UINTN       Item;
      |               ^~~~

and

EfiRom.c: In function ‘main’:
EfiRom.c:78:17: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   78 |       if ((Ptr0 = strstr ((CONST CHAR8 *) mOptions.FileList->FileName, DEFAULT_OUTPUT_EXTENSION)) != NULL) {
      |                 ^

and one more for older version used in scarthgap

main.c: In function ‘ProcessArgs’:
main.c:163:42: error: too many arguments to function ‘p->process’; expected 0, have 2
  163 |                                         (*p->process)( *argv, *(argv+1) );
      |                                         ~^~~~~~~~~~~~  ~~~~~
main.c:120:34: note: declared here
  120 |                         WildFunc process;
      |                                  ^~~~~~~
main.c:168:42: error: too many arguments to function ‘p->process’; expected 0, have 1
  168 |                                         (*p->process)( *argv );
      |                                         ~^~~~~~~~~~~~  ~~~~~
main.c:120:34: note: declared here
  120 |                         WildFunc process;
      |                                  ^~~~~~~

(From OE-Core rev: 7de54889b3547a94bc7c6015731ec1c099e4d629)

Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
[YC: upstream commit a1db482ecd2824a4ae67a3c2a8e607b607ab4a43]
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Paul Barker <paul@pbarker.dev>
This commit is contained in:
Martin Jansa
2026-04-12 10:08:13 +02:00
committed by Paul Barker
parent d6cada74f6
commit f3e45f9d3e
4 changed files with 133 additions and 0 deletions
@@ -0,0 +1,42 @@
From 015c26aea52a54e96319887ea542870b4804fb91 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Thu, 29 Jan 2026 09:23:32 +0100
Subject: [PATCH] BaseTools/StringFuncs: fix gcc 16 warning
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
StringFuncs.c: In function SplitStringByWhitespace:
StringFuncs.c:113:15: error: variable Item set but not used [-Werror=unused-but-set-variable=]
113 | UINTN Item;
| ^~~~
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Upstream-Status: Backport [edk2-stable202602 https://github.com/tianocore/edk2/commit/3597306191297b504683b83fe7750e49c6a2e836]
Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
---
BaseTools/Source/C/Common/StringFuncs.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/BaseTools/Source/C/Common/StringFuncs.c b/BaseTools/Source/C/Common/StringFuncs.c
index 53e44365e9..df02d9c808 100644
--- a/BaseTools/Source/C/Common/StringFuncs.c
+++ b/BaseTools/Source/C/Common/StringFuncs.c
@@ -110,7 +110,6 @@ SplitStringByWhitespace (
CHAR8 *EndOfSubString;
CHAR8 *EndOfString;
STRING_LIST *Output;
- UINTN Item;
String = CloneString (String);
if (String == NULL) {
@@ -120,7 +119,7 @@ SplitStringByWhitespace (
Output = NewStringList ();
- for (Pos = String, Item = 0; Pos < EndOfString; Item++) {
+ for (Pos = String; Pos < EndOfString;) {
while (isspace ((int)*Pos)) {
Pos++;
}
@@ -0,0 +1,44 @@
From 4d2bdadcd6d45f6708b1b4827b0dc9b6e4b8edd2 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Mon, 8 Dec 2025 10:28:50 +0100
Subject: [PATCH] BaseTools/EfiRom: fix compiler warning
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
New warning after updating gcc:
EfiRom.c: In function main:
EfiRom.c:78:17: error: assignment discards const qualifier from pointer target type [-Werror=discarded-qualifiers]
The assigned value is not used, so fix the warning by just removing it.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Upstream-Status: Backport [edk2-stable202602 https://github.com/tianocore/edk2/commit/9af06ef3cbb052b142f9660c2c01e7aeb401300c]
Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
---
BaseTools/Source/C/EfiRom/EfiRom.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/BaseTools/Source/C/EfiRom/EfiRom.c b/BaseTools/Source/C/EfiRom/EfiRom.c
index fa7bf0e62e..6e903b3504 100644
--- a/BaseTools/Source/C/EfiRom/EfiRom.c
+++ b/BaseTools/Source/C/EfiRom/EfiRom.c
@@ -44,7 +44,6 @@ Returns:
FILE_LIST *FList;
UINT32 TotalSize;
UINT32 Size;
- CHAR8 *Ptr0;
SetUtilityName(UTILITY_NAME);
@@ -75,7 +74,7 @@ Returns:
//
if (mOptions.DumpOption == 1) {
if (mOptions.FileList != NULL) {
- if ((Ptr0 = strstr ((CONST CHAR8 *) mOptions.FileList->FileName, DEFAULT_OUTPUT_EXTENSION)) != NULL) {
+ if (strstr ((CONST CHAR8 *) mOptions.FileList->FileName, DEFAULT_OUTPUT_EXTENSION) != NULL) {
DumpImage (mOptions.FileList);
goto BailOut;
} else {
@@ -0,0 +1,44 @@
From 74bc6545e72707a47dd9dae42ce33b8877b10000 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Mon, 20 Jan 2025 09:40:31 +0100
Subject: [PATCH] BaseTools/Pccts: set C standard
The prehistoric code base doesn't build with ISO C23. Set the C
standard to C11 (for both clang and gcc) so it continues to build with
gcc 15 (which uses C23 by default).
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Upstream-Status: Backport [edk2-stable202502 https://github.com/tianocore/edk2/commit/e063f8b8a53861043b9872cc35b08a3dc03b0942]
Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
---
BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile | 2 +-
BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile b/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile
index 746d58b5e2..b47c8a37af 100644
--- a/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile
+++ b/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile
@@ -169,7 +169,7 @@ ANTLR=${BIN_DIR}/antlr
DLG=${BIN_DIR}/dlg
OBJ_EXT=o
OUT_OBJ = -o
-CFLAGS= $(COPT) -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN $(COTHER) -DZZLEXBUFSIZE=65536
+CFLAGS= $(COPT) -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN $(COTHER) -DZZLEXBUFSIZE=65536 -std=gnu11
CPPFLAGS=
#
# SGI Users, use this CFLAGS
diff --git a/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile b/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile
index e45ac98e04..d72bee3d70 100644
--- a/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile
+++ b/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile
@@ -123,7 +123,7 @@ endif
COPT=-O
ANTLR=${BIN_DIR}/antlr
DLG=${BIN_DIR}/dlg
-CFLAGS= $(COPT) -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -DZZLEXBUFSIZE=65536
+CFLAGS= $(COPT) -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -DZZLEXBUFSIZE=65536 -std=gnu11
CPPFLAGS=
OBJ_EXT=o
OUT_OBJ = -o
+3
View File
@@ -26,6 +26,9 @@ SRC_URI = "gitsm://github.com/tianocore/edk2.git;branch=master;protocol=https \
file://0004-reproducible.patch \ file://0004-reproducible.patch \
file://0001-MdePkg-Fix-overflow-issue-in-BasePeCoffLib.patch \ file://0001-MdePkg-Fix-overflow-issue-in-BasePeCoffLib.patch \
file://0001-MdeModulePkg-Potential-UINT32-overflow-in-S3-ResumeC.patch \ file://0001-MdeModulePkg-Potential-UINT32-overflow-in-S3-ResumeC.patch \
file://0006-BaseTools-StringFuncs-fix-gcc-16-warning.patch \
file://0007-BaseTools-EfiRom-fix-compiler-warning.patch \
file://0008-BaseTools-Pccts-set-C-standard.patch \
" "
PV = "edk2-stable202402" PV = "edk2-stable202402"