summaryrefslogtreecommitdiff
path: root/drivers/firmware/efi/libstub/string.c
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2022-10-11 16:27:45 +0300
committerArd Biesheuvel <ardb@kernel.org>2022-11-09 14:42:02 +0300
commit2e6fa86f2d484ff9a0047e20a48c1400314a5bb6 (patch)
tree4ff6658afebecdf141b3170f148069ea0bc41474 /drivers/firmware/efi/libstub/string.c
parent52dce39cd2786673969a12d1c94e0922d9208f83 (diff)
downloadlinux-2e6fa86f2d484ff9a0047e20a48c1400314a5bb6.tar.xz
efi: libstub: Enable efi_printk() in zboot decompressor
Split the efi_printk() routine into its own source file, and provide local implementations of strlen() and strnlen() so that the standalone zboot app can efi_err and efi_info etc. Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Diffstat (limited to 'drivers/firmware/efi/libstub/string.c')
-rw-r--r--drivers/firmware/efi/libstub/string.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/drivers/firmware/efi/libstub/string.c b/drivers/firmware/efi/libstub/string.c
index 9f5810d86646..5a1519d435bf 100644
--- a/drivers/firmware/efi/libstub/string.c
+++ b/drivers/firmware/efi/libstub/string.c
@@ -11,7 +11,37 @@
#include <linux/types.h>
#include <linux/string.h>
-#ifndef __HAVE_ARCH_STRSTR
+#ifndef EFI_HAVE_STRLEN
+/**
+ * strlen - Find the length of a string
+ * @s: The string to be sized
+ */
+size_t strlen(const char *s)
+{
+ const char *sc;
+
+ for (sc = s; *sc != '\0'; ++sc)
+ /* nothing */;
+ return sc - s;
+}
+#endif
+
+#ifndef EFI_HAVE_STRNLEN
+/**
+ * strnlen - Find the length of a length-limited string
+ * @s: The string to be sized
+ * @count: The maximum number of bytes to search
+ */
+size_t strnlen(const char *s, size_t count)
+{
+ const char *sc;
+
+ for (sc = s; count-- && *sc != '\0'; ++sc)
+ /* nothing */;
+ return sc - s;
+}
+#endif
+
/**
* strstr - Find the first substring in a %NUL terminated string
* @s1: The string to be searched
@@ -33,7 +63,6 @@ char *strstr(const char *s1, const char *s2)
}
return NULL;
}
-#endif
/**
* strncmp - Compare two length-limited strings