From 9e63f130a72cf489dab79e12c2375679bd63cf52 Mon Sep 17 00:00:00 2001 From: tsoome Date: Thu, 14 Dec 2017 16:41:52 +0000 Subject: [PATCH] libefi: make efichar.h more usable in stand code Use _STANDALONE for guard expression in efichar.[ch] and add efi_char typedef. clean up boot1.c, and replace for loop in efipart.c with ucs2len(). Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D13488 --- stand/efi/boot1/boot1.c | 1 - stand/efi/include/efichar.h | 6 ++++++ stand/efi/libefi/Makefile | 2 -- stand/efi/libefi/efichar.c | 4 ++-- stand/efi/libefi/efipart.c | 4 ++-- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/stand/efi/boot1/boot1.c b/stand/efi/boot1/boot1.c index b7cb57f45530..7b51f03e14af 100644 --- a/stand/efi/boot1/boot1.c +++ b/stand/efi/boot1/boot1.c @@ -29,7 +29,6 @@ __FBSDID("$FreeBSD$"); #include #include -typedef CHAR16 efi_char; #include #include "boot_module.h" diff --git a/stand/efi/include/efichar.h b/stand/efi/include/efichar.h index 2fa4ed44792c..49ff43b3cb20 100644 --- a/stand/efi/include/efichar.h +++ b/stand/efi/include/efichar.h @@ -29,6 +29,12 @@ #ifndef _BOOT_EFI_EFICHAR_H_ #define _BOOT_EFI_EFICHAR_H_ +#ifdef _STANDALONE +#include + +typedef CHAR16 efi_char; +#endif + int ucs2_to_utf8(const efi_char *, char **); int utf8_to_ucs2(const char *, efi_char **, size_t *); int ucs2len(const efi_char *); diff --git a/stand/efi/libefi/Makefile b/stand/efi/libefi/Makefile index e0ffd7b80f62..f5cf71ea7c6d 100644 --- a/stand/efi/libefi/Makefile +++ b/stand/efi/libefi/Makefile @@ -52,6 +52,4 @@ CFLAGS+= ${FORMAT_EXTENSIONS} CFLAGS+= -DTERM_EMU .endif -CFLAGS+= -DLIBEFI - .include diff --git a/stand/efi/libefi/efichar.c b/stand/efi/libefi/efichar.c index dad4e963300c..15aa5cae3a59 100644 --- a/stand/efi/libefi/efichar.c +++ b/stand/efi/libefi/efichar.c @@ -29,16 +29,16 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef LIBEFI +#ifdef _STANDALONE #include #else #include #include #include #include -#endif #include #include +#endif #include "efichar.h" diff --git a/stand/efi/libefi/efipart.c b/stand/efi/libefi/efipart.c index 3193cd5ab43e..e0dfa874ae10 100644 --- a/stand/efi/libefi/efipart.c +++ b/stand/efi/libefi/efipart.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include static EFI_GUID blkio_guid = BLOCK_IO_PROTOCOL; @@ -564,8 +565,7 @@ efipart_hdinfo_add_filepath(EFI_HANDLE disk_handle) unit = 0; /* FILEPATH_DEVICE_PATH has 0 terminated string */ - for (len = 0; node->PathName[len] != 0; len++) - ; + len = ucs2len(node->PathName); if ((pathname = malloc(len + 1)) == NULL) { printf("Failed to add disk, out of memory\n"); free(pd);