Skip to content

Commit

Permalink
efivars: introduce utf16_strncmp
Browse files Browse the repository at this point in the history
Introduce utf16_strncmp which is used in the next patch.  Semantics
should be the same as the strncmp C function.

Signed-off-by: Mike Waychison <mikew@google.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
  • Loading branch information
Mike Waychison authored and Tony Luck committed Jul 22, 2011
1 parent a294090 commit 828aa1f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions drivers/firmware/efivars.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,24 @@ utf16_strsize(efi_char16_t *data, unsigned long maxlength)
return utf16_strnlen(data, maxlength/sizeof(efi_char16_t)) * sizeof(efi_char16_t);
}

static inline int
utf16_strncmp(const efi_char16_t *a, const efi_char16_t *b, size_t len)
{
while (1) {
if (len == 0)
return 0;
if (*a < *b)
return -1;
if (*a > *b)
return 1;
if (*a == 0) /* implies *b == 0 */
return 0;
a++;
b++;
len--;
}
}

static efi_status_t
get_var_data_locked(struct efivars *efivars, struct efi_variable *var)
{
Expand Down

0 comments on commit 828aa1f

Please sign in to comment.