svn commit: r323258 - in head/sys/boot/efi: boot1 include libefi
Warner Losh
imp at FreeBSD.org
Thu Sep 7 07:30:08 UTC 2017
Author: imp
Date: Thu Sep 7 07:30:05 2017
New Revision: 323258
URL: https://svnweb.freebsd.org/changeset/base/323258
Log:
ucs2len
Rename boot1's wcslen to ucs2len, which we can't use in userland
because wchar in userland is unsigned, not short. Move it into
efichar.c. Also spell '* 2' as '* sizeof(efi_char)' and add 1 for the
trailing NUL to transition the FreeBSD boot env vars to being NUL
terminated on the same line...
Sponsored by: Netflix
Modified:
head/sys/boot/efi/boot1/boot1.c
head/sys/boot/efi/include/efichar.h
head/sys/boot/efi/libefi/efichar.c
Modified: head/sys/boot/efi/boot1/boot1.c
==============================================================================
--- head/sys/boot/efi/boot1/boot1.c Thu Sep 7 07:24:22 2017 (r323257)
+++ head/sys/boot/efi/boot1/boot1.c Thu Sep 7 07:30:05 2017 (r323258)
@@ -80,17 +80,6 @@ Free(void *buf, const char *file __unused, int line __
(void)BS->FreePool(buf);
}
-static int
-wcslen(const CHAR16 *str)
-{
- int i;
-
- i = 0;
- while (*str++)
- i++;
- return i;
-}
-
static EFI_STATUS
efi_setenv_freebsd_wcs(const char *varname, CHAR16 *valstr)
{
@@ -103,7 +92,7 @@ efi_setenv_freebsd_wcs(const char *varname, CHAR16 *va
return (EFI_OUT_OF_RESOURCES);
rv = RS->SetVariable(var, &FreeBSDBootVarGUID,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- wcslen(valstr) * 2, valstr);
+ (ucs2len(valstr) + 1) * sizeof(efi_char), valstr);
free(var);
return (rv);
}
Modified: head/sys/boot/efi/include/efichar.h
==============================================================================
--- head/sys/boot/efi/include/efichar.h Thu Sep 7 07:24:22 2017 (r323257)
+++ head/sys/boot/efi/include/efichar.h Thu Sep 7 07:30:05 2017 (r323258)
@@ -31,5 +31,6 @@
int ucs2_to_utf8(const efi_char *, char **);
int utf8_to_ucs2(const char *, efi_char **, size_t *);
+int ucs2len(const efi_char *);
#endif /* _BOOT_EFI_EFICHAR_H_ */
Modified: head/sys/boot/efi/libefi/efichar.c
==============================================================================
--- head/sys/boot/efi/libefi/efichar.c Thu Sep 7 07:24:22 2017 (r323257)
+++ head/sys/boot/efi/libefi/efichar.c Thu Sep 7 07:30:05 2017 (r323258)
@@ -42,6 +42,17 @@ __FBSDID("$FreeBSD$");
#include "efichar.h"
+int
+ucs2len(const efi_char *str)
+{
+ int i;
+
+ i = 0;
+ while (*str++)
+ i++;
+ return i;
+}
+
/*
* If nm were converted to utf8, what what would strlen
* return on the resulting string?
More information about the svn-src-all
mailing list