Anastasia Klimchuk has uploaded this change for review.

View Change

tests: Add wrap for __fprintf_chk

The wrap for __fprintf_chk is needed for clang on Linux, it is used
instead of fprintf function.

BUG=b:237606255
TEST=ninja test on
1) gcc 12.2.0 on Debian
2)

Ticket: https://ticket.coreboot.org/issues/411
Change-Id: I70cb1cd90d1f377ff4606acad3c1b514120ae4f7
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
---
M tests/meson.build
M tests/tests.c
M tests/wraps.h
3 files changed, 29 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/32/68432/1
diff --git a/tests/meson.build b/tests/meson.build
index c62cc1b..74001cb 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -72,6 +72,7 @@
'-Wl,--wrap=__fgets_chk',
'-Wl,--wrap=fprintf',
'-Wl,--wrap=__vfprintf_chk',
+ '-Wl,--wrap=__fprintf_chk',
'-Wl,--wrap=fclose',
'-Wl,--wrap=feof',
'-Wl,--wrap=ferror',
diff --git a/tests/tests.c b/tests/tests.c
index 53bad65..c110e48 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -290,6 +290,14 @@
return 0;
}

+int __wrap___fprintf_chk(FILE *fp, const char *fmt, va_list args)
+{
+ LOG_ME;
+ if (get_io() && get_io()->fprintf)
+ return get_io()->fprintf(get_io()->state, fp, fmt, args);
+ return 0;
+}
+
int __wrap_fclose(FILE *fp)
{
LOG_ME;
diff --git a/tests/wraps.h b/tests/wraps.h
index f97eaba..10a5165 100644
--- a/tests/wraps.h
+++ b/tests/wraps.h
@@ -55,6 +55,7 @@
int __wrap_setvbuf(FILE *fp, char *buf, int type, size_t size);
int __wrap_fprintf(FILE *fp, const char *fmt, ...);
int __wrap___vfprintf_chk(FILE *fp, const char *fmt, va_list args);
+int __wrap___fprintf_chk(FILE *fp, const char *fmt, va_list args);
int __wrap_fclose(FILE *fp);
int __wrap_feof(FILE *fp);
int __wrap_ferror(FILE *fp);

To view, visit change 68432. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I70cb1cd90d1f377ff4606acad3c1b514120ae4f7
Gerrit-Change-Number: 68432
Gerrit-PatchSet: 1
Gerrit-Owner: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-MessageType: newchange