mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 23:24:38 +00:00
lib: convert u16_strlen() into a macro
The function u16_strlen() can be implemented as call to u16_strnlen(). Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
This commit is contained in:
parent
fe869e11c7
commit
0121282d1a
2 changed files with 14 additions and 24 deletions
|
@ -200,18 +200,6 @@ int u16_strncmp(const u16 *s1, const u16 *s2, size_t n);
|
|||
*/
|
||||
#define u16_strcmp(s1, s2) u16_strncmp((s1), (s2), SIZE_MAX)
|
||||
|
||||
/**
|
||||
* u16_strlen - count non-zero words
|
||||
*
|
||||
* This function matches wsclen() if the -fshort-wchar compiler flag is set.
|
||||
* In the EFI context we explicitly need a function handling u16 strings.
|
||||
*
|
||||
* @in: null terminated u16 string
|
||||
* Return: number of non-zero words.
|
||||
* This is not the number of utf-16 letters!
|
||||
*/
|
||||
size_t u16_strlen(const void *in);
|
||||
|
||||
/**
|
||||
* u16_strsize() - count size of u16 string in bytes including the null
|
||||
* character
|
||||
|
@ -236,6 +224,20 @@ size_t u16_strsize(const void *in);
|
|||
*/
|
||||
size_t u16_strnlen(const u16 *in, size_t count);
|
||||
|
||||
/**
|
||||
* u16_strlen - count non-zero words
|
||||
*
|
||||
* This function matches wsclen() if the -fshort-wchar compiler flag is set.
|
||||
* In the EFI context we explicitly need a function handling u16 strings.
|
||||
*
|
||||
* @in: null terminated u16 string
|
||||
* Return: number of non-zero words.
|
||||
* This is not the number of utf-16 letters!
|
||||
*/
|
||||
size_t u16_strlen(const void *in);
|
||||
|
||||
#define u16_strlen(in) u16_strnlen(in, SIZE_MAX)
|
||||
|
||||
/**
|
||||
* u16_strcpy() - copy u16 string
|
||||
*
|
||||
|
|
|
@ -375,18 +375,6 @@ int u16_strncmp(const u16 *s1, const u16 *s2, size_t n)
|
|||
return ret;
|
||||
}
|
||||
|
||||
size_t u16_strlen(const void *in)
|
||||
{
|
||||
const char *pos = in;
|
||||
size_t ret;
|
||||
|
||||
for (; pos[0] || pos[1]; pos += 2)
|
||||
;
|
||||
ret = pos - (char *)in;
|
||||
ret >>= 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t __efi_runtime u16_strnlen(const u16 *in, size_t count)
|
||||
{
|
||||
size_t i;
|
||||
|
|
Loading…
Reference in a new issue