SPDX: Convert all of our single license tags to Linux Kernel style
[oweals/u-boot.git] / lib / efi_selftest / efi_selftest_util.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * efi_selftest_util
4  *
5  * Copyright (c) 2017 Heinrich Schuchardt <xypron.glpk@gmx.de>
6  *
7  * Utility functions
8  */
9
10 #include <efi_selftest.h>
11
12 int efi_st_memcmp(const void *buf1, const void *buf2, size_t length)
13 {
14         const u8 *pos1 = buf1;
15         const u8 *pos2 = buf2;
16
17         for (; length; --length) {
18                 if (*pos1 != *pos2)
19                         return *pos1 - *pos2;
20                 ++pos1;
21                 ++pos2;
22         }
23         return 0;
24 }
25
26 int efi_st_strcmp_16_8(const u16 *buf1, const char *buf2)
27 {
28         for (; *buf1 || *buf2; ++buf1, ++buf2) {
29                 if (*buf1 != *buf2)
30                         return *buf1 - *buf2;
31         }
32         return 0;
33 }