blob: 87a04f898a47ad18c334d7242b3d5a739c041aeb [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Heinrich Schuchardt2a6daf72017-10-05 16:36:07 +02002/*
3 * efi_selftest_util
4 *
5 * Copyright (c) 2017 Heinrich Schuchardt <xypron.glpk@gmx.de>
6 *
Heinrich Schuchardt2a6daf72017-10-05 16:36:07 +02007 * Utility functions
8 */
9
10#include <efi_selftest.h>
11
12int 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)
Heinrich Schuchardtea090932017-10-06 20:39:13 +020019 return *pos1 - *pos2;
Heinrich Schuchardt2a6daf72017-10-05 16:36:07 +020020 ++pos1;
21 ++pos2;
22 }
Heinrich Schuchardta8ec6282017-10-18 18:13:11 +020023 return 0;
Heinrich Schuchardt2a6daf72017-10-05 16:36:07 +020024}
Heinrich Schuchardt02efd5d2017-10-18 18:13:13 +020025
26int 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}