Heinrich Schuchardt | 2a6daf7 | 2017-10-05 16:36:07 +0200 | [diff] [blame] | 1 | /* |
| 2 | * efi_selftest_util |
| 3 | * |
| 4 | * Copyright (c) 2017 Heinrich Schuchardt <xypron.glpk@gmx.de> |
| 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0+ |
| 7 | * |
| 8 | * Utility functions |
| 9 | */ |
| 10 | |
| 11 | #include <efi_selftest.h> |
| 12 | |
| 13 | int efi_st_memcmp(const void *buf1, const void *buf2, size_t length) |
| 14 | { |
| 15 | const u8 *pos1 = buf1; |
| 16 | const u8 *pos2 = buf2; |
| 17 | |
| 18 | for (; length; --length) { |
| 19 | if (*pos1 != *pos2) |
Heinrich Schuchardt | ea09093 | 2017-10-06 20:39:13 +0200 | [diff] [blame] | 20 | return *pos1 - *pos2; |
Heinrich Schuchardt | 2a6daf7 | 2017-10-05 16:36:07 +0200 | [diff] [blame] | 21 | ++pos1; |
| 22 | ++pos2; |
| 23 | } |
Heinrich Schuchardt | a8ec628 | 2017-10-18 18:13:11 +0200 | [diff] [blame] | 24 | return 0; |
Heinrich Schuchardt | 2a6daf7 | 2017-10-05 16:36:07 +0200 | [diff] [blame] | 25 | } |
Heinrich Schuchardt | 02efd5d | 2017-10-18 18:13:13 +0200 | [diff] [blame] | 26 | |
| 27 | int efi_st_strcmp_16_8(const u16 *buf1, const char *buf2) |
| 28 | { |
| 29 | for (; *buf1 || *buf2; ++buf1, ++buf2) { |
| 30 | if (*buf1 != *buf2) |
| 31 | return *buf1 - *buf2; |
| 32 | } |
| 33 | return 0; |
| 34 | } |