Skip to content
Snippets Groups Projects
0015-test.c-Conditionally-do-not-declare-stuff-that-s-in-.patch 1.81 KiB
Newer Older
From b092c85fc3e9caec83728b244a34ed8325a02c6d Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 2 Jul 2021 14:05:47 -0400
Subject: [PATCH 15/26] test.c: Conditionally do not declare stuff that's in
 other places

test.c duplicates a couple of objects (StrnCmp, StrCmp) that are
in libefi.a, as well as SHIM_LOCK_GUID from lib/guid.o.  While it's nice
to have these at some places, we need to disable them if we're actually
linking a test case against either of those.

This patch adds HAVE_foo guards around those objects.

Signed-off-by: Peter Jones <pjones@redhat.com>
---
 test.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/test.c b/test.c
index dc71941..9da5cf5 100644
--- a/test.c
+++ b/test.c
@@ -22,6 +22,7 @@ LogError_(const char *file, int line, const char *func, const CHAR16 *fmt, ...)
 	return EFI_SUCCESS;
 }
 
+#ifndef HAVE_STRCMP
 INTN
 StrCmp(CONST CHAR16 *s1, CONST CHAR16 *s2) {
 	assert(s1 != NULL);
@@ -34,7 +35,9 @@ StrCmp(CONST CHAR16 *s1, CONST CHAR16 *s2) {
 	}
 	return 0;
 }
+#endif
 
+#ifndef HAVE_STRNCMP
 INTN
 StrnCmp(CONST CHAR16 *s1, CONST CHAR16 *s2, UINTN len) {
 	assert(s1 != NULL);
@@ -48,20 +51,27 @@ StrnCmp(CONST CHAR16 *s1, CONST CHAR16 *s2, UINTN len) {
 	}
 	return 0;
 }
+#endif
 
+#ifndef HAVE_GET_VARIABLE_ATTR
 EFI_STATUS
 get_variable_attr(const CHAR16 * const var, UINT8 **data, UINTN *len,
 		  EFI_GUID owner, UINT32 *attributes)
 {
 	return EFI_UNSUPPORTED;
 }
+#endif
 
+#ifndef HAVE_GET_VARIABLE
 EFI_STATUS
 get_variable(const CHAR16 * const var, UINT8 **data, UINTN *len, EFI_GUID owner)
 {
 	return get_variable_attr(var, data, len, owner, NULL);
 }
+#endif
 
+#ifndef HAVE_SHIM_LOCK_GUID
 EFI_GUID SHIM_LOCK_GUID = {0x605dab50, 0xe046, 0x4300, {0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23 } };
+#endif
 
 // vim:fenc=utf-8:tw=75:noet
-- 
2.32.0